修复连接wifi时wifi名包含中文就连接失败的bug

master
qubiaobiao 2024-08-27 14:38:23 +08:00
parent 3e512acec1
commit b3a565930b
2 changed files with 18 additions and 5 deletions

View File

@ -1,10 +1,18 @@
import { ref } from 'vue' import { ref } from 'vue'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { useMessage } from 'naive-ui'
export const useNetworkStore = defineStore('network', () => { export const useNetworkStore = defineStore('network', () => {
const message = useMessage()
const isOnLine = ref(window.navigator.onLine) const isOnLine = ref(window.navigator.onLine)
window.addEventListener( 'online' , () => isOnLine.value = true ) window.addEventListener( 'online' , () => {
window.addEventListener( 'offline', () => isOnLine.value = false ) isOnLine.value = true
message.success('连接成功')
} )
window.addEventListener( 'offline', () => {
isOnLine.value = false
message.error('连接失败')
} )
return { isOnLine } return { isOnLine }
}) })

View File

@ -74,9 +74,9 @@ const columns = [
return h( return h(
NButton, NButton,
{ {
type: 'info', type: row.ssid === current.value?.ssid ? 'primary' : 'info',
secondary: true, secondary: true,
disabled: row.ssid === current.value?.ssid || !row.password, disabled: row.ssid === current.value?.ssid || !row.password || row.password.length < 8,
onClick: () => connect({ ssid:row.ssid, password: row.password }) onClick: () => connect({ ssid:row.ssid, password: row.password })
}, },
{ default: () => row.ssid === current.value?.ssid ? '已连接' : '连 接' } { default: () => row.ssid === current.value?.ssid ? '已连接' : '连 接' }
@ -91,11 +91,16 @@ const connect = ( connectionOpts ) => {
return return
} }
if(connectionOpts.password.length < 8) {
message.error('密码长度不足8位')
return
}
if (!hasIpcRenderer()) return if (!hasIpcRenderer()) return
const result = window.ipcRenderer.sendSync('NETWORK_CONNECT', connectionOpts) const result = window.ipcRenderer.sendSync('NETWORK_CONNECT', connectionOpts)
if (result === 'OK') { if (result === 'OK') {
message.success('网络连接成功') message.success('网络连接请求发送成功')
emit('done') emit('done')
} else { } else {
message.error(result.message) message.error(result.message)