You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
import { defineStore } from 'pinia';
|
|
|
|
import { ref } from 'vue'
|
|
|
|
import { login, logout } from '@/api/common.js'
|
|
|
|
import { useUserStore } from '@/store/user.js'
|
|
|
|
|
|
|
|
export const useSystemStore = defineStore('system', () => {
|
|
|
|
const userStore = useUserStore()
|
|
|
|
let appInfo = ref({})
|
|
|
|
|
|
|
|
function setAppInfo (info) {
|
|
|
|
appInfo.value = info;
|
|
|
|
}
|
|
|
|
|
|
|
|
function Login(params) {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
login(params).then(res => {
|
|
|
|
userStore.setUserInfo(res);
|
|
|
|
resolve(res)
|
|
|
|
}).catch(error => {
|
|
|
|
console.log('登录失败:', error)
|
|
|
|
reject(error)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function Logout() {
|
|
|
|
return logout().then(res => {
|
|
|
|
return res;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return { Login, Logout, appInfo, setAppInfo }
|
|
|
|
})
|