1234567891011121314151617181920212223242526272829303132333435 |
- import { defineStore, createPinia } from 'pinia'
- import { GlobalState } from './interface/index'
- import { User_Dept_List, User_Post_List } from '@/api/user/index'
- export const GlobalStore = defineStore({
- id: 'GlobalState',
- state: (): GlobalState => ({
- loading: false,
- UserDeptList: [],
- UserPostList: [],
- User_tokey: localStorage.getItem('User_tokey') || ''
- }),
- getters: {
- GET_User_tokey: state => state.User_tokey,
- GET_Dept_List: state => state.UserDeptList
- },
- actions: {
- SET_User_Tokey(payload: string) {
- if (typeof payload === 'string') {
- this.User_tokey = payload
- }
- },
- async SET_User_Dept_List() {
- const res: any = await User_Dept_List()
- this.UserDeptList = res.Data
- },
- async SET_User_Post_List() {
- const res = await User_Post_List()
- console.log(res)
- }
- }
- })
- const pinia = createPinia()
- export default pinia
|