diff --git a/components.d.ts b/components.d.ts index 2144ab7..a0113ee 100644 --- a/components.d.ts +++ b/components.d.ts @@ -27,12 +27,12 @@ declare module 'vue' { ElHeader: typeof import('element-plus/es')['ElHeader'] ElIcon: typeof import('element-plus/es')['ElIcon'] ElInput: typeof import('element-plus/es')['ElInput'] + ElLink: typeof import('element-plus/es')['ElLink'] ElOption: typeof import('element-plus/es')['ElOption'] ElRadioButton: typeof import('element-plus/es')['ElRadioButton'] ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup'] ElRow: typeof import('element-plus/es')['ElRow'] ElSelect: typeof import('element-plus/es')['ElSelect'] - ElSwitch: typeof import('element-plus/es')['ElSwitch'] ElTable: typeof import('element-plus/es')['ElTable'] ElTableColumn: typeof import('element-plus/es')['ElTableColumn'] ElTag: typeof import('element-plus/es')['ElTag'] diff --git a/dist-v0.0.23.7z b/dist-v0.0.23.7z deleted file mode 100644 index 8f1b8ae..0000000 Binary files a/dist-v0.0.23.7z and /dev/null differ diff --git a/dist-v0.0.24.7z b/dist-v0.0.24.7z new file mode 100644 index 0000000..b1b8166 Binary files /dev/null and b/dist-v0.0.24.7z differ diff --git a/src/components/SoftKeyboard.vue b/src/components/SoftKeyboard.vue index dcaa0f0..b89c6b7 100644 --- a/src/components/SoftKeyboard.vue +++ b/src/components/SoftKeyboard.vue @@ -1,5 +1,4 @@ - + diff --git a/src/pages/Index/Settings/Device.vue b/src/pages/Index/Settings/Device.vue index e2f8dca..e50ae69 100644 --- a/src/pages/Index/Settings/Device.vue +++ b/src/pages/Index/Settings/Device.vue @@ -149,80 +149,6 @@ - -
-
-
- IP地址 -
- -
-
-
- 子网掩码 -
- -
-
-
- 网关 -
- -
-
-
-
- 首先DNS -
- -
-
-
- 备选DNS -
- -
-
-
- -
@@ -252,32 +178,21 @@ import { setAllTemperature, setIncubateBoxTemperature, setPlateBoxTemperature, - setDateAndTime, setNetworkSetting, getNetworkSetting + setDateAndTime, } from '@/services' import { eMessage, isValidIPv4 } from '../utils' import { useDeviceStore } from '@/store/index' import DatePicker from '@/pages/Index/components/Setting/DatePicker.vue' -import message from 'element-plus/es/components/message/index.mjs' +import SoftKeyboard from '@/components/SoftKeyboard.vue' +import { useSystemStore } from '@/store/modules/useSystemStore.ts' +import { SystemInfo } from '@/types/Index/System.ts' const deviceStore = useDeviceStore() const inputValue = ref('') const keyboardType = ref<'text' | 'number'>('number') const softKeyboardRef = ref() -// 系统设置状态 -interface Settings { - language: string - autoPrint: boolean - autoLogout: boolean - autoLogoutTimeout: number - allTemperature: number | undefined - incubateBoxTemperature: number - plateBoxTemperature: number - DHCP: boolean - localIp: string -} - -const settings = ref({ +const settings = ref({ language: 'zh-CN', autoPrint: true, autoLogout: false, @@ -289,118 +204,13 @@ const settings = ref({ localIp: '', }) -type Network = 'STATIC_IP' | 'DYNAMIC_IP' -const networkVisible = ref(false) -interface NetworkForm { - ip: string, - netmask: string, - gateway: string, - firstDns: string, - spareDns: string, - networkMode: Network -} -const networkForm = ref({ - id: '', - ip: '0.0.0.0', - netmask: '0.0.0.0', - gateway: '0.0.0.0', - firstDns: '0.0.0.0', - spareDns: '0.0.0.0', - networkMode: 'STATIC_IP', -}) - -const networkModeList = [{ - label: '固定IP地址', - value: 'STATIC_IP', -},{ - label: '动态获取IP地址', - value: 'DYNAMIC_IP', -}] - -const selectedNetworkModel = ref('STATIC_IP') - -const updateNetworkModel = (network) => { - networkForm.value.networkModel = network.value - networkVisible.value = true -} - -const getNetwork = () => { - getNetworkSetting().then(res => { - if(res.success) { - const {id, networkMode, staticIPConfig } = res.data - networkForm.value = { - id, - ip: staticIPConfig.ip, - gateway: staticIPConfig.gateway, - netmask: staticIPConfig.netmask, - firstDns: staticIPConfig.dnsList[0], - spareDns: staticIPConfig.dnsList[1], - networkMode - } - console.log('networkForm--', networkForm.value) - } - }) -} - -const onSaveNetwork = () => { - console.log('onSaveNetwork==setForm=== ', networkForm.value) - const {ip, gateway, netmask, spareDns, firstDns, networkMode} = networkForm.value - if(networkMode === 'STATIC_IP'){ - if(!ip){ - message.error('请输入IP地址') - return; - } - if(!gateway){ - message.error('请输入网关地址') - return; - } - if(!netmask){ - message.error('请输入子网掩码地址') - return; - } - if(!firstDns){ - message.error('请输入首先DNS') - return; - } - - if(!spareDns){ - message.error('请输入血液DNS') - return; - } - } - - const params = { - id: networkForm.value.id, - networkMode: selectedNetworkModel.value, - staticIPConfig: {}, - dynamicIpConfig: {}, - } - const staticConfig = { - ip, - netmask: netmask, - gateway: gateway, - dnsList: [firstDns, spareDns], - } - params.staticIPConfig = staticConfig - params.dynamicIpConfig = { - dnsList: [firstDns, spareDns] - } - setNetworkSetting(params).then(res => { - if(res.success){ - message.success('设置成功') - networkVisible.value = false - selectedNetworkModel.value = networkForm.value.networkModel - getNetwork() - } - }) -} - // 日期和时间 const currentDate = ref(new Date()) const time = ref('00:00:00') let pickerKey = ref(0) // const dateFormats = ['MM.dd.yyyy', 'dd.MM.yyyy', 'yyyy.MM.dd'] // const selectedDateFormat = ref(dateFormats[2]) +const systemStore = useSystemStore() // 选项配置 const languages = [ @@ -431,6 +241,7 @@ const fetchSettings = async () => { const res = await getSystemSettings() if (res.success) { settings.value = res.data + systemStore.updateSystemInfo(res.data) if (res.data.incubateBoxTemperature === res.data.plateBoxTemperature) { settings.value.allTemperature = res.data.incubateBoxTemperature } @@ -452,12 +263,7 @@ const focusedInput = ref(null) const openKeyboard = (e) => { keyboardVisible.value = true const labelName: string = e.target.name - let formValue = '' - if(networkVisible.value) { - formValue = networkForm.value[labelName] - }else { - formValue = settings.value[labelName] - } + let formValue = settings.value[labelName] inputValue.value = formValue ? formValue.toString() : '' focusedInput.value = labelName } @@ -465,11 +271,7 @@ const openKeyboard = (e) => { watch(inputValue, (newVal: string | number) => { if (focusedInput.value) { console.log('focusedInput.value--',focusedInput.value) - if(networkVisible.value){ - networkForm.value[focusedInput.value] = newVal - }else{ - settings.value[focusedInput.value] = newVal - } + settings.value[focusedInput.value] = newVal console.log('settings.value--',settings.value) } }) @@ -498,9 +300,15 @@ const updateSetting = async (key: string, value: any) => { break case 'autoLogout': res = await setAutoLogout(value) + systemStore.updateSystemInfo({ + autoLogout: value + }) break case 'autoLogoutTimeout': res = await setAutoLogoutTime(value) + systemStore.updateSystemInfo({ + autoLogoutTimeout: value + }) break case 'allTemperature': if (!isIntegerInRange(value)) { @@ -576,8 +384,6 @@ const temperatures = ref([]) // 初始化 onMounted(async () => { await fetchSettings() - // 获取网络参数 - await getNetwork() // 启动定时器 startTimer() const res = await getTemperatureRange() diff --git a/src/pages/Index/Settings/EditLis.vue b/src/pages/Index/Settings/EditLis.vue index cd481d8..d7fdaff 100644 --- a/src/pages/Index/Settings/EditLis.vue +++ b/src/pages/Index/Settings/EditLis.vue @@ -159,7 +159,7 @@ const saveLisForm = async () => { console.log('lisForm.lisIf00===', lisForm.value.lisIf) if(lisForm && lisForm.value.lisIf === 'NETWORK'){ const p = lisForm.value.LISNetPortStr.toString().trim() - if (!/^\d+$/.test(p)) { + if (!isValidPort(p)) { eMessage.error('请输入合法的端口值') return } @@ -208,6 +208,35 @@ const showKeyboard = (field: 'ip' | 'port') => { keyboardVisible.value = true } +const onCheck = (field: 'ip' | 'port' | '') => { + console.log('field========',field) + if(!field){ + return; + } + let fieldValue = '' + if (field === 'ip') { + fieldValue = lisForm.value?.lisNetIp || '' + let addr = fieldValue.trim() + if (!isValidIPv4(addr)) { + eMessage.error('请输入合法的IP地址') + return + } + } + if (field === 'port') { + fieldValue = lisForm.value?.LISNetPortStr || '' + if (!isValidPort(fieldValue)) { + eMessage.error('请输入合法的端口值') + return + } + } +} + +const isValidPort = (port) => { + // 匹配 0-65535 范围内的端口号 + const regex = /^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$/; + return regex.test(port); +} + // 处理键盘输入 const handleKeyboardInput = (value: string) => { // 更新当前输入值 @@ -225,6 +254,13 @@ watch(inputValue, (newVal: string) => { handleKeyboardInput(newVal) }) + +watch(keyboardVisible, (newVal)=>{ + if(!newVal){ + onCheck(currentInputField.value) + } +}) + // 隐藏键盘 const hideKeyboard = () => { keyboardVisible.value = false diff --git a/src/pages/Index/Settings/Lis.vue b/src/pages/Index/Settings/Lis.vue index 1936faf..d376950 100644 --- a/src/pages/Index/Settings/Lis.vue +++ b/src/pages/Index/Settings/Lis.vue @@ -3,31 +3,19 @@
类型
- + {{ LISTypeMap[lisSettings && lisSettings.lisType || ''] }}
协议
- + Boditech
接口
- + {{ LISInterfaceMap[lisSettings && lisSettings.lisIf || ''] }}
传输速度
- + {{ LISSerialBaudrateMap[lisSettings && lisSettings.lisSerialBaudrate || '']}}
-
+
@@ -239,7 +223,7 @@ onUnmounted(() => { } } .edit-lis{ - width: 100%; + width: 100vw; height: 5rem; padding: 0 24px; border: 1px solid #dcdfe6; @@ -247,11 +231,14 @@ onUnmounted(() => { font-size: 24px; cursor: pointer; transition: all 0.3s ease; + color: #fff; + background-color: #409eff; +} +.lis-btn{ + width: 100%; display: flex; align-items: center; justify-content: center; - color: #fff; - background-color: #409eff; } .keyboard { position: fixed; diff --git a/src/pages/Index/Settings/Network.vue b/src/pages/Index/Settings/Network.vue index f6905bb..df996b7 100644 --- a/src/pages/Index/Settings/Network.vue +++ b/src/pages/Index/Settings/Network.vue @@ -52,25 +52,30 @@ />
-
- {{ index === 0 ? '首先DNS' : '备选DNS' }} -
- - - +
+
+ {{ index === 0 ? 'DNS' : '' }} +
+ + {{ index === 0 ? '首先' : '备选' }} + + + + +
@@ -102,29 +107,33 @@
@@ -185,11 +194,11 @@ const defaultDnsData = ref() const networkModeList = [ { - label: '固定IP地址', + label: '静态IP', value: 'STATIC_IP', }, { - label: '动态获取IP地址', + label: '动态IP', value: 'DYNAMIC_IP', }, ] @@ -498,4 +507,23 @@ onUnmounted(() => { color: #fff; background-color: #409eff; } + +.dns-list{ + background-color: #ffffff; + padding: 10px; + .dns-item{ + box-shadow: none; + padding: 10px 1.5rem; + } +} +.dns-title{ + font-size: 1.5rem; + color: #888888; + padding-right: 8px; +} + +.dns-input{ + display: flex; + align-items: center; +} diff --git a/src/pages/Index/Settings/Version.vue b/src/pages/Index/Settings/Version.vue index d41cc75..fd7fead 100644 --- a/src/pages/Index/Settings/Version.vue +++ b/src/pages/Index/Settings/Version.vue @@ -1,7 +1,7 @@ diff --git a/src/services/osControl/os.ts b/src/services/osControl/os.ts index bcdb147..5395797 100644 --- a/src/services/osControl/os.ts +++ b/src/services/osControl/os.ts @@ -155,4 +155,12 @@ export const disableDevice = async () => { } } - +// MCU详细版本信息 +export const getMcuVersionDetailInfo = async () => { + try { + const res = await apiClient.post('/api/v1/app/DeviceInfo/getMcuVersionDetail') + return res.data + } catch (error) { + console.log('MCU详细版本信息获取报错', error) + } +} diff --git a/src/store/modules/useSystemStore.ts b/src/store/modules/useSystemStore.ts index e613c84..a564377 100644 --- a/src/store/modules/useSystemStore.ts +++ b/src/store/modules/useSystemStore.ts @@ -1,5 +1,6 @@ import { defineStore } from 'pinia' import { ref } from 'vue' +import { SystemInfo } from '@/types/Index/System.ts' export const useSystemStore = defineStore('system', () => { const isDebug = ref(false) @@ -23,6 +24,24 @@ export const useSystemStore = defineStore('system', () => { const updateStatusList = (status) => { statusList.value.push(status) } + + const systemInfo = ref({ + language: 'zh-CN', + autoPrint: true, + autoLogout: false, + autoLogoutTimeout: 10, + allTemperature: 20, + incubateBoxTemperature: 20, + plateBoxTemperature: 20, + DHCP: true, + localIp: '', + }) + const updateSystemInfo = (data) => { + systemInfo.value = { + ...systemInfo.value, + ...data, + } + } return { isDebug, @@ -34,5 +53,8 @@ export const useSystemStore = defineStore('system', () => { statusList, updateStatusList, + + systemInfo, + updateSystemInfo, } }) diff --git a/src/types/Index/Settings.ts b/src/types/Index/Settings.ts index e6e56ca..b133627 100644 --- a/src/types/Index/Settings.ts +++ b/src/types/Index/Settings.ts @@ -26,3 +26,11 @@ export interface ResponseData { timestamp: number success: boolean } + + +export interface McuVersionInfo { + boardName: string + mid: string + version: string + versionCode: string +} \ No newline at end of file diff --git a/src/types/Index/System.ts b/src/types/Index/System.ts new file mode 100644 index 0000000..a8c7366 --- /dev/null +++ b/src/types/Index/System.ts @@ -0,0 +1,11 @@ +export interface SystemInfo { + language: string + autoPrint: boolean + autoLogout: boolean + autoLogoutTimeout: number + allTemperature: number | undefined + incubateBoxTemperature: number + plateBoxTemperature: number + DHCP: boolean + localIp: string +} diff --git a/src/utils/getServerInfo.ts b/src/utils/getServerInfo.ts index 96bd3d6..c44bfb7 100644 --- a/src/utils/getServerInfo.ts +++ b/src/utils/getServerInfo.ts @@ -5,15 +5,15 @@ export function getServerInfo(wsPath: string = '/api/v1/app/ws/state') { // 获取主机名(IP 或域名)和端口号 // const host = url.hostname // 例如: "192.168.1.100" 或 "localhost" - const host = window.location.hostname; + // const host = window.location.hostname; // const host = window.location.host; - // const host = "192.168.8.175"; + const host = "127.0.0.1"; // const port = '8082' // 使用固定的后端端口;由于本地开发时,8080被占用导致ws连接失败,所以使用8082 const port = "80" // 构建 WebSocket URL const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:' - // const wsUrl = `${wsProtocol}//${host}:${port}${wsPath}` - const wsUrl = `${wsProtocol}//${host}${wsPath}` + const wsUrl = `${wsProtocol}//${host}:${port}${wsPath}` + // const wsUrl = `${wsProtocol}//${host}${wsPath}` // 构建 HTTP URL const httpUrl = `${window.location.protocol}//${host}:${port}` // 例如: "http://192.168.1.100:8082" 或 "http://localhost:8082" diff --git a/src/websocket/socket.ts b/src/websocket/socket.ts index 73fa2b9..5aa5672 100644 --- a/src/websocket/socket.ts +++ b/src/websocket/socket.ts @@ -255,6 +255,7 @@ interface TubeHolderStateMessage extends BaseMessage { projIds: number[] state: RunningTubeState errors: string[] + erroInfo: string }> state: string }