u
This commit is contained in:
1 parent
68e0785ec6
commit
57c0d98f11
189 files changed
+34329
No files matched your search
@@ -0,0 +1,13 @@
|
||||
import type { Area } from '@/types/company/area'
|
||||
import type { Property } from '@/types/company/peoperty'
|
||||
import { reactive } from 'vue'
|
||||
|
||||
const areaOptions = reactive<Area[]>([])
|
||||
const propertyOptions = reactive<Property[]>([])
|
||||
|
||||
export function useCommonOptions() {
|
||||
return {
|
||||
areaOptions,
|
||||
propertyOptions,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { App } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import { createPersistedState } from 'pinia-plugin-persistedstate'
|
||||
|
||||
export function setupPinia(app: App) {
|
||||
const store = createPinia()
|
||||
store.use(createPersistedState())
|
||||
app.use(store)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
interface IUserInfo {
|
||||
id: number
|
||||
account?: string
|
||||
email?: string
|
||||
name?: string
|
||||
token?: string
|
||||
avatar?: string
|
||||
}
|
||||
|
||||
export const useUserStore = defineStore(
|
||||
'user',
|
||||
() => {
|
||||
const userInfo = ref<IUserInfo>({
|
||||
id: 0,
|
||||
})
|
||||
|
||||
const setUserInfo = (val: IUserInfo) => {
|
||||
userInfo.value = val
|
||||
}
|
||||
|
||||
const clearUserInfo = () => {
|
||||
}
|
||||
|
||||
// ✅ 如果需要同时验证多个字段
|
||||
const isLogined = computed(() => {
|
||||
return !!(
|
||||
(
|
||||
userInfo.value.token
|
||||
&& userInfo.value.id !== 0
|
||||
&& userInfo.value.account
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
return {
|
||||
userInfo,
|
||||
setUserInfo,
|
||||
clearUserInfo,
|
||||
isLogined,
|
||||
}
|
||||
},
|
||||
{
|
||||
persist: true,
|
||||
},
|
||||
)
|
||||
Reference in new issue
Block a user