mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2025-12-11 18:32:49 +00:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import { getConfig } from '@/app/api/auth'
|
|
|
|
interface loginConfig {
|
|
is_username: number | boolean,
|
|
is_mobile: number | boolean,
|
|
is_auth_register: number | boolean,
|
|
is_bind_mobile: number | boolean,
|
|
agreement_show: number | boolean
|
|
}
|
|
|
|
interface Config {
|
|
login: loginConfig
|
|
}
|
|
|
|
const useConfigStore = defineStore('config', {
|
|
state: (): Config => {
|
|
return {
|
|
login: {
|
|
is_username: 0,
|
|
is_mobile: 0,
|
|
is_auth_register: 0,
|
|
is_bind_mobile: 0,
|
|
agreement_show: 0
|
|
}
|
|
}
|
|
},
|
|
actions: {
|
|
async getLoginConfig(router: any = null) {
|
|
await getConfig().then(({ data }) => {
|
|
this.login.is_username = parseInt(data.is_username)
|
|
this.login.is_mobile = parseInt(data.is_mobile)
|
|
this.login.is_auth_register = parseInt(data.is_auth_register)
|
|
this.login.is_bind_mobile = parseInt(data.is_bind_mobile)
|
|
this.login.agreement_show = parseInt(data.agreement_show)
|
|
if(data && router && router.currentRoute.value.path === '/site/close'){
|
|
navigateTo('/', { replace: true })
|
|
}
|
|
}).catch(() => {
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
export default useConfigStore
|