diff --git a/src/pages/login.vue b/src/pages/login.vue index a7e35551..2b0dfde4 100644 --- a/src/pages/login.vue +++ b/src/pages/login.vue @@ -161,6 +161,7 @@ function login() { const superuser = response.super_user const username = response.user_name const avatar = response.avatar + const level = response.level // 更新token和remember状态到Vuex Store store.dispatch('auth/updateToken', token) @@ -168,6 +169,7 @@ function login() { store.dispatch('auth/updateSuperUser', superuser) store.dispatch('auth/updateUserName', username) store.dispatch('auth/updateAvatar', avatar) + store.dispatch('auth/updateLevel', level) // 登录后处理 afterLogin(superuser) diff --git a/src/store/auth.ts b/src/store/auth.ts index 352c4ab0..c3ac35db 100644 --- a/src/store/auth.ts +++ b/src/store/auth.ts @@ -8,6 +8,7 @@ interface AuthState { userName: string avatar: string originalPath: string | null + level: number } // 定义根状态类型 @@ -25,6 +26,7 @@ const authModule: Module = { userName: '', avatar: '', originalPath: null, + level: 1, }, mutations: { setToken(state, token: string) { @@ -45,6 +47,12 @@ const authModule: Module = { setAvatar(state, avatar: string) { state.avatar = avatar }, + setOriginalPath(state, originalPath: string) { + state.originalPath = originalPath + }, + setLevel(state, level: number) { + state.level = level + }, }, actions: { updateToken({ commit }, token: string) { @@ -65,6 +73,12 @@ const authModule: Module = { updateAvatar({ commit }, avatar: string) { commit('setAvatar', avatar) }, + updateOriginalPath({ commit }, originalPath: string) { + commit('setOriginalPath', originalPath) + }, + updateLevel({ commit }, level: number) { + commit('setLevel', level) + }, }, getters: { getToken: state => state.token, @@ -72,6 +86,8 @@ const authModule: Module = { getSuperUser: state => state.superUser, getUserName: state => state.userName, getAvatar: state => state.avatar, + getOriginalPath: state => state.originalPath, + getLevel: state => state.level, }, } diff --git a/src/views/reorganize/FileBrowserView.vue b/src/views/reorganize/FileBrowserView.vue index 18865bbc..7f825333 100644 --- a/src/views/reorganize/FileBrowserView.vue +++ b/src/views/reorganize/FileBrowserView.vue @@ -2,6 +2,7 @@ import api from '@/api' import { FileItem, MediaDirectory } from '@/api/types' import FileBrowser from '@/components/FileBrowser.vue' +import store from '@/store' const endpoints = { list: { @@ -30,6 +31,11 @@ const endpoints = { }, } +const user_level = store.state.auth.level + +// 用户存储 +const userStorage = user_level > 1 ? 'local,aliyun,u115' : 'local' + // 当前目录 const path = ref('') @@ -112,7 +118,7 @@ onBeforeMount(loadDownloadDirectories)