From 0a893f4fd821ea261452e8d31151f544618f7dbe Mon Sep 17 00:00:00 2001 From: guoapeng Date: Fri, 9 May 2025 16:58:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8F=A3=E5=AE=9E=E7=8E=B0;?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=9E=B6=E6=9E=84=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/index.js | 4 +- server/routes/auth.js | 4 +- server/routes/control.js | 74 ++++++++++++++++++++++++++++++++ server/routes/debug.js | 40 ----------------- server/routes/ore.js | 33 ++++++++++++++ src/apis/ore.ts | 2 +- src/apis/system.ts | 1 + src/assets/images/logout.svg | 1 + src/assets/styles/element.scss | 9 +++- src/assets/styles/main.scss | 6 --- src/assets/styles/variable.scss | 5 +++ src/components/common/FTDialog/index.vue | 4 +- src/layouts/default.vue | 13 +++++- src/main.ts | 1 + src/stores/homeStore.ts | 44 +++++++++++++++++++ src/views/login/index.vue | 8 +++- vite.config.ts | 4 +- 17 files changed, 196 insertions(+), 57 deletions(-) create mode 100644 server/routes/control.js delete mode 100644 server/routes/debug.js create mode 100644 server/routes/ore.js create mode 100644 src/assets/images/logout.svg create mode 100644 src/assets/styles/variable.scss create mode 100644 src/stores/homeStore.ts diff --git a/server/index.js b/server/index.js index fdbfffa..fdb1173 100644 --- a/server/index.js +++ b/server/index.js @@ -1,7 +1,8 @@ // const express = require('express') import express from 'express' import { authRoutes } from './routes/auth.js' -import { debugRoutes } from './routes/debug.js' +import { debugRoutes } from './routes/control.js' +import { oreRoutes } from './routes/ore.js' import { initWebSocketServer } from './utils/websocket.js' const app = express() @@ -18,3 +19,4 @@ initWebSocketServer() // 注册路由模块 debugRoutes(app) authRoutes(app) +oreRoutes(app) diff --git a/server/routes/auth.js b/server/routes/auth.js index 1b4189e..2c0f3c7 100644 --- a/server/routes/auth.js +++ b/server/routes/auth.js @@ -17,7 +17,9 @@ export const authRoutes = (app) => { fixedUser: 'ENABLE', }, } - res.json(mockResponse) + setTimeout(() => { + res.json(mockResponse) + }, 2000) }) app.post(`${baseUrl}/logout`, (req, res) => { // const { username, password } = req.body diff --git a/server/routes/control.js b/server/routes/control.js new file mode 100644 index 0000000..e9ee542 --- /dev/null +++ b/server/routes/control.js @@ -0,0 +1,74 @@ +import { broadcast } from '../utils/websocket.js' + +export const debugRoutes = (app) => { + const statusList = ['info', 'warn', 'success', 'error', 'finish'] + + app.post('/api/debug/cmd', (req, res) => { + const { commandId, command, params } = req.body + console.log('收到命令:', command, '参数:', params) + + // 模拟返回数据 + const mockResponse = { + code: '0', + msg: '成功', + data: null, + } + + let messageNum = 0 + + // 异步广播消息 + setTimeout(() => { + res.json(mockResponse) + const poll = setInterval(() => { + if (messageNum === 10) { + clearInterval(poll) + } + broadcast({ + type: 'cmd_debug', + data: { + commandId, + command, + status: statusList[Math.floor(Math.random() * statusList.length)], + title: `步骤${messageNum}执行完成`, + content: `具体信息${messageNum}`, + }, + }) + messageNum++ + }, Math.floor(Math.random() * (1000 - 500 + 1)) + 500) + }, 1000) + }) + app.post('/api/cmd', (req, res) => { + const { commandId, command, params } = req.body + console.log('收到命令:', command, '参数:', params) + + // 模拟返回数据 + const mockResponse = { + code: '0', + msg: '成功', + data: null, + } + + let messageNum = 0 + + // 异步广播消息 + setTimeout(() => { + res.json(mockResponse) + const poll = setInterval(() => { + if (messageNum === 10) { + clearInterval(poll) + } + broadcast({ + type: 'cmd_debug', + data: { + commandId, + command, + status: statusList[Math.floor(Math.random() * statusList.length)], + title: `步骤${messageNum}执行完成`, + content: `具体信息${messageNum}`, + }, + }) + messageNum++ + }, Math.floor(Math.random() * (1000 - 500 + 1)) + 500) + }, 1000) + }) +} diff --git a/server/routes/debug.js b/server/routes/debug.js deleted file mode 100644 index 2b62e1a..0000000 --- a/server/routes/debug.js +++ /dev/null @@ -1,40 +0,0 @@ -import { broadcast } from '../utils/websocket.js' - -export const debugRoutes = (app) => { - const statusList = ['info', 'warn', 'success', 'error', 'finish'] - - app.post('/api/debug/cmd', (req, res) => { - const { commandId, command, params } = req.body - console.log('收到命令:', command, '参数:', params) - - // 模拟返回数据 - const mockResponse = { - code: '0', - msg: '成功', - data: null, - } - - let messageNum = 0 - - // 异步广播消息 - setTimeout(() => { - res.json(mockResponse) - const poll = setInterval(() => { - if (messageNum === 10) { - clearInterval(poll) - } - broadcast({ - type: 'cmd_debug', - data: { - commandId, - command, - status: statusList[Math.floor(Math.random() * statusList.length)], - title: `步骤${messageNum}执行完成`, - content: `具体信息${messageNum}`, - }, - }) - messageNum++ - }, Math.floor(Math.random() * (1000 - 500 + 1)) + 500) - }, 1000) - }) -} diff --git a/server/routes/ore.js b/server/routes/ore.js new file mode 100644 index 0000000..3277ba5 --- /dev/null +++ b/server/routes/ore.js @@ -0,0 +1,33 @@ +const baseUrl = '/api/ores' +export const oreRoutes = (app) => { + app.get(`${baseUrl}/list`, (req, res) => { + const mockResponse = { + code: '0', + data: { + list: [ + { + id: 1, + oresName: '金矿石2', + createTime: '2025-04-27 15:54:32', + updateTime: '2025-04-27 15:54:32', + craftsList: [ + { + id: 1, + createTime: '2025-04-27 15:55:13', + updateTime: '2025-04-27 15:55:13', + name: '工艺2', + steps: '[{"method":"upTray"},{"method":"downTray"},{"method":"addLiquid","params":{"tubeSolList":[{"tubeNum":15,"addLiquidList":[{"solId":15,"volume":20}]}]}},{"method":"moveToSol"},{"method":"moveToHeat"},{"method":"shaking","params":{"second":6}},{"method":"startHeating","params":{"temperature":200}},{"method":"stopHeating"},{"method":"takePhoto"},{"method":"delay","params":{"second":2}}]', + oresId: 1, + }, + ], + }, + ], + total: 1, + }, + msg: '成功', + } + setTimeout(() => { + res.json(mockResponse) + }, 1000) + }) +} diff --git a/src/apis/ore.ts b/src/apis/ore.ts index ee53128..8b0b5ee 100644 --- a/src/apis/ore.ts +++ b/src/apis/ore.ts @@ -1,6 +1,6 @@ import http from 'libs/http' -export const getOreList = (): Promise => http.get(`/ores/list`) +export const getOreList = (): Promise> => http.get(`/ores/list`) export const saveOre = (params: { name: string }): Promise => http.post(`/ores`, params) diff --git a/src/apis/system.ts b/src/apis/system.ts index 2d86b3c..b42f869 100644 --- a/src/apis/system.ts +++ b/src/apis/system.ts @@ -1,3 +1,4 @@ import http from 'libs/http' export const debugControl = (params: System.CmdControlParams): Promise => http.post('/debug/cmd', params) +export const control = (params: System.CmdControlParams): Promise => http.post('/cmd', params) diff --git a/src/assets/images/logout.svg b/src/assets/images/logout.svg new file mode 100644 index 0000000..dc19d14 --- /dev/null +++ b/src/assets/images/logout.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/styles/element.scss b/src/assets/styles/element.scss index 5e5169c..e9048f8 100644 --- a/src/assets/styles/element.scss +++ b/src/assets/styles/element.scss @@ -4,7 +4,7 @@ - // --el-color-primary: #26509C; + --el-color-primary: #26509C; //--el-button-active-bg-color: linear-gradient(90deg, #0657C0 24%, #096AE0 101%); --text-color-primary: #17213c; //--el-color-success: rgba(88, 162, 95, 1); @@ -16,4 +16,11 @@ //--color-yellow: #e6a23c; //--color-blue: --el-color-primary; --el-font-family: 'PingFangSC-Regular', 'PingFang SC', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif; +} +.el-dialog { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + margin: 0; } \ No newline at end of file diff --git a/src/assets/styles/main.scss b/src/assets/styles/main.scss index 04de84d..57fc354 100644 --- a/src/assets/styles/main.scss +++ b/src/assets/styles/main.scss @@ -1,9 +1,3 @@ -$primary-color: #1989FA; -$success-color: #14A656; -$danger-color: #DF1515; -$warn-color: #EE8223; -$info-color: #909399; - @use './common.scss'; @use './element.scss'; diff --git a/src/assets/styles/variable.scss b/src/assets/styles/variable.scss new file mode 100644 index 0000000..dbda63e --- /dev/null +++ b/src/assets/styles/variable.scss @@ -0,0 +1,5 @@ +$primary-color: #1989FA; +$success-color: #14A656; +$danger-color: #DF1515; +$warn-color: #EE8223; +$info-color: #909399; \ No newline at end of file diff --git a/src/components/common/FTDialog/index.vue b/src/components/common/FTDialog/index.vue index 7b4f098..d54f8cb 100644 --- a/src/components/common/FTDialog/index.vue +++ b/src/components/common/FTDialog/index.vue @@ -63,10 +63,10 @@ watch( diff --git a/src/layouts/default.vue b/src/layouts/default.vue index 5fccd92..fffed23 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -1,5 +1,6 @@ diff --git a/vite.config.ts b/vite.config.ts index 549e038..94624cd 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -87,7 +87,7 @@ export default defineConfig(({ mode }) => { css: { preprocessorOptions: { scss: { - additionalData: '@use "@/assets/styles/main.scss" as *;', + additionalData: '@use "@/assets/styles/variable.scss" as *;', }, }, }, @@ -107,4 +107,4 @@ export default defineConfig(({ mode }) => { }, }, } -}) \ No newline at end of file +})