|
@ -20,6 +20,7 @@ function SystemSettings() { |
|
|
const [settingLoading, setSettingLoading] = useState(false) |
|
|
const [settingLoading, setSettingLoading] = useState(false) |
|
|
const [imageControlLoading, setImageControlLoading] = useState(false) |
|
|
const [imageControlLoading, setImageControlLoading] = useState(false) |
|
|
const [clearZeroLoading, setClearZeroLoading] = useState(false) |
|
|
const [clearZeroLoading, setClearZeroLoading] = useState(false) |
|
|
|
|
|
const [storagePath, setStoragePath] = useState('') |
|
|
|
|
|
|
|
|
// 获取设备连接状态和重连配置 |
|
|
// 获取设备连接状态和重连配置 |
|
|
const connectedDevice = useDeviceStore((state) => state.connectedDevice) |
|
|
const connectedDevice = useDeviceStore((state) => state.connectedDevice) |
|
@ -64,6 +65,60 @@ function SystemSettings() { |
|
|
} |
|
|
} |
|
|
}, [setReconnecting]) |
|
|
}, [setReconnecting]) |
|
|
|
|
|
|
|
|
|
|
|
// 初始化存储路径 |
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
const savedPath = localStorage.getItem('storagePath') |
|
|
|
|
|
if (savedPath) { |
|
|
|
|
|
setStoragePath(savedPath) |
|
|
|
|
|
} else { |
|
|
|
|
|
// 使用暴露的 API 获取默认存储路径 |
|
|
|
|
|
const defaultPath = window.api.getDefaultStoragePath() |
|
|
|
|
|
setStoragePath(defaultPath) |
|
|
|
|
|
localStorage.setItem('storagePath', defaultPath) |
|
|
|
|
|
} |
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
// 打开存储目录 |
|
|
|
|
|
const handleOpenStoragePath = async () => { |
|
|
|
|
|
if (!storagePath) { |
|
|
|
|
|
message.warning('存储路径未设置') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
// 使用 IPC 调用主进程打开目录 |
|
|
|
|
|
const result = await window.electron.ipcRenderer.invoke('open-directory', storagePath) |
|
|
|
|
|
if (!result.success) { |
|
|
|
|
|
message.error(`打开目录失败:${result.error}`) |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('打开存储目录失败:', error) |
|
|
|
|
|
message.error(`打开目录失败:${error.message}`) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 选择存储目录 |
|
|
|
|
|
const handleSelectStoragePath = async () => { |
|
|
|
|
|
try { |
|
|
|
|
|
// 使用 IPC 调用主进程选择目录 |
|
|
|
|
|
const result = await window.electron.ipcRenderer.invoke('select-directory', { |
|
|
|
|
|
title: '选择存储目录', |
|
|
|
|
|
defaultPath: storagePath |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
if (result.success && result.path) { |
|
|
|
|
|
setStoragePath(result.path) |
|
|
|
|
|
localStorage.setItem('storagePath', result.path) |
|
|
|
|
|
message.success('存储目录设置成功!') |
|
|
|
|
|
} else if (!result.canceled) { |
|
|
|
|
|
message.error(`选择目录失败:${result.error}`) |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error('选择存储目录失败:', error) |
|
|
|
|
|
message.error(`选择目录失败:${error.message}`) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 读取参数函数 |
|
|
// 读取参数函数 |
|
|
const handleReadParam = async () => { |
|
|
const handleReadParam = async () => { |
|
|
if (!selectedParam) { |
|
|
if (!selectedParam) { |
|
@ -444,13 +499,28 @@ function SystemSettings() { |
|
|
存储目录 |
|
|
存储目录 |
|
|
</div> |
|
|
</div> |
|
|
<div> |
|
|
<div> |
|
|
<Button icon={<EyeOutlined />} type="text" disabled={!connectedDevice}></Button> |
|
|
<Button |
|
|
<Button icon={<EditOutlined />} type="text" disabled={!connectedDevice}></Button> |
|
|
icon={<EyeOutlined />} |
|
|
|
|
|
type="text" |
|
|
|
|
|
onClick={handleOpenStoragePath} |
|
|
|
|
|
title="打开存储目录" |
|
|
|
|
|
/> |
|
|
|
|
|
<Button |
|
|
|
|
|
icon={<EditOutlined />} |
|
|
|
|
|
type="text" |
|
|
|
|
|
onClick={handleSelectStoragePath} |
|
|
|
|
|
title="选择存储目录" |
|
|
|
|
|
/> |
|
|
</div> |
|
|
</div> |
|
|
</Flex> |
|
|
</Flex> |
|
|
|
|
|
|
|
|
<Flex align="center" gap={8} className={styles.storageInputRow}> |
|
|
<Flex align="center" gap={8} className={styles.storageInputRow}> |
|
|
<Input className={styles.storageInput} disabled={!connectedDevice} /> |
|
|
<Input |
|
|
|
|
|
className={styles.storageInput} |
|
|
|
|
|
value={storagePath} |
|
|
|
|
|
readOnly |
|
|
|
|
|
placeholder="存储目录路径" |
|
|
|
|
|
/> |
|
|
</Flex> |
|
|
</Flex> |
|
|
<Checkbox className={styles.checkboxRight} disabled={!connectedDevice}> |
|
|
<Checkbox className={styles.checkboxRight} disabled={!connectedDevice}> |
|
|
实时数据 |
|
|
实时数据 |
|
|