mirror of
https://github.com/jekip/naive-ui-admin.git
synced 2026-02-04 13:42:27 +08:00
pre: 代码优化
This commit is contained in:
@@ -1,10 +1,8 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { createStorage } from '@/utils/Storage';
|
|
||||||
import { store } from '@/store';
|
import { store } from '@/store';
|
||||||
import { ACCESS_TOKEN, CURRENT_USER, IS_LOCKSCREEN } from '@/store/mutation-types';
|
import { ACCESS_TOKEN, CURRENT_USER, IS_LOCKSCREEN } from '@/store/mutation-types';
|
||||||
import { ResultEnum } from '@/enums/httpEnum';
|
import { ResultEnum } from '@/enums/httpEnum';
|
||||||
|
|
||||||
const Storage = createStorage({ storage: localStorage });
|
|
||||||
import { getUserInfo, login } from '@/api/system/user';
|
import { getUserInfo, login } from '@/api/system/user';
|
||||||
import { storage } from '@/utils/Storage';
|
import { storage } from '@/utils/Storage';
|
||||||
|
|
||||||
@@ -20,12 +18,12 @@ export interface IUserState {
|
|||||||
export const useUserStore = defineStore({
|
export const useUserStore = defineStore({
|
||||||
id: 'app-user',
|
id: 'app-user',
|
||||||
state: (): IUserState => ({
|
state: (): IUserState => ({
|
||||||
token: Storage.get(ACCESS_TOKEN, ''),
|
token: storage.get(ACCESS_TOKEN, ''),
|
||||||
username: '',
|
username: '',
|
||||||
welcome: '',
|
welcome: '',
|
||||||
avatar: '',
|
avatar: '',
|
||||||
permissions: [],
|
permissions: [],
|
||||||
info: Storage.get(CURRENT_USER, {}),
|
info: storage.get(CURRENT_USER, {}),
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getToken(): string {
|
getToken(): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user