初步完成merchant和admin不同role的展示内容逻辑2
This commit is contained in:
@@ -17,6 +17,7 @@ export type DeviceState = {
|
||||
export type State = {
|
||||
globalNum : number
|
||||
userProfile ?: UserProfile
|
||||
authUser ?: UTSJSONObject
|
||||
isLoggedIn : boolean // 新增字段
|
||||
deviceState : DeviceState // 新增设备状态
|
||||
// 如有需要,可增加更多属性
|
||||
@@ -26,6 +27,7 @@ export type State = {
|
||||
export const state = reactive({
|
||||
globalNum: 0,
|
||||
userProfile: { username: '', email: '' },
|
||||
authUser: null,
|
||||
isLoggedIn: false,
|
||||
deviceState: {
|
||||
devices: [],
|
||||
@@ -54,6 +56,7 @@ export async function getCurrentUser() : Promise<UserProfile | null> {
|
||||
} catch (_) {}
|
||||
|
||||
const sessionInfo = supa.getSession()
|
||||
state.authUser = sessionInfo.user
|
||||
if (sessionInfo.user == null) {
|
||||
state.userProfile = { username: '', email: '' }
|
||||
state.isLoggedIn = false // 未登录
|
||||
@@ -174,6 +177,7 @@ export function getUserStore() {
|
||||
return {
|
||||
getUserId() : string | null {
|
||||
const sessionInfo = supa.getSession()
|
||||
state.authUser = sessionInfo.user
|
||||
return sessionInfo.user?.getString("id") ?? null
|
||||
},
|
||||
|
||||
@@ -184,6 +188,7 @@ export function getUserStore() {
|
||||
getUserRole() : string | null {
|
||||
// Default role logic - can be enhanced based on your needs
|
||||
const sessionInfo = supa.getSession()
|
||||
state.authUser = sessionInfo.user
|
||||
if (sessionInfo.user == null) return null
|
||||
|
||||
// You can add role detection logic here
|
||||
|
||||
Reference in New Issue
Block a user