mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
refactor: app conf
This commit is contained in:
2
src/utils.ts
vendored
2
src/utils.ts
vendored
@@ -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';
|
||||
|
||||
4
src/view/dashboard/index.tsx
vendored
4
src/view/dashboard/index.tsx
vendored
@@ -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');
|
||||
|
||||
10
src/view/settings/index.tsx
vendored
10
src/view/settings/index.tsx
vendored
@@ -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 }}
|
||||
|
||||
Reference in New Issue
Block a user