feat: 新增首页组件及功能

This commit is contained in:
zhanghao 2026-08-25 14:03:07 +08:00
parent 0286064415
commit 69e99d849e
9 changed files with 1112 additions and 12 deletions

View File

@ -18,19 +18,25 @@ const isExt = computed(() => {
return isExternal(props.to) return isExternal(props.to)
}) })
const isNewWindowRoute = computed(() => {
const path = typeof props.to === 'string' ? props.to : props.to?.path
return path === '/inspection/cockpit'
})
const type = computed(() => { const type = computed(() => {
if (isExt.value) { if (isExt.value || isNewWindowRoute.value) {
return 'a' return 'a'
} }
return 'router-link' return 'router-link'
}) })
function linkProps() { function linkProps() {
if (isExt.value) { if (isExt.value || isNewWindowRoute.value) {
const href = typeof props.to === 'string' ? props.to : props.to?.path
return { return {
href: props.to, href,
target: '_blank', target: '_blank',
rel: 'noopener' rel: 'noopener noreferrer'
} }
} }
return { return {

View File

@ -120,9 +120,9 @@ function setVisibleNumber() {
function handleSelect(key, keyPath) { function handleSelect(key, keyPath) {
currentIndex.value = key currentIndex.value = key
const route = routers.value.find(item => item.path === key) const route = routers.value.find(item => item.path === key)
if (isHttp(key)) { if (isHttp(key) || key === '/inspection/cockpit') {
// http(s):// 路径新窗口打开 // http(s):// 路径新窗口打开
window.open(key, "_blank") window.open(key, '_blank', 'noopener,noreferrer')
} else if (!route || !route.children) { } else if (!route || !route.children) {
// 没有子路由路径内部打开 // 没有子路由路径内部打开
const routeMenu = childrenMenus.value.find(item => item.path === key) const routeMenu = childrenMenus.value.find(item => item.path === key)

View File

@ -19,11 +19,12 @@ const isWhiteList = (path) => {
} }
router.beforeEach(async (to, from) => { router.beforeEach(async (to, from) => {
if (to.meta?.noLogin) { const token = getToken()
if (to.meta?.noLogin && !token) {
return true return true
} }
NProgress.start() NProgress.start()
if (getToken()) { if (token) {
to.meta.title && useSettingsStore().setTitle(to.meta.title) to.meta.title && useSettingsStore().setTitle(to.meta.title)
const isLock = useLockStore().isLock const isLock = useLockStore().isLock
if (to.path === '/login') { if (to.path === '/login') {

View File

@ -15,9 +15,14 @@ export const constantRoutes = [
{ path: '/401', component: commonView('error/401'), hidden: true }, { path: '/401', component: commonView('error/401'), hidden: true },
{ path: '/:pathMatch(.*)*', component: commonView('error/404'), hidden: true }, { path: '/:pathMatch(.*)*', component: commonView('error/404'), hidden: true },
{ {
path: '/', component: Layout, redirect: '/inspection/cockpit', path: '/', component: Layout, redirect: '/index',
children: [{ path: '/inspection/cockpit', component: () => import('@/views/inspection/cockpit/index.vue'), name: 'InspectionCockpit', meta: { title: '巡检驾驶舱', noLogin: true } }] children: [{ path: 'index', component: () => import('@/views/index.vue'), name: 'Index', meta: { title: '首页', icon: 'dashboard', affix: true } }]
}, },
{
path: '/inspection/cockpit', component: () => import('@/views/inspection/cockpit/index.vue'), name: 'InspectionCockpit',
meta: { title: '巡检驾驶舱', noLogin: true }
},
{ path: '/flow', component: commonView('flow/index'), hidden: true, meta: { title: '流程编排', noLogin: true } },
{ path: '/lock', component: () => import('@/views/lock'), hidden: true }, { path: '/lock', component: () => import('@/views/lock'), hidden: true },
{ {
path: '/user', component: Layout, hidden: true, redirect: 'noredirect', path: '/user', component: Layout, hidden: true, redirect: 'noredirect',

View File

@ -1,4 +1,4 @@
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min' import JSEncrypt from 'jsencrypt'
// 密钥对生成 http://web.chacuo.net/netrsakeypair // 密钥对生成 http://web.chacuo.net/netrsakeypair

1070
src/views/index.vue Normal file

File diff suppressed because it is too large Load Diff

View File

@ -406,7 +406,7 @@ function handleDelete(row) {
function handleDeploy(row) { function handleDeploy(row) {
const params = { itemId: row.detectItemId, name: row.waypointName, state: row.status }; const params = { itemId: row.detectItemId, name: row.waypointName, state: row.status };
const fullPath = appendParamsToPath("/flow", params); const fullPath = appendParamsToPath("/flow", params);
const p = window.open(fullPath, "_blank"); window.open(fullPath, "_blank", "noopener,noreferrer");
} }

View File

@ -1,7 +1,18 @@
import { defineConfig, loadEnv, normalizePath } from 'vite' import { defineConfig, loadEnv, normalizePath } from 'vite'
import path from 'path' import path from 'path'
import { realpathSync } from 'node:fs'
import createVitePlugins from './vite/plugins' 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/ // https://vitejs.dev/config/
export default defineConfig(({ mode, command }) => { export default defineConfig(({ mode, command }) => {
const env = loadEnv(mode, process.cwd()) const env = loadEnv(mode, process.cwd())
@ -12,6 +23,7 @@ export default defineConfig(({ mode, command }) => {
plugins: createVitePlugins(env, command === 'build'), plugins: createVitePlugins(env, command === 'build'),
optimizeDeps: { optimizeDeps: {
exclude: [ exclude: [
...(isCommonLinked ? ['@cmvr/iot-common'] : []),
'monaco-editor', 'monaco-editor',
'monaco-editor/esm/vs/base/worker/workerMain.js', 'monaco-editor/esm/vs/base/worker/workerMain.js',
'monaco-editor/esm/vs/editor/editor.main.js', 'monaco-editor/esm/vs/editor/editor.main.js',
@ -57,6 +69,11 @@ export default defineConfig(({ mode, command }) => {
port: Number(VITE_PORT || 80), port: Number(VITE_PORT || 80),
host: true, host: true,
open: true, open: true,
...(isCommonLinked ? {
watch: {
ignored: ['!**/node_modules/@cmvr/iot-common/**']
}
} : {}),
proxy: { proxy: {
// https://cn.vitejs.dev/config/#server-proxy // https://cn.vitejs.dev/config/#server-proxy
'/dev-api': { '/dev-api': {

View File

@ -11,6 +11,7 @@ export default function createAutoImport() {
'@/utils/ruoyi': ['selectDictLabel'] '@/utils/ruoyi': ['selectDictLabel']
} }
], ],
exclude: [/[\\/]cmvr-iot-common[\\/]dist[\\/]/],
dts: false dts: false
}) })
} }