Merge remote-tracking branch 'origin/huangzhenbao-admin'

This commit is contained in:
not-like-juvenile
2026-03-18 17:14:05 +08:00
676 changed files with 25158 additions and 46646 deletions

View File

@@ -1,4 +1,4 @@
import supa, { supaReady } from '@/components/supadb/aksupainstance.uts'
import supa, { supaReady } from '@/components/supadb/aksupainstance.uts'
import type { UserProfile, UserStats } from '@/pages/user/types.uts'
import type { DeviceInfo } from '@/pages/sense/types.uts'
import { SenseDataService, type DeviceParams } from '@/pages/sense/senseDataService.uts'
@@ -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,7 +56,8 @@ export async function getCurrentUser() : Promise<UserProfile | null> {
} catch (_) {}
const sessionInfo = supa.getSession()
state.authUser = sessionInfo.user
// 如果没有 session 但 state 中已有用户信息(可能是 admin 这种 mock 账号),不再强制清空
if (sessionInfo.user == null) {
const existingId = state.userProfile?.id
@@ -237,6 +240,7 @@ export function getUserStore() {
return {
getUserId() : string | null {
const sessionInfo = supa.getSession()
state.authUser = sessionInfo.user
return sessionInfo.user?.getString("id") ?? null
},
@@ -245,11 +249,15 @@ export function getUserStore() {
},
getUserRole() : string | null {
const profile = state.userProfile
if (profile != null && profile.role != null) {
return profile.role
}
return 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
// For now, return a default role
return 'teacher' // or determine from user profile/database
},
},
getProfile() : UserProfile | null {