diff --git a/frontend/src/App.vue b/frontend/src/App.vue index ff44e59..c048298 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -1,54 +1,6 @@ diff --git a/frontend/src/api/http.ts b/frontend/src/api/http.ts index 0784a2c..8f85d72 100644 --- a/frontend/src/api/http.ts +++ b/frontend/src/api/http.ts @@ -1,7 +1,7 @@ import axios from 'axios' export const http = axios.create({ - baseURL: 'http://127.0.0.1:8000/api', + baseURL: '/api', timeout: 5000, headers: { 'Content-Type': 'application/json', diff --git a/frontend/src/assets/images/dashboard/bg.png b/frontend/src/assets/images/dashboard/bg.png new file mode 100644 index 0000000..19f1e77 Binary files /dev/null and b/frontend/src/assets/images/dashboard/bg.png differ diff --git a/frontend/src/assets/images/dashboard/logo.svg b/frontend/src/assets/images/dashboard/logo.svg new file mode 100644 index 0000000..2421465 --- /dev/null +++ b/frontend/src/assets/images/dashboard/logo.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/assets/images/menuicon/1-1.png b/frontend/src/assets/images/menuicon/1-1.png new file mode 100644 index 0000000..f0ff552 Binary files /dev/null and b/frontend/src/assets/images/menuicon/1-1.png differ diff --git a/frontend/src/assets/images/menuicon/1.png b/frontend/src/assets/images/menuicon/1.png new file mode 100644 index 0000000..ce55b3f Binary files /dev/null and b/frontend/src/assets/images/menuicon/1.png differ diff --git a/frontend/src/assets/images/menuicon/2-1.png b/frontend/src/assets/images/menuicon/2-1.png new file mode 100644 index 0000000..bfdb8e3 Binary files /dev/null and b/frontend/src/assets/images/menuicon/2-1.png differ diff --git a/frontend/src/assets/images/menuicon/2.png b/frontend/src/assets/images/menuicon/2.png new file mode 100644 index 0000000..ebab0b1 Binary files /dev/null and b/frontend/src/assets/images/menuicon/2.png differ diff --git a/frontend/src/assets/images/menuicon/3-1.png b/frontend/src/assets/images/menuicon/3-1.png new file mode 100644 index 0000000..300e21e Binary files /dev/null and b/frontend/src/assets/images/menuicon/3-1.png differ diff --git a/frontend/src/assets/images/menuicon/3.png b/frontend/src/assets/images/menuicon/3.png new file mode 100644 index 0000000..ed8f3e9 Binary files /dev/null and b/frontend/src/assets/images/menuicon/3.png differ diff --git a/frontend/src/assets/images/menuicon/4-1.png b/frontend/src/assets/images/menuicon/4-1.png new file mode 100644 index 0000000..f6a9f52 Binary files /dev/null and b/frontend/src/assets/images/menuicon/4-1.png differ diff --git a/frontend/src/assets/images/menuicon/4.png b/frontend/src/assets/images/menuicon/4.png new file mode 100644 index 0000000..72f97c3 Binary files /dev/null and b/frontend/src/assets/images/menuicon/4.png differ diff --git a/frontend/src/assets/images/menuicon/5-1.png b/frontend/src/assets/images/menuicon/5-1.png new file mode 100644 index 0000000..09cf0d2 Binary files /dev/null and b/frontend/src/assets/images/menuicon/5-1.png differ diff --git a/frontend/src/assets/images/menuicon/5.png b/frontend/src/assets/images/menuicon/5.png new file mode 100644 index 0000000..ad7116e Binary files /dev/null and b/frontend/src/assets/images/menuicon/5.png differ diff --git a/frontend/src/assets/images/menuicon/6-1.png b/frontend/src/assets/images/menuicon/6-1.png new file mode 100644 index 0000000..d71a255 Binary files /dev/null and b/frontend/src/assets/images/menuicon/6-1.png differ diff --git a/frontend/src/assets/images/menuicon/6.png b/frontend/src/assets/images/menuicon/6.png new file mode 100644 index 0000000..ebd773c Binary files /dev/null and b/frontend/src/assets/images/menuicon/6.png differ diff --git a/frontend/src/assets/images/menuicon/7-1.png b/frontend/src/assets/images/menuicon/7-1.png new file mode 100644 index 0000000..762bbef Binary files /dev/null and b/frontend/src/assets/images/menuicon/7-1.png differ diff --git a/frontend/src/assets/images/menuicon/7.png b/frontend/src/assets/images/menuicon/7.png new file mode 100644 index 0000000..22199ef Binary files /dev/null and b/frontend/src/assets/images/menuicon/7.png differ diff --git a/frontend/src/assets/images/menuicon/bb.svg b/frontend/src/assets/images/menuicon/bb.svg new file mode 100644 index 0000000..0bd9671 --- /dev/null +++ b/frontend/src/assets/images/menuicon/bb.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/assets/images/menuicon/lb.png b/frontend/src/assets/images/menuicon/lb.png new file mode 100644 index 0000000..e268f26 Binary files /dev/null and b/frontend/src/assets/images/menuicon/lb.png differ diff --git a/frontend/src/assets/images/menuicon/noitem.png b/frontend/src/assets/images/menuicon/noitem.png new file mode 100644 index 0000000..45786a8 Binary files /dev/null and b/frontend/src/assets/images/menuicon/noitem.png differ diff --git a/frontend/src/assets/images/menuicon/off.png b/frontend/src/assets/images/menuicon/off.png new file mode 100644 index 0000000..341a5fa Binary files /dev/null and b/frontend/src/assets/images/menuicon/off.png differ diff --git a/frontend/src/assets/images/menuicon/off2.png b/frontend/src/assets/images/menuicon/off2.png new file mode 100644 index 0000000..35064ae Binary files /dev/null and b/frontend/src/assets/images/menuicon/off2.png differ diff --git a/frontend/src/assets/images/menuicon/on.png b/frontend/src/assets/images/menuicon/on.png new file mode 100644 index 0000000..cd5aaed Binary files /dev/null and b/frontend/src/assets/images/menuicon/on.png differ diff --git a/frontend/src/assets/images/menuicon/on2.png b/frontend/src/assets/images/menuicon/on2.png new file mode 100644 index 0000000..dfc99a1 Binary files /dev/null and b/frontend/src/assets/images/menuicon/on2.png differ diff --git a/frontend/src/assets/images/menuicon/u699.png b/frontend/src/assets/images/menuicon/u699.png new file mode 100644 index 0000000..8003efe Binary files /dev/null and b/frontend/src/assets/images/menuicon/u699.png differ diff --git a/frontend/src/assets/images/menuicon/yj.svg b/frontend/src/assets/images/menuicon/yj.svg new file mode 100644 index 0000000..6d74c5d --- /dev/null +++ b/frontend/src/assets/images/menuicon/yj.svg @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/frontend/src/layout/AppLayout.vue b/frontend/src/layout/AppLayout.vue new file mode 100644 index 0000000..90f62db --- /dev/null +++ b/frontend/src/layout/AppLayout.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/frontend/src/layout/components/header.vue b/frontend/src/layout/components/header.vue new file mode 100644 index 0000000..224027a --- /dev/null +++ b/frontend/src/layout/components/header.vue @@ -0,0 +1,147 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/layout/components/sidebar.vue b/frontend/src/layout/components/sidebar.vue new file mode 100644 index 0000000..1c56339 --- /dev/null +++ b/frontend/src/layout/components/sidebar.vue @@ -0,0 +1,275 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/main.ts b/frontend/src/main.ts index fe5bae3..1facfad 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -1,5 +1,14 @@ import { createApp } from 'vue' import App from './App.vue' +import router from './routes' +import ElementPlus from 'element-plus' +import zhCn from 'element-plus/es/locale/lang/zh-cn' +import 'element-plus/dist/index.css' import './style.css' +const app = createApp(App) -createApp(App).mount('#app') +app.use(router) +app.use(ElementPlus as any, { + locale: zhCn, +}) +app.mount('#app') diff --git a/frontend/src/routes/index.ts b/frontend/src/routes/index.ts new file mode 100644 index 0000000..93c3832 --- /dev/null +++ b/frontend/src/routes/index.ts @@ -0,0 +1,252 @@ +import { + createRouter, + createWebHistory, + type RouteRecordRaw, +} from "vue-router" + +/** + * 路由元信息类型 + */ +declare module "vue-router" { + interface RouteMeta { + title?: string + requiresAuth?: boolean + hidden?: boolean + keepAlive?: boolean + icon?: string + } +} + +/** + * 路由表 + */ +// src/routes/index.ts +const routes: RouteRecordRaw[] = [ + // { + // path: "/login", + // name: "Login", + // component: () => import("@/views/login/index.vue"), + // meta: { + // title: "登录", + // hidden: true, + // }, + // }, + { + path: "/dashboard", + name: "Dashboard", + component: () => import("@/views/dashboard/index.vue"), + meta: { + title: "系统总览", + requiresAuth: false, + icon: "dashboard", + keepAlive: true, + }, + }, + { + path: "/", + component: () => import("@/layout/AppLayout.vue"), + meta: { + requiresAuth: false, + }, + children: [ + { + path: "", + redirect: "/dashboard", + }, + { + path: "analogQuantity", + name: "AnalogQuantity", + component: () => import("@/views/analogQuantity/index.vue"), + meta: { + title: "模拟量", + }, + }, + { + path: "switchQuantity", + name: "SwitchQuantity", + component: () => import("@/views/switchQuantity/index.vue"), + meta: { + title: "开关量", + }, + }, + { + path: "aiQuantity", + name: "AiQuantity", + component: () => import("@/views/aiQuantity/index.vue"), + meta: { + title: "AI采集", + }, + }, + { + path: "eventReport", + name: "EventReport", + component: () => import("@/views/eventReport/index.vue"), + meta: { + title: "事件报告", + }, + }, + { + path: "communicationSetting", + name: "CommunicationSetting", + component: () => import("@/views/communicationSetting/index.vue"), + meta: { + title: "通信设置", + }, + }, + { + path: "aiChannelSetting", + name: "AiChannelSetting", + component: () => import("@/views/aiChannelSetting/index.vue"), + meta: { + title: "AI通道设置", + }, + }, + { + path: "aoChannelSetting", + name: "AoChannelSetting", + component: () => import("@/views/aoChannelSetting/index.vue"), + meta: { + title: "AO通道设置", + }, + }, + { + path: "timeSetting", + name: "TimeSetting", + component: () => import("@/views/timeSetting/index.vue"), + meta: { + title: "对时设置", + }, + }, + { + path: "passwordSetting", + name: "PasswordSetting", + component: () => import("@/views/passwordSetting/index.vue"), + meta: { + title: "密码设置", + }, + }, + { + path: "lightSetting", + name: "LightSetting", + component: () => import("@/views/lightSetting/index.vue"), + meta: { + title: "灯光设置", + }, + }, + { + path: "recordSetting", + name: "RecordSetting", + component: () => import("@/views/recordSetting/index.vue"), + meta: { + title: "录波功能", + }, + }, + { + path: "lineSetting", + name: "LineSetting", + component: () => import("@/views/lineSetting/index.vue"), + meta: { + title: "线路定值设置", + }, + }, + { + path: "aiAlarmSetting", + name: "AiAlarmSetting", + component: () => import("@/views/aiAlarmSetting/index.vue"), + meta: { + title: "AI报警设置", + }, + }, + { + path: "deviceInfo", + name: "DeviceInfo", + component: () => import("@/views/deviceInfo/index.vue"), + meta: { + title: "装置信息", + }, + }, + ], + }, + // { + // path: "/404", + // name: "NotFoundPage", + // component: () => import("../views/404/index.vue"), + // meta: { + // title: "404", + // hidden: true, + // }, + // }, + { + path: "/:pathMatch(.*)*", + redirect: "/404", + }, +] + +/** + * 创建路由实例 + * createWebHistory() 是 Vue Router 4 推荐的 history 模式写法 + */ +const router = createRouter({ + history: createWebHistory(import.meta.env.BASE_URL), + routes, + scrollBehavior() { + return { + top: 0, + } + }, +}) + +/** + * 白名单页面 + */ +const WHITE_LIST = ["/dashboard", "/404"] + +/** + * 获取 token + * 这里先写成本地存储,你后面可以替换成 Pinia / cookies / 你项目自己的 auth 方案 + */ +function getToken() { + return localStorage.getItem("token") +} + +/** + * 全局前置守卫 + */ +router.beforeEach((to, _from, next) => { + const token = getToken() + + // 设置页面标题 + if (to.meta?.title) { + document.title = `${to.meta.title} - 电气量测控平台` + } else { + document.title = "电气量测控平台" + } + + // 不需要登录的页面直接放行 + if (WHITE_LIST.includes(to.path)) { + next() + return + } + + // 需要登录但没 token + if (to.meta?.requiresAuth && !token) { + next({ + path: "/login", + query: { + redirect: to.fullPath, + }, + }) + return + } + + next() +}) + +/** + * 全局后置守卫 + */ +router.afterEach(() => { + // 这里后面可以接入进度条、埋点、页面访问日志之类 +}) + +export default router diff --git a/frontend/src/views/aiAlarmSetting/index.vue b/frontend/src/views/aiAlarmSetting/index.vue new file mode 100644 index 0000000..005ea2d --- /dev/null +++ b/frontend/src/views/aiAlarmSetting/index.vue @@ -0,0 +1,193 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/aiChannelSetting/index.vue b/frontend/src/views/aiChannelSetting/index.vue new file mode 100644 index 0000000..7ef720e --- /dev/null +++ b/frontend/src/views/aiChannelSetting/index.vue @@ -0,0 +1,194 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/aiQuantity/index.vue b/frontend/src/views/aiQuantity/index.vue new file mode 100644 index 0000000..c4d6cea --- /dev/null +++ b/frontend/src/views/aiQuantity/index.vue @@ -0,0 +1,207 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/analogQuantity/index.vue b/frontend/src/views/analogQuantity/index.vue new file mode 100644 index 0000000..8212e44 --- /dev/null +++ b/frontend/src/views/analogQuantity/index.vue @@ -0,0 +1,349 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/aoChannelSetting/index.vue b/frontend/src/views/aoChannelSetting/index.vue new file mode 100644 index 0000000..6cb215e --- /dev/null +++ b/frontend/src/views/aoChannelSetting/index.vue @@ -0,0 +1,194 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/communicationSetting/index.vue b/frontend/src/views/communicationSetting/index.vue new file mode 100644 index 0000000..21a61a7 --- /dev/null +++ b/frontend/src/views/communicationSetting/index.vue @@ -0,0 +1,273 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/dashboard/index.vue b/frontend/src/views/dashboard/index.vue new file mode 100644 index 0000000..ac7d256 --- /dev/null +++ b/frontend/src/views/dashboard/index.vue @@ -0,0 +1,150 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/deviceInfo/index.vue b/frontend/src/views/deviceInfo/index.vue new file mode 100644 index 0000000..fc918cc --- /dev/null +++ b/frontend/src/views/deviceInfo/index.vue @@ -0,0 +1,116 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/eventReport/index.vue b/frontend/src/views/eventReport/index.vue new file mode 100644 index 0000000..ea086b9 --- /dev/null +++ b/frontend/src/views/eventReport/index.vue @@ -0,0 +1,192 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/lightSetting/index.vue b/frontend/src/views/lightSetting/index.vue new file mode 100644 index 0000000..09b88ec --- /dev/null +++ b/frontend/src/views/lightSetting/index.vue @@ -0,0 +1,161 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/lineSetting/index.vue b/frontend/src/views/lineSetting/index.vue new file mode 100644 index 0000000..20a597c --- /dev/null +++ b/frontend/src/views/lineSetting/index.vue @@ -0,0 +1,298 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue new file mode 100644 index 0000000..1d5f7ce --- /dev/null +++ b/frontend/src/views/login/index.vue @@ -0,0 +1,193 @@ + diff --git a/frontend/src/views/passwordSetting/index.vue b/frontend/src/views/passwordSetting/index.vue new file mode 100644 index 0000000..d15420c --- /dev/null +++ b/frontend/src/views/passwordSetting/index.vue @@ -0,0 +1,136 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/recordSetting/index.vue b/frontend/src/views/recordSetting/index.vue new file mode 100644 index 0000000..0438031 --- /dev/null +++ b/frontend/src/views/recordSetting/index.vue @@ -0,0 +1,321 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/switchQuantity/index.vue b/frontend/src/views/switchQuantity/index.vue new file mode 100644 index 0000000..2a7fc44 --- /dev/null +++ b/frontend/src/views/switchQuantity/index.vue @@ -0,0 +1,210 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/views/timeSetting/index.vue b/frontend/src/views/timeSetting/index.vue new file mode 100644 index 0000000..e888464 --- /dev/null +++ b/frontend/src/views/timeSetting/index.vue @@ -0,0 +1,107 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/websocket/client.ts b/frontend/src/websocket/client.ts index 2b38514..fd117ad 100644 --- a/frontend/src/websocket/client.ts +++ b/frontend/src/websocket/client.ts @@ -1,7 +1,9 @@ import type { AlarmEvent, RealtimeData } from '../types/platform' function buildWsUrl(path: string): string { - return `ws://127.0.0.1:8000${path}` + const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws' + const host = window.location.host + return `${protocol}://${host}${path}` } export function connectRealtime(onMessage: (data: RealtimeData) => void): WebSocket { diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 79c91b5..666e174 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -9,7 +9,11 @@ "isolatedModules": true, "esModuleInterop": true, "lib": ["ES2020", "DOM"], - "types": ["vite/client"] + "types": ["vite/client"], + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + } }, "include": ["src/**/*.ts", "src/**/*.vue"] } diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 6db2aa6..e787d55 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,10 +1,27 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' +import { resolve } from 'path' export default defineConfig({ plugins: [vue()], server: { - host: '0.0.0.0', + host: 0.0.0.0, port: 5173, + proxy: { + '/api': { + target: 'http://localhost:8000', + changeOrigin: true, + }, + '/ws': { + target: 'ws://localhost:8000', + changeOrigin: true, + ws: true, + }, + }, + }, + resolve: { + alias: { + '@': resolve(__dirname, 'src'), + }, }, })