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.

33 lines
713 B
JavaScript

8 months ago
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 => {
8 months ago
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 }
})