From a74ef03d1964b9decdcf97da9614fdbdeaa07a7e Mon Sep 17 00:00:00 2001 From: zhanghao <774378400@qq.com> Date: Tue, 25 Aug 2026 14:24:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E6=9D=83=E9=99=90?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=92=8C=E9=A6=96=E9=A1=B5=E5=B8=83=E5=B1=80?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E5=8A=A0=E5=AF=86=E5=BA=93=E5=BC=95?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/permission.js | 5 +- src/router/index.js | 5 +- src/utils/jsencrypt.js | 2 +- src/views/index.vue | 1065 +++++++++++++++++ src/views/intelligenceTest/testCase/index.vue | 2 +- vite.config.js | 17 + vite/plugins/auto-import.js | 1 + 7 files changed, 1091 insertions(+), 6 deletions(-) create mode 100644 src/views/index.vue diff --git a/src/permission.js b/src/permission.js index 5e08a49..3ea5cc7 100644 --- a/src/permission.js +++ b/src/permission.js @@ -19,11 +19,12 @@ const isWhiteList = (path) => { } router.beforeEach(async (to, from) => { - if (to.meta?.noLogin) { + const token = getToken() + if (to.meta?.noLogin && !token) { return true } NProgress.start() - if (getToken()) { + if (token) { to.meta.title && useSettingsStore().setTitle(to.meta.title) const isLock = useLockStore().isLock if (to.path === '/login') { diff --git a/src/router/index.js b/src/router/index.js index 9ad53dc..fc0f854 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -15,9 +15,10 @@ export const constantRoutes = [ { path: '/401', component: commonView('error/401'), hidden: true }, { path: '/:pathMatch(.*)*', component: commonView('error/404'), hidden: true }, { - path: '/', component: Layout, redirect: '/intelligenceTest/taskManage', - children: [{ path: '/intelligenceTest/taskManage', component: () => import('@/views/intelligenceTest/taskManage/index.vue'), name: 'IntelligenceTaskManage', meta: { title: '智能测试任务', noLogin: true } }] + path: '/', component: Layout, redirect: '/index', + children: [{ path: 'index', component: () => import('@/views/index.vue'), name: 'Index', meta: { title: '首页', icon: 'dashboard', affix: true } }] }, + { path: '/flow', component: commonView('flow/index'), hidden: true, meta: { title: '流程编排', noLogin: true } }, { path: '/lock', component: () => import('@/views/lock'), hidden: true }, { path: '/user', component: Layout, hidden: true, redirect: 'noredirect', diff --git a/src/utils/jsencrypt.js b/src/utils/jsencrypt.js index 78d9523..91eeff6 100644 --- a/src/utils/jsencrypt.js +++ b/src/utils/jsencrypt.js @@ -1,4 +1,4 @@ -import JSEncrypt from 'jsencrypt/bin/jsencrypt.min' +import JSEncrypt from 'jsencrypt' // 密钥对生成 http://web.chacuo.net/netrsakeypair diff --git a/src/views/index.vue b/src/views/index.vue new file mode 100644 index 0000000..3832394 --- /dev/null +++ b/src/views/index.vue @@ -0,0 +1,1065 @@ + + + + + diff --git a/src/views/intelligenceTest/testCase/index.vue b/src/views/intelligenceTest/testCase/index.vue index 0c6cc25..18ae753 100644 --- a/src/views/intelligenceTest/testCase/index.vue +++ b/src/views/intelligenceTest/testCase/index.vue @@ -337,7 +337,7 @@ function cancel() { function handleDeploy(row) { const params = { itemId: row.detectItemId, name: row.caseName, state: row.status }; const fullPath = appendParamsToPath("/flow", params); - const p = window.open(fullPath, "_blank"); + window.open(fullPath, "_blank", "noopener,noreferrer"); } getList(); diff --git a/vite.config.js b/vite.config.js index 39bc171..678a256 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,7 +1,18 @@ import { defineConfig, loadEnv, normalizePath } from 'vite' import path from 'path' +import { realpathSync } from 'node:fs' import createVitePlugins from './vite/plugins' +const isCommonLinked = (() => { + try { + const linkedPath = realpathSync(path.resolve('node_modules/@cmvr/iot-common')) + const localPath = realpathSync(path.resolve('../cmvr-iot-common')) + return path.relative(linkedPath, localPath) === '' + } catch { + return false + } +})() + // https://vitejs.dev/config/ export default defineConfig(({ mode, command }) => { const env = loadEnv(mode, process.cwd()) @@ -12,6 +23,7 @@ export default defineConfig(({ mode, command }) => { plugins: createVitePlugins(env, command === 'build'), optimizeDeps: { exclude: [ + ...(isCommonLinked ? ['@cmvr/iot-common'] : []), 'monaco-editor', 'monaco-editor/esm/vs/base/worker/workerMain.js', 'monaco-editor/esm/vs/editor/editor.main.js', @@ -57,6 +69,11 @@ export default defineConfig(({ mode, command }) => { port: Number(VITE_PORT || 80), host: true, open: true, + ...(isCommonLinked ? { + watch: { + ignored: ['!**/node_modules/@cmvr/iot-common/**'] + } + } : {}), proxy: { // https://cn.vitejs.dev/config/#server-proxy '/dev-api': { diff --git a/vite/plugins/auto-import.js b/vite/plugins/auto-import.js index 1b6ab1d..723d4dc 100644 --- a/vite/plugins/auto-import.js +++ b/vite/plugins/auto-import.js @@ -11,6 +11,7 @@ export default function createAutoImport() { '@/utils/ruoyi': ['selectDictLabel'] } ], + exclude: [/[\\/]cmvr-iot-common[\\/]dist[\\/]/], dts: false }) }