Merge branch 'lichang' into lite
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { getSysConf } from '@/api';
|
||||
import { CACHE_LOCAL_I18N, CACHE_SESSION_CRYPTO_API } from '@/constants/cache-keys-constants';
|
||||
import {
|
||||
CACHE_LOCAL_I18N,
|
||||
CACHE_SESSION_CRYPTO_API,
|
||||
} from '@/constants/cache-keys-constants';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
// import { removeToken } from '@/plugins/auth-token';
|
||||
import { parseUrlPath } from '@/plugins/file-static-url';
|
||||
import { localGet, localSet } from '@/utils/cache-local-utils';
|
||||
import { sessionSet } from '@/utils/cache-session-utils';
|
||||
@@ -16,11 +18,12 @@ type AppStore = {
|
||||
/**应用版本 */
|
||||
appVersion: string;
|
||||
|
||||
/**服务版本 */
|
||||
/**版本号 */
|
||||
version: string;
|
||||
// buildTime: string;
|
||||
/**系统引导使用 */
|
||||
// bootloader: boolean;
|
||||
/**服务版本 */
|
||||
serverVersion: string;
|
||||
// 用户登录认证
|
||||
loginAuth: boolean;
|
||||
// 用户接口加密
|
||||
@@ -54,13 +57,13 @@ const useAppStore = defineStore('app', {
|
||||
appCode: import.meta.env.VITE_APP_CODE,
|
||||
appVersion: import.meta.env.VITE_APP_VERSION,
|
||||
|
||||
version: `-`,
|
||||
// buildTime: `-`,
|
||||
version: '-',
|
||||
// bootloader: false,
|
||||
serverVersion: '-',
|
||||
loginAuth: true,
|
||||
cryptoApi: true,
|
||||
serialNum: `-`,
|
||||
copyright: `Copyright ©2023 For ${import.meta.env.VITE_APP_NAME}`,
|
||||
serialNum: '-',
|
||||
copyright: `Copyright ©2023-2025 For ${import.meta.env.VITE_APP_NAME}`,
|
||||
logoType: 'icon',
|
||||
filePathIcon: '',
|
||||
filePathBrand: '',
|
||||
@@ -86,15 +89,16 @@ const useAppStore = defineStore('app', {
|
||||
const res = await getSysConf();
|
||||
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
||||
this.version = res.data.version;
|
||||
// this.buildTime = res.data.buildTime;
|
||||
this.serverVersion = res.data.serverVersion;
|
||||
// this.bootloader = res.data.bootloader === 'true';
|
||||
// // 引导时
|
||||
// if (this.bootloader) {
|
||||
// removeToken();
|
||||
// delAccessToken();
|
||||
// delRefreshToken();
|
||||
// }
|
||||
this.loginAuth = res.data.loginAuth !== 'false';
|
||||
this.cryptoApi = res.data.cryptoApi !== 'false';
|
||||
sessionSet(CACHE_SESSION_CRYPTO_API, res.data.cryptoApi);
|
||||
sessionSet(CACHE_SESSION_CRYPTO_API, res.data.cryptoApi);
|
||||
this.serialNum = res.data.serialNum;
|
||||
this.appName = res.data.title;
|
||||
this.copyright = res.data.copyright;
|
||||
|
||||
@@ -20,7 +20,7 @@ type MaskStateType = {
|
||||
const useMaskStore = defineStore('mask', {
|
||||
state: (): MaskStateType => ({
|
||||
type: (localGet(CACHE_LOCAL_MASK) || 'none') as MaskStateType['type'],
|
||||
lockPasswd: localGet(CACHE_LOCAL_LOCK_PASSWD) || '',
|
||||
lockPasswd: atob(localGet(CACHE_LOCAL_LOCK_PASSWD) || ''),
|
||||
lockTimeout: 0,
|
||||
}),
|
||||
getters: {},
|
||||
@@ -59,7 +59,7 @@ const useMaskStore = defineStore('mask', {
|
||||
}, 5_000);
|
||||
}
|
||||
if (type === 'lock') {
|
||||
localSet(CACHE_LOCAL_LOCK_PASSWD, this.lockPasswd);
|
||||
localSet(CACHE_LOCAL_LOCK_PASSWD, btoa(this.lockPasswd));
|
||||
} else {
|
||||
localRemove(CACHE_LOCAL_LOCK_PASSWD);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { defineStore } from 'pinia';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { listAllNeInfo } from '@/api/ne/neInfo';
|
||||
import { parseDataToOptions } from '@/utils/parse-tree-utils';
|
||||
import { getNeTraceInterfaceAll } from '@/api/trace/task';
|
||||
import { getNePerformanceList } from '@/api/perfManage/taskManage';
|
||||
|
||||
/**网元信息类型 */
|
||||
@@ -13,8 +12,6 @@ type NeInfo = {
|
||||
neCascaderOptions: Record<string, any>[];
|
||||
/**选择器单级父类型 */
|
||||
neSelectOtions: Record<string, any>[];
|
||||
/**跟踪接口列表 */
|
||||
traceInterfaceList: Record<string, any>[];
|
||||
/**性能测量数据集 */
|
||||
perMeasurementList: Record<string, any>[];
|
||||
};
|
||||
@@ -24,7 +21,6 @@ const useNeInfoStore = defineStore('neinfo', {
|
||||
neList: [],
|
||||
neCascaderOptions: [],
|
||||
neSelectOtions: [],
|
||||
traceInterfaceList: [],
|
||||
perMeasurementList: [],
|
||||
}),
|
||||
getters: {
|
||||
@@ -56,7 +52,7 @@ const useNeInfoStore = defineStore('neinfo', {
|
||||
async fnNelist() {
|
||||
// 有数据不请求
|
||||
if (this.neList.length > 0) {
|
||||
return { code: 1, data: this.neList, msg: 'success' };
|
||||
return { code: RESULT_CODE_SUCCESS, data: this.neList, msg: 'success' };
|
||||
}
|
||||
const res = await listAllNeInfo({
|
||||
bandStatus: false,
|
||||
@@ -79,29 +75,11 @@ const useNeInfoStore = defineStore('neinfo', {
|
||||
}
|
||||
return res;
|
||||
},
|
||||
// 刷新跟踪接口列表
|
||||
async fnRefreshNeTraceInterface() {
|
||||
this.traceInterfaceList = [];
|
||||
const res = await this.fnNeTraceInterface();
|
||||
return res;
|
||||
},
|
||||
// 获取跟踪接口列表
|
||||
async fnNeTraceInterface() {
|
||||
// 有数据不请求
|
||||
if (this.traceInterfaceList.length > 0) {
|
||||
return { code: 1, data: this.traceInterfaceList, msg: 'success' };
|
||||
}
|
||||
const res = await getNeTraceInterfaceAll();
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
this.traceInterfaceList = res.data;
|
||||
}
|
||||
return res;
|
||||
},
|
||||
// 获取性能测量数据集列表
|
||||
async fnNeTaskPerformance() {
|
||||
// 有数据不请求
|
||||
if (this.perMeasurementList.length > 0) {
|
||||
return { code: 1, data: this.perMeasurementList, msg: 'success' };
|
||||
return { code: RESULT_CODE_SUCCESS, data: this.perMeasurementList, msg: 'success' };
|
||||
}
|
||||
const res = await getNePerformanceList();
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import type {
|
||||
RouteMeta,
|
||||
RouteRecordRaw,
|
||||
} from 'vue-router';
|
||||
import { getRouters } from '@/api/router';
|
||||
import { getRouter } from '@/api/auth';
|
||||
import BasicLayout from '@/layouts/BasicLayout.vue';
|
||||
import BlankLayout from '@/layouts/BlankLayout.vue';
|
||||
import LinkLayout from '@/layouts/LinkLayout.vue';
|
||||
@@ -46,7 +46,7 @@ const useRouterStore = defineStore('router', {
|
||||
* @returns 生成的路由菜单
|
||||
*/
|
||||
async generateRoutes() {
|
||||
const res = await getRouters();
|
||||
const res = await getRouter();
|
||||
if (res.code === RESULT_CODE_SUCCESS) {
|
||||
const buildRoutes = buildRouters(res.data.concat());
|
||||
this.buildRouterData = buildRoutes;
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
import defaultAvatar from '@/assets/images/default_avatar.png';
|
||||
import useLayoutStore from './layout';
|
||||
import { login, logout, getInfo } from '@/api/login';
|
||||
import { setToken, removeToken } from '@/plugins/auth-token';
|
||||
import { login, logout, getInfo } from '@/api/auth';
|
||||
import {
|
||||
delAccessToken,
|
||||
delRefreshToken,
|
||||
setAccessToken,
|
||||
setRefreshToken,
|
||||
} from '@/plugins/auth-token';
|
||||
import { defineStore } from 'pinia';
|
||||
import { TOKEN_RESPONSE_FIELD } from '@/constants/token-constants';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { RESULT_CODE_EXCEPTION, RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { parseUrlPath } from '@/plugins/file-static-url';
|
||||
|
||||
/**用户信息类型 */
|
||||
type UserInfo = {
|
||||
/**用户ID */
|
||||
forcePasswdChange: boolean;
|
||||
/**用户ID */
|
||||
userId: string;
|
||||
/**登录账号 */
|
||||
@@ -33,6 +39,7 @@ type UserInfo = {
|
||||
|
||||
const useUserStore = defineStore('user', {
|
||||
state: (): UserInfo => ({
|
||||
forcePasswdChange: false,
|
||||
userId: '',
|
||||
userName: '',
|
||||
roles: [],
|
||||
@@ -102,8 +109,11 @@ const useUserStore = defineStore('user', {
|
||||
async fnLogin(loginBody: Record<string, string>) {
|
||||
const res = await login(loginBody);
|
||||
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
||||
const token = res.data[TOKEN_RESPONSE_FIELD];
|
||||
setToken(token);
|
||||
setAccessToken(res.data.accessToken, res.data.refreshExpiresIn);
|
||||
setRefreshToken(res.data.refreshToken, res.data.refreshExpiresIn);
|
||||
if (res.data?.forcePasswdChange) {
|
||||
this.forcePasswdChange = true;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
},
|
||||
@@ -139,10 +149,15 @@ const useUserStore = defineStore('user', {
|
||||
// }
|
||||
// useLayoutStore().changeWaterMark(waterMarkContent);
|
||||
useLayoutStore().changeWaterMark('');
|
||||
// 强制修改密码
|
||||
if (res.data?.forcePasswdChange) {
|
||||
this.forcePasswdChange = true;
|
||||
}
|
||||
}
|
||||
// 网络错误时退出登录状态
|
||||
if (res.code === 0) {
|
||||
removeToken();
|
||||
if (res.code === RESULT_CODE_EXCEPTION) {
|
||||
delAccessToken();
|
||||
delRefreshToken();
|
||||
window.location.reload();
|
||||
}
|
||||
return res;
|
||||
@@ -156,7 +171,8 @@ const useUserStore = defineStore('user', {
|
||||
} finally {
|
||||
this.roles = [];
|
||||
this.permissions = [];
|
||||
removeToken();
|
||||
delAccessToken();
|
||||
delRefreshToken();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user