mirror of
https://gitee.com/pnoker/iot-dc3.git
synced 2026-09-19 02:04:37 +08:00
fix: update Login view layout adjustments
This commit is contained in:
+11
-11
@@ -22,7 +22,7 @@
|
||||
"engines": {
|
||||
"node": ">=22.0.0"
|
||||
},
|
||||
"packageManager": "pnpm@11.1.3",
|
||||
"packageManager": "pnpm@11.2.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"prepare": "husky",
|
||||
@@ -66,7 +66,7 @@
|
||||
"js-cookie": "^3.0.7",
|
||||
"js-md5": "^0.8.3",
|
||||
"json-bigint": "^1.0.0",
|
||||
"marked": "^18.0.3",
|
||||
"marked": "^18.0.4",
|
||||
"mitt": "^3.0.1",
|
||||
"nprogress": "^0.2.0",
|
||||
"pinia": "^3.0.4",
|
||||
@@ -81,12 +81,12 @@
|
||||
"@tauri-apps/cli": "^2.11.2",
|
||||
"@types/js-cookie": "^3.0.6",
|
||||
"@types/json-bigint": "^1.0.4",
|
||||
"@types/node": "^25.9.0",
|
||||
"@types/node": "^25.9.1",
|
||||
"@types/nprogress": "^0.2.3",
|
||||
"@typescript-eslint/eslint-plugin": "^8.59.3",
|
||||
"@typescript-eslint/parser": "^8.59.3",
|
||||
"@typescript-eslint/eslint-plugin": "^8.59.4",
|
||||
"@typescript-eslint/parser": "^8.59.4",
|
||||
"@vitejs/plugin-vue": "^6.0.7",
|
||||
"@vitest/coverage-v8": "^4.1.6",
|
||||
"@vitest/coverage-v8": "^4.1.7",
|
||||
"@vue/eslint-config-typescript": "^14.7.0",
|
||||
"@vue/test-utils": "^2.4.10",
|
||||
"eslint": "^10.4.0",
|
||||
@@ -99,14 +99,14 @@
|
||||
"lint-staged": "^17.0.5",
|
||||
"playwright": "^1.60.0",
|
||||
"prettier": "^3.8.3",
|
||||
"sass": "^1.99.0",
|
||||
"sass": "^1.100.0",
|
||||
"typescript": "~6.0.3",
|
||||
"unplugin-auto-import": "^21.0.0",
|
||||
"unplugin-vue-components": "^32.0.0",
|
||||
"vite": "^8.0.13",
|
||||
"vitest": "^4.1.6",
|
||||
"unplugin-vue-components": "^32.1.0",
|
||||
"vite": "^8.0.14",
|
||||
"vitest": "^4.1.7",
|
||||
"vue-eslint-parser": "^10.4.0",
|
||||
"vue-tsc": "^3.3.0"
|
||||
"vue-tsc": "^3.3.1"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{vue,js,mjs,cjs,ts,jsx,tsx}": [
|
||||
|
||||
Generated
+359
-203
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
declare type R<T = any> = {
|
||||
ok: boolean;
|
||||
code: number;
|
||||
code: string;
|
||||
message: string;
|
||||
data: T;
|
||||
};
|
||||
|
||||
@@ -23,7 +23,9 @@ import commonRouters from './common';
|
||||
import operateRouters from './operate';
|
||||
import settingsRouters from './settings';
|
||||
import viewsRouters from './views';
|
||||
import { getStorage } from '@/utils/storageUtil';
|
||||
import { checkTokenValid } from '@/api/token';
|
||||
import type { Login } from '@/config/types';
|
||||
import { getStorage, removeStorage } from '@/utils/storageUtil';
|
||||
import { isNull } from '@/utils/validationUtil';
|
||||
import { AUTH_HEADERS } from '@/config/constant/common';
|
||||
|
||||
@@ -53,7 +55,7 @@ const router = createRouter({
|
||||
* Vue Router 4 deprecated the next() callback — we return the target
|
||||
* (or true/false) directly instead.
|
||||
*/
|
||||
router.beforeEach((to: RouteLocationNormalized) => {
|
||||
router.beforeEach(async (to: RouteLocationNormalized) => {
|
||||
NProgress.start();
|
||||
|
||||
// Skip authentication check for login page
|
||||
@@ -62,11 +64,33 @@ router.beforeEach((to: RouteLocationNormalized) => {
|
||||
}
|
||||
|
||||
// Check if user is authenticated locally
|
||||
const tenant = getStorage(AUTH_HEADERS.TENANT);
|
||||
const user = getStorage(AUTH_HEADERS.LOGIN);
|
||||
const token = getStorage(AUTH_HEADERS.TOKEN);
|
||||
const tenant = getStorage(AUTH_HEADERS.TENANT) as string | undefined;
|
||||
const user = getStorage(AUTH_HEADERS.LOGIN) as string | undefined;
|
||||
const tokenData = getStorage(AUTH_HEADERS.TOKEN) as { salt?: string; token?: string } | undefined;
|
||||
|
||||
if (isNull(tenant) || isNull(user) || isNull(token)) {
|
||||
if (isNull(tenant) || isNull(user) || isNull(tokenData)) {
|
||||
return { name: 'login' };
|
||||
}
|
||||
|
||||
// Validate token with server
|
||||
try {
|
||||
const login: Login = {
|
||||
tenant,
|
||||
name: user,
|
||||
salt: tokenData!.salt,
|
||||
token: tokenData!.token,
|
||||
};
|
||||
const validRes = await checkTokenValid(login);
|
||||
if (!validRes?.data) {
|
||||
removeStorage(AUTH_HEADERS.TENANT);
|
||||
removeStorage(AUTH_HEADERS.LOGIN);
|
||||
removeStorage(AUTH_HEADERS.TOKEN);
|
||||
return { name: 'login' };
|
||||
}
|
||||
} catch {
|
||||
removeStorage(AUTH_HEADERS.TENANT);
|
||||
removeStorage(AUTH_HEADERS.LOGIN);
|
||||
removeStorage(AUTH_HEADERS.TOKEN);
|
||||
return { name: 'login' };
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,12 @@ import { seedAuthStorage } from '../fixtures/auth';
|
||||
// We replace the heavy real route configs with stub records so the router
|
||||
// can be instantiated in jsdom without dragging in the entire view tree.
|
||||
|
||||
const tokenMocks = vi.hoisted(() => ({
|
||||
checkTokenValid: vi.fn(() => Promise.resolve({ data: true })),
|
||||
}));
|
||||
|
||||
vi.mock('@/api/token', () => tokenMocks);
|
||||
|
||||
const routeStubs = vi.hoisted(() => {
|
||||
const stubComponent = { render: () => null };
|
||||
const common: RouteRecordRaw[] = [
|
||||
|
||||
Reference in New Issue
Block a user