diff --git a/ui/autoMate/src/renderer/src/pages/Setting/SettingLoader.ts b/ui/autoMate/src/renderer/src/pages/Setting/SettingLoader.ts new file mode 100644 index 0000000..48605c9 --- /dev/null +++ b/ui/autoMate/src/renderer/src/pages/Setting/SettingLoader.ts @@ -0,0 +1,4 @@ +export default async ({}) =>{ + const config = (await window.api.sql('select * from config where id=1', 'findOne', {})) as ConfigType + return JSON.parse(config.content) as ConfigDataType +} \ No newline at end of file diff --git a/ui/autoMate/src/renderer/src/pages/Setting/index.tsx b/ui/autoMate/src/renderer/src/pages/Setting/index.tsx index 661862a..b5e2c96 100644 --- a/ui/autoMate/src/renderer/src/pages/Setting/index.tsx +++ b/ui/autoMate/src/renderer/src/pages/Setting/index.tsx @@ -1,7 +1,8 @@ -import { Form, useSubmit } from 'react-router-dom' +import { Form, useLoaderData, useSubmit } from 'react-router-dom' import styles from './styles.module.scss' export const Setting = () => { + const config = useLoaderData() as ConfigDataType const submit = useSubmit() return (
@@ -12,6 +13,7 @@ export const Setting = () => { { submit(e.currentTarget.form, {method: 'POST'}) }} @@ -19,7 +21,7 @@ export const Setting = () => {
数据库
- +
diff --git a/ui/autoMate/src/renderer/src/router/index.tsx b/ui/autoMate/src/renderer/src/router/index.tsx index d5076e2..974b4cd 100644 --- a/ui/autoMate/src/renderer/src/router/index.tsx +++ b/ui/autoMate/src/renderer/src/router/index.tsx @@ -13,6 +13,7 @@ import ContentListAction from "@renderer/pages/ContentList/ContentListAction"; import CategoryAction from "@renderer/pages/Category/CategoryAction"; import { Setting } from "@renderer/pages/Setting"; import SettingAction from "@renderer/pages/Setting/SettingAction"; +import SettingLoader from "@renderer/pages/Setting/SettingLoader"; const router = createHashRouter([ { @@ -25,6 +26,7 @@ const router = createHashRouter([ children: [ { index: true, + loader: SettingLoader, action: SettingAction, element: }, diff --git a/ui/autoMate/types.d.ts b/ui/autoMate/types.d.ts index 9cb7ba6..02a3612 100644 --- a/ui/autoMate/types.d.ts +++ b/ui/autoMate/types.d.ts @@ -15,4 +15,14 @@ type ContentType = { } -type WindowNameType = 'search' | 'config' \ No newline at end of file +type WindowNameType = 'search' | 'config' + +type ConfigType = { + id: number + content: string +} + +type ConfigDataType = { + shortCut: string + databaseDirectory: string +} \ No newline at end of file