From 2a82f444c16fe8993f3d0038759640f76d66e9ab Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Thu, 4 Nov 2021 15:39:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=86=E8=8A=82=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 1 + .gitignore | 3 +- index.html | 2 +- mock/function-config.js | 23 ------ mock/network-config.js | 13 --- package.json | 3 +- src/App.vue | 28 +++++-- src/components/function-config-applied.vue | 2 +- src/components/search-bar-data.vue | 6 +- src/components/search-bar.vue | 6 +- src/routers/index.js | 92 ++++++++++++++-------- src/store/device.js | 7 +- src/utils/axios.js | 1 - src/views/data-history.vue | 16 ++-- src/views/device-create.vue | 57 +++++++------- src/views/device-list.vue | 56 +++++++------ src/views/month-data.vue | 2 +- src/views/statistical-history.vue | 2 +- src/views/statistical-realtime.vue | 2 +- 19 files changed, 175 insertions(+), 147 deletions(-) delete mode 100644 mock/function-config.js delete mode 100644 mock/network-config.js diff --git a/.env.production b/.env.production index e69de29..ab22b6a 100644 --- a/.env.production +++ b/.env.production @@ -0,0 +1 @@ +VITE_API_URL=https://www.tall.wiki diff --git a/.gitignore b/.gitignore index 855f6f4..5ddf738 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ dist dist-ssr *.local .eslintcache -.husky +.idea +.vscode diff --git a/index.html b/index.html index 030a6ff..b515a49 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Vite App + 智能大气腐蚀检测云平台
diff --git a/mock/function-config.js b/mock/function-config.js deleted file mode 100644 index 032b02b..0000000 --- a/mock/function-config.js +++ /dev/null @@ -1,23 +0,0 @@ -module.exports = { - frequency: { - so2: 0, // SO2采样频率 - metal: 0, // 金属腐蚀采样频率 - th: 0, // 温湿度 采样频率 - salt: 0, // 盐雾 采样频率 - }, // 采样频率 - count: 0, // 采集个数 - time: new Date(), // 设置时间 - batteryLow: 0, // 电池电压低阈值 - batteryHigh: 0, // 电池电压高阈值 - sunHigh: 0, // 太阳能电压高阈值 - humidityHigh: 0, // 湿度高阈值 - temperatureLow: 0, // 温度低阈值 - temperatureHigh: 0, // 温度高阈值 - securityMode: 0, // 安全模式 0->不加密 1->加密 - corrosiveType: '', // 金属腐蚀类型 - report: { - type: 0, // 上报周期类型 0->时间点 1->周期 - timePoints: [0, 0, 0, 0, 0, 0], // 设置时间点 - cycle: 0, // 上报周期分钟数 - }, -}; diff --git a/mock/network-config.js b/mock/network-config.js deleted file mode 100644 index 74dbdae..0000000 --- a/mock/network-config.js +++ /dev/null @@ -1,13 +0,0 @@ -module.exports = { - ip1: '', - port1: '', - ip2: '', - port2: '', - ip3: '', - port3: '', - ipBackup: '', // 备用ip - portBackup: '', // 备用端口号 - account: '', // 账号 - password: '', // 密码 - apn: '', // apn -}; diff --git a/package.json b/package.json index d9669f9..d137666 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "scripts": { "dev-test": "vite --mode development", "dev": "vite --mode test", - "build": "vite build", + "build": "vite build --mode test", + "build:prod": "vite build --mode production", "serve": "vite preview", "cz": "git add . && git cz", "format": "prettier --write ./src", diff --git a/src/App.vue b/src/App.vue index 332f8d1..bc1a346 100644 --- a/src/App.vue +++ b/src/App.vue @@ -14,13 +14,14 @@ const routeList = ref(routes); const menu = computed(() => store.state.menu); // 验证 获取query中u参数 获取token - const route = useRoute(); +const router = useRouter(); + useRouter() .isReady() .then(async () => { const u = computed(() => route.query.u); - if (!u) { + if (!u.value) { // 获取url中的u参数, 没有提示缺少参数 ElMessage.error('缺少用户信息参数'); } else { @@ -32,7 +33,7 @@ useRouter() const token = computed(() => store.getters['user/token']); // 获取设备数据 const getDeviceData = async () => { - if (token) { + if (token && token.value) { await store.dispatch('device/getDevices'); timer && clearTimeout(timer); timer = null; @@ -44,6 +45,18 @@ const getDeviceData = async () => { }; getDeviceData(); + +/** + * 打开页面 + * @param {string} path 页面路径 + */ +function openPage(path) { + const { query } = route; + router.push({ + path, + query, + }); +}