diff --git a/components.d.ts b/components.d.ts
index 23bb044..01a7db1 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -11,7 +11,6 @@ declare module 'vue' {
MarkdownRender: typeof import('./src/components/MarkdownRender.vue')['default']
NAlert: typeof import('naive-ui')['NAlert']
NButton: typeof import('naive-ui')['NButton']
- NButtonGroup: typeof import('naive-ui')['NButtonGroup']
NCard: typeof import('naive-ui')['NCard']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
diff --git a/src/common/customError.ts b/src/common/customError.ts
index 57879c5..0c936e3 100644
--- a/src/common/customError.ts
+++ b/src/common/customError.ts
@@ -6,3 +6,7 @@ export class CustomError extends Error {
super();
}
}
+
+export enum ErrorCodes {
+ MISSING_GPT_CONFIG = 999,
+}
diff --git a/src/electron/preload.ts b/src/electron/preload.ts
index 212b2a6..9e4cd24 100644
--- a/src/electron/preload.ts
+++ b/src/electron/preload.ts
@@ -13,7 +13,8 @@ contextBridge.exposeInMainWorld('storeAPI', {
ipcRenderer.invoke('storeAPI', { method: 'GET', key, value: defaultValue }),
set: async (key: string, value: unknown) =>
ipcRenderer.invoke('storeAPI', { method: 'SET', key, value }),
- getSecret: async (key: string) => ipcRenderer.invoke('storeAPI', { method: 'GET_SECRET', key }),
+ getSecret: async (key: string, value: unknown) =>
+ ipcRenderer.invoke('storeAPI', { method: 'GET_SECRET', key, value }),
setSecret: async (key: string, value: unknown) =>
ipcRenderer.invoke('storeAPI', { method: 'SET_SECRET', key, value }),
});
diff --git a/src/electron/storeApi.ts b/src/electron/storeApi.ts
index f72b49f..919c83b 100644
--- a/src/electron/storeApi.ts
+++ b/src/electron/storeApi.ts
@@ -53,10 +53,10 @@ const storeApi: { [key: string]: (key: string, val: unknown) => unknown } = {
store.set(key, value);
},
- get_secret: (key: string) => {
+ get_secret: (key: string, defaultValue: unknown) => {
const encryptedValue = store.get(key, '');
- return encryptedValue ? JSON.parse(decryptValue(encryptedValue as string)) : undefined;
+ return encryptedValue ? JSON.parse(decryptValue(encryptedValue as string)) : defaultValue;
},
set_secret: (key: string, value: unknown) => {
diff --git a/src/lang/zhCN.ts b/src/lang/zhCN.ts
index f900317..ad47c50 100644
--- a/src/lang/zhCN.ts
+++ b/src/lang/zhCN.ts
@@ -18,6 +18,7 @@ export const zhCN = {
light: '月白主题',
ai: {
title: 'GPTs配置',
+ configGpt: '前往配置GPT',
others: '其他GPTs',
model: '模型',
modelPlaceholder: '请输入GPT模型名称',
diff --git a/src/layout/components/chatbot-box.vue b/src/layout/components/chatbot-box.vue
index ae8921e..7cd4b2e 100644
--- a/src/layout/components/chatbot-box.vue
+++ b/src/layout/components/chatbot-box.vue
@@ -23,6 +23,15 @@
{{ chatBotNotification.message }}
+
+ {{ $t('setting.ai.configGpt') }}
@@ -54,21 +63,25 @@ import { storeToRefs } from 'pinia';
import { Bot, SendAlt, FaceCool } from '@vicons/carbon';
import { ChatMessageRole, useChatStore } from '../../store';
import MarkdownRender from '../../components/MarkdownRender.vue';
+import { ErrorCodes } from '../../common';
const chatStore = useChatStore();
const { chats } = storeToRefs(chatStore);
const { sendMessage, fetchChats } = chatStore;
+const router = useRouter();
+
const scrollbarRef = ref(null);
const chatMsg = ref(''); // 聊天消息
const chatBotNotification = ref({
enabled: false,
level: '',
message: '',
+ code: 0,
});
// 提交消息
const submitMsg = () => {
- chatBotNotification.value = { enabled: false, level: '', message: '' };
+ chatBotNotification.value = { enabled: false, level: '', message: '', code: 0 };
if (!chatMsg.value.trim().length) return;
sendMessage(chatMsg.value)
.catch(err => {
@@ -76,6 +89,7 @@ const submitMsg = () => {
enabled: true,
level: 'error',
message: err.message,
+ code: 0,
};
})
.finally(() => {
@@ -83,6 +97,11 @@ const submitMsg = () => {
});
chatMsg.value = '';
};
+
+const configGpt = () => {
+ router.push({ path: '/setting', replace: true });
+};
+
fetchChats()
.then(() => {
scrollbarRef.value.scrollTo({ top: 999999 });
@@ -91,7 +110,8 @@ fetchChats()
chatBotNotification.value = {
enabled: true,
level: 'error',
- message: err.message,
+ message: err.details,
+ code: err.status,
};
});
diff --git a/src/layout/components/tool-bar-right.vue b/src/layout/components/tool-bar-right.vue
index 2d94707..c0e8a37 100644
--- a/src/layout/components/tool-bar-right.vue
+++ b/src/layout/components/tool-bar-right.vue
@@ -22,7 +22,6 @@