refactor: app conf

This commit is contained in:
lencx
2023-01-27 00:23:05 +08:00
parent f0ff062b21
commit f9f173407e
14 changed files with 388 additions and 396 deletions

2
src/utils.ts vendored
View File

@@ -2,7 +2,7 @@ import { readTextFile, writeTextFile, exists, createDir } from '@tauri-apps/api/
import { homeDir, join, dirname } from '@tauri-apps/api/path';
import dayjs from 'dayjs';
export const CHAT_CONF_JSON = 'chat.conf.json';
export const APP_CONF_JSON = 'chat.conf.json';
export const CHAT_MODEL_JSON = 'chat.model.json';
export const CHAT_MODEL_CMD_JSON = 'chat.model.cmd.json';
export const CHAT_DOWNLOAD_JSON = 'chat.download.json';

View File

@@ -7,7 +7,7 @@ import { os, invoke } from '@tauri-apps/api';
import useInit from '@/hooks/useInit';
import useJson from '@/hooks/useJson';
import { CHAT_AWESOME_JSON, CHAT_CONF_JSON, readJSON } from '@/utils';
import { CHAT_AWESOME_JSON, APP_CONF_JSON, readJSON } from '@/utils';
import './index.scss';
export default function Dashboard() {
@@ -19,7 +19,7 @@ export default function Dashboard() {
useInit(async () => {
const getOS = await os.platform();
const conf = await readJSON(CHAT_CONF_JSON);
const conf = await readJSON(APP_CONF_JSON);
const appTheme = await invoke('get_theme');
setTheme(appTheme as string);
setClass(!conf?.titlebar && getOS === 'darwin');

View File

@@ -6,7 +6,7 @@ import { clone, omit, isEqual } from 'lodash';
import useInit from '@/hooks/useInit';
import FilePath from '@/components/FilePath';
import { chatRoot, CHAT_CONF_JSON } from '@/utils';
import { chatRoot, APP_CONF_JSON } from '@/utils';
import General from './General';
import MainWindow from './MainWindow';
import TrayWindow from './TrayWindow';
@@ -24,8 +24,8 @@ export default function Settings() {
}, [key]);
useInit(async () => {
setChatConf(await invoke('get_chat_conf'));
setPath(await path.join(await chatRoot(), CHAT_CONF_JSON));
setChatConf(await invoke('get_app_conf'));
setPath(await path.join(await chatRoot(), APP_CONF_JSON));
});
useEffect(() => {
@@ -37,7 +37,7 @@ export default function Settings() {
};
const onReset = async () => {
const chatData = await invoke('reset_chat_conf');
const chatData = await invoke('reset_app_conf');
setChatConf(chatData);
const isOk = await dialog.ask(`Configuration reset successfully, whether to restart?`, {
title: 'ChatGPT Preferences',
@@ -69,7 +69,7 @@ export default function Settings() {
return (
<div>
<FilePath paths={CHAT_CONF_JSON} />
<FilePath paths={APP_CONF_JSON} />
<Form
form={form}
style={{ maxWidth: 500 }}