diff --git a/.env b/.env index 53d90db..e097930 100644 --- a/.env +++ b/.env @@ -19,7 +19,7 @@ VITE_LAMP_PASSWORD = fjoc(1KHP(Ls&Bje)C VITE_LAMP_AUTHORIZATION = Y3VlZGVzX2FkbWluOmN1ZWRlc19hZG1pbl9zZWNyZXQ= # 当需要重置localStorage时, 修改此变量 -VITE_STORAGE_VERSION = 4 +VITE_STORAGE_VERSION = 5 # 调试码 VITE_DEBUG_CODE = ndm_debug diff --git a/README.md b/README.md index be8511e..173008c 100644 --- a/README.md +++ b/README.md @@ -39,19 +39,3 @@ pnpm build ``` 在执行 `pnpm build` 之前,你可以在 `package.json` 中修改 `version` 字段,将其设置为你期望的版本号,构建完成后,项目的根目录中除了 `dist` 目录外,还会生成三个压缩包,文件名的格式统一为 `ndm-web-platform_v_`,文件格式则分别为 `zip`、`tar`、`tar.gz`。 - -## 调试模式 - -在调试模式中,用户可以查看设备的原始诊断数据,也可以对轮询器进行控制,或者启用离线开发模式,系统不会自动调用一些主动触发的请求。 - -### 开启调试模式 - -在非登录页的任意页面中,使用键盘组合键 `Ctrl+Alt+D`,系统会弹出一个输入框,输入环境变量 `.env` 中的 `VITE_DEBUG_CODE` 对应的值即可开启调试模式,如需关闭调试模式,再次使用上述组合键并点击 `确认` 按钮即可。 - -注意调试模式与其内部的功能之间没有联动关系,例如在开启调试模式后可以关闭轮询或者启用离线开发模式,但是在关闭调试模式后,轮询不会重新被开启,离线开发模式也不会被关闭,因此在关闭离线开发模式前,请务必确保系统处于正确的运行状态下。 - -### 关于离线开发模式 - -由于离线开发模式涉及到登录操作,因此项目中将离线开发模式暴露到了全局变量 `window.$offlineDev` 中,允许在登录页中直接开启离线开发模式。 - -如果你第一次启动这个项目,系统在正常情况下会先跳转至登录页,此时如果希望开启离线模式,可以直接打开浏览器的开发者工具,在控制台输入 `window.$offlineDev.value = true` 即可,系统会直接跳转到首页。 diff --git a/src/App.vue b/src/App.vue index 356e370..306dfd7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -7,10 +7,10 @@ import { dateZhCN, NConfigProvider, NDialogProvider, NLoadingBarProvider, NMessa import { storeToRefs } from 'pinia'; const settingStore = useSettingStore(); -const { themeMode, offlineDev } = storeToRefs(settingStore); +const { themeMode, mockUser } = storeToRefs(settingStore); // 允许通过控制台启用离线开发模式 (登录页适用) -window.$offlineDev = offlineDev; +window.$mockUser = mockUser; useVersionCheckQuery(); diff --git a/src/components/device/device-card/components/current-diag/security-box-circuit-card.vue b/src/components/device/device-card/components/current-diag/security-box-circuit-card.vue index d9c556a..bd33f1b 100644 --- a/src/components/device/device-card/components/current-diag/security-box-circuit-card.vue +++ b/src/components/device/device-card/components/current-diag/security-box-circuit-card.vue @@ -38,7 +38,7 @@ const deviceStore = useDeviceStore(); const { lineDevices } = storeToRefs(deviceStore); const settingStore = useSettingStore(); -const { offlineDev } = storeToRefs(settingStore); +const { useLocalDB } = storeToRefs(settingStore); const { ndmDevice, station, circuits } = toRefs(props); @@ -258,8 +258,8 @@ const { mutate: unlinkDevice } = useMutation({ delete modifiedUpperLinkDescription.downstream?.[circuitIndex]; modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription); - // 3. 发起update请求并获取最新的设备详情(离线模式下直接修改本地数据) - if (offlineDev.value) { + // 3. 发起update请求并获取最新的设备详情(使用本地数据库时直接修改本地数据) + if (useLocalDB.value) { return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice }; } const stationCode = station.value.code; diff --git a/src/components/device/device-card/components/current-diag/security-box-circuit-link-modal.vue b/src/components/device/device-card/components/current-diag/security-box-circuit-link-modal.vue index c154a47..7db7d84 100644 --- a/src/components/device/device-card/components/current-diag/security-box-circuit-link-modal.vue +++ b/src/components/device/device-card/components/current-diag/security-box-circuit-link-modal.vue @@ -23,7 +23,7 @@ const show = defineModel('show', { default: false }); const deviceStore = useDeviceStore(); const settingStore = useSettingStore(); -const { offlineDev } = storeToRefs(settingStore); +const { useLocalDB } = storeToRefs(settingStore); const { ndmDevice, station, circuitIndex } = toRefs(props); @@ -150,8 +150,8 @@ const { mutate: linkPortToDevice, isPending: linking } = useMutation({ } modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription); - // 3. 发起update请求并获取最新的设备详情(离线模式下直接修改本地数据) - if (offlineDev.value) { + // 3. 发起update请求并获取最新的设备详情(使用本地数据库时直接修改本地数据) + if (useLocalDB.value) { return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice }; } const stationCode = station.value.code; diff --git a/src/components/device/device-card/components/current-diag/switch-port-card.vue b/src/components/device/device-card/components/current-diag/switch-port-card.vue index adced51..6829da5 100644 --- a/src/components/device/device-card/components/current-diag/switch-port-card.vue +++ b/src/components/device/device-card/components/current-diag/switch-port-card.vue @@ -25,7 +25,7 @@ const deviceStore = useDeviceStore(); const { lineDevices } = storeToRefs(deviceStore); const settingStore = useSettingStore(); -const { offlineDev } = storeToRefs(settingStore); +const { useLocalDB } = storeToRefs(settingStore); const { ndmDevice, station, ports } = toRefs(props); @@ -208,8 +208,8 @@ const { mutate: unlinkDevice } = useMutation({ delete modifiedUpperLinkDescription.downstream?.[port.portName]; modifiedUpperDevice.linkDescription = JSON.stringify(modifiedUpperLinkDescription); - // 3. 发起update请求并获取最新的设备详情(离线模式下直接修改本地数据) - if (offlineDev.value) { + // 3. 发起update请求并获取最新的设备详情(使用本地数据库时直接修改本地数据) + if (useLocalDB.value) { return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice }; } const stationCode = station.value.code; diff --git a/src/components/device/device-card/components/current-diag/switch-port-link-modal.vue b/src/components/device/device-card/components/current-diag/switch-port-link-modal.vue index fe6636c..f04276f 100644 --- a/src/components/device/device-card/components/current-diag/switch-port-link-modal.vue +++ b/src/components/device/device-card/components/current-diag/switch-port-link-modal.vue @@ -32,7 +32,7 @@ const show = defineModel('show', { default: false }); const deviceStore = useDeviceStore(); const settingStore = useSettingStore(); -const { offlineDev } = storeToRefs(settingStore); +const { useLocalDB } = storeToRefs(settingStore); const { ndmDevice, station, port } = toRefs(props); @@ -160,8 +160,8 @@ const { mutate: linkPortToDevice, isPending: linking } = useMutation({ } modifiedLowerDevice.linkDescription = JSON.stringify(modifiedLowerDeviceLinkDescription); - // 3. 发起update请求并获取最新的设备详情(离线模式下直接修改本地数据) - if (offlineDev.value) { + // 3. 发起update请求并获取最新的设备详情(使用本地数据库时直接修改本地数据) + if (useLocalDB.value) { return { upperDevice: modifiedUpperDevice, lowerDevice: modifiedLowerDevice }; } const stationCode = station.value.code; diff --git a/src/components/device/device-card/ndm-alarm-host/alarm-host-card.vue b/src/components/device/device-card/ndm-alarm-host/alarm-host-card.vue index 5719a42..1b37911 100644 --- a/src/components/device/device-card/ndm-alarm-host/alarm-host-card.vue +++ b/src/components/device/device-card/ndm-alarm-host/alarm-host-card.vue @@ -16,7 +16,7 @@ const route = useRoute(); const router = useRouter(); const settingStore = useSettingStore(); -const { debugModeEnabled } = storeToRefs(settingStore); +const { showDeviceRawData } = storeToRefs(settingStore); const { ndmDevice, station } = toRefs(props); @@ -31,7 +31,7 @@ const activeTabName = ref('当前诊断'); const onTabChange = (name: string) => { activeTabName.value = name; }; -watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { +watch([ndmDevice, showDeviceRawData], ([newDevice, enabled], [oldDevice]) => { if (newDevice.id !== oldDevice.id || !enabled) { activeTabName.value = '当前诊断'; } @@ -46,7 +46,7 @@ watch([ndmDevice, debugModeEnabled], ([newDevice, enabled], [oldDevice]) => { 当前诊断 历史诊断 修改设备 - 原始数据 + 原始数据