fix:401、403错误提示,对话角色更改assistant,模型选择持久化
This commit is contained in:
@@ -13,7 +13,7 @@ VITE_WEB_BASE_API = '/dev-api'
|
|||||||
|
|
||||||
# 本地接口
|
# 本地接口
|
||||||
# VITE_API_URL = http://localhost:19001/api/app
|
# VITE_API_URL = http://localhost:19001/api/app
|
||||||
VITE_API_URL=http://ccnetcore.com:19001/api/app
|
VITE_API_URL=http://data.ccnetcore.com:19001/api/app
|
||||||
|
|
||||||
# SSO单点登录url
|
# SSO单点登录url
|
||||||
VITE_SSO_SEVER_URL='http://localhost:18001'
|
VITE_SSO_SEVER_URL='http://localhost:18001'
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ VITE_WEB_ENV = 'production'
|
|||||||
VITE_WEB_BASE_API = '/prod-api'
|
VITE_WEB_BASE_API = '/prod-api'
|
||||||
|
|
||||||
# 本地接口
|
# 本地接口
|
||||||
VITE_API_URL = http://ccnetcore.com:19001/api/app
|
VITE_API_URL = http://data.ccnetcore.com:19001/api/app
|
||||||
|
|
||||||
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
# 是否在打包时开启压缩,支持 gzip 和 brotli
|
||||||
VITE_BUILD_COMPRESS = gzip
|
VITE_BUILD_COMPRESS = gzip
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ async function handleReset() {
|
|||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (error !== 'cancel') {
|
if (error !== 'cancel') {
|
||||||
console.error('重置失败:', error);
|
|
||||||
ElMessage.error('重置失败');
|
ElMessage.error('重置失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { useUserStore } from '@/stores/modules/user';
|
|||||||
|
|
||||||
type MessageItem = BubbleProps & {
|
type MessageItem = BubbleProps & {
|
||||||
key: number;
|
key: number;
|
||||||
role: 'ai' | 'user' | 'system';
|
role: 'ai' | 'user' | 'assistant';
|
||||||
avatar: string;
|
avatar: string;
|
||||||
thinkingStatus?: ThinkingStatus;
|
thinkingStatus?: ThinkingStatus;
|
||||||
thinlCollapse?: boolean;
|
thinlCollapse?: boolean;
|
||||||
@@ -81,8 +81,6 @@ watch(
|
|||||||
const v = localStorage.getItem('chatContent');
|
const v = localStorage.getItem('chatContent');
|
||||||
if (v) {
|
if (v) {
|
||||||
// 发送消息
|
// 发送消息
|
||||||
console.log('发送消息 v', v);
|
|
||||||
console.log('发送消息--error', bubbleItems);
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
startSSE(v);
|
startSSE(v);
|
||||||
}, 350);
|
}, 350);
|
||||||
@@ -181,7 +179,7 @@ async function startSSE(chatContent: string) {
|
|||||||
.slice(-6) // 然后取倒数第2到第7条(总共6条)
|
.slice(-6) // 然后取倒数第2到第7条(总共6条)
|
||||||
.map((item: MessageItem) => ({
|
.map((item: MessageItem) => ({
|
||||||
role: item.role,
|
role: item.role,
|
||||||
content: (item.role === 'ai' || item.role === 'system') && item.content.length > 2000
|
content: (item.role === 'ai' || item.role === 'assistant') && item.content.length > 2000
|
||||||
? `${item.content.substring(0, 2000)}...(内容过长,已省略)`
|
? `${item.content.substring(0, 2000)}...(内容过长,已省略)`
|
||||||
: item.content,
|
: item.content,
|
||||||
})),
|
})),
|
||||||
@@ -222,7 +220,7 @@ function addMessage(message: string, isUser: boolean) {
|
|||||||
? avatar.value
|
? avatar.value
|
||||||
: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||||
avatarSize: '32px',
|
avatarSize: '32px',
|
||||||
role: isUser ? 'user' : 'system',
|
role: isUser ? 'user' : 'assistant',
|
||||||
placement: isUser ? 'end' : 'start',
|
placement: isUser ? 'end' : 'start',
|
||||||
isMarkdown: !isUser,
|
isMarkdown: !isUser,
|
||||||
loading: !isUser,
|
loading: !isUser,
|
||||||
|
|||||||
@@ -4,21 +4,21 @@ import { getModelList } from '@/api';
|
|||||||
|
|
||||||
// 模型管理
|
// 模型管理
|
||||||
export const useModelStore = defineStore('model', () => {
|
export const useModelStore = defineStore('model', () => {
|
||||||
// 当前模型
|
// 当前模型(需要持久化)
|
||||||
const currentModelInfo = ref<GetSessionListVO>({});
|
const currentModelInfo = ref<GetSessionListVO>({});
|
||||||
|
|
||||||
|
// 模型菜单列表(不需要持久化)
|
||||||
|
const modelList = ref<GetSessionListVO[]>([]);
|
||||||
|
|
||||||
// 设置当前模型
|
// 设置当前模型
|
||||||
const setCurrentModelInfo = (modelInfo: GetSessionListVO) => {
|
const setCurrentModelInfo = (modelInfo: GetSessionListVO) => {
|
||||||
currentModelInfo.value = modelInfo;
|
currentModelInfo.value = modelInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 模型菜单列表
|
|
||||||
const modelList = ref<GetSessionListVO[]>([]);
|
|
||||||
// 请求模型菜单列表
|
// 请求模型菜单列表
|
||||||
const requestModelList = async () => {
|
const requestModelList = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await getModelList();
|
const res = await getModelList();
|
||||||
console.log('res', res);
|
|
||||||
modelList.value = res.data;
|
modelList.value = res.data;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -32,4 +32,8 @@ export const useModelStore = defineStore('model', () => {
|
|||||||
modelList,
|
modelList,
|
||||||
requestModelList,
|
requestModelList,
|
||||||
};
|
};
|
||||||
|
}, {
|
||||||
|
persist: {
|
||||||
|
paths: ['currentModelInfo'], // 只持久化 currentModelInfo
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ function jwtPlugin(): {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (response.result?.code === 401) {
|
if (response.result?.code === 401) {
|
||||||
|
ElMessage.error('登录已过期,请重新登录');
|
||||||
userStore.logout();
|
userStore.logout();
|
||||||
userStore.openLoginDialog();
|
userStore.openLoginDialog();
|
||||||
}
|
}
|
||||||
@@ -118,9 +119,17 @@ function jwtPlugin(): {
|
|||||||
|
|
||||||
onError: async (error) => {
|
onError: async (error) => {
|
||||||
if (error.status === 403) {
|
if (error.status === 403) {
|
||||||
|
const data = await (error.response.json());
|
||||||
// 弹窗提示
|
// 弹窗提示
|
||||||
ElMessage.error('业务错误,请稍后再试');
|
ElMessage.error(data.error.message);
|
||||||
console.error('Fetch error:', error);
|
return Promise.reject(data);
|
||||||
|
}
|
||||||
|
if (error.status === 401) {
|
||||||
|
ElMessage.error('登录已过期,请重新登录!');
|
||||||
|
|
||||||
|
// 弹窗提示
|
||||||
|
userStore.logout();
|
||||||
|
userStore.openLoginDialog();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
4
Yi.Ai.Vue3/types/components.d.ts
vendored
4
Yi.Ai.Vue3/types/components.d.ts
vendored
@@ -11,13 +11,9 @@ declare module 'vue' {
|
|||||||
AccountPassword: typeof import('./../src/components/LoginDialog/components/FormLogin/AccountPassword.vue')['default']
|
AccountPassword: typeof import('./../src/components/LoginDialog/components/FormLogin/AccountPassword.vue')['default']
|
||||||
APIKeyManagement: typeof import('./../src/components/userPersonalCenter/components/APIKeyManagement.vue')['default']
|
APIKeyManagement: typeof import('./../src/components/userPersonalCenter/components/APIKeyManagement.vue')['default']
|
||||||
DeepThinking: typeof import('./../src/components/DeepThinking/index.vue')['default']
|
DeepThinking: typeof import('./../src/components/DeepThinking/index.vue')['default']
|
||||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
|
||||||
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
ElAvatar: typeof import('element-plus/es')['ElAvatar']
|
||||||
ElButton: typeof import('element-plus/es')['ElButton']
|
ElButton: typeof import('element-plus/es')['ElButton']
|
||||||
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
|
ElButtonGroup: typeof import('element-plus/es')['ElButtonGroup']
|
||||||
ElCard: typeof import('element-plus/es')['ElCard']
|
|
||||||
ElCollapse: typeof import('element-plus/es')['ElCollapse']
|
|
||||||
ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
|
|
||||||
ElContainer: typeof import('element-plus/es')['ElContainer']
|
ElContainer: typeof import('element-plus/es')['ElContainer']
|
||||||
ElDialog: typeof import('element-plus/es')['ElDialog']
|
ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||||
ElDivider: typeof import('element-plus/es')['ElDivider']
|
ElDivider: typeof import('element-plus/es')['ElDivider']
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ onUnmounted(() => removeMatchMedia);
|
|||||||
<Segmented
|
<Segmented
|
||||||
resize
|
resize
|
||||||
class="select-none"
|
class="select-none"
|
||||||
:modelValue="overallStyle === 'system' ? 2 : dataTheme ? 1 : 0"
|
:modelValue="overallStyle === 'assistant' ? 2 : dataTheme ? 1 : 0"
|
||||||
:options="themeOptions"
|
:options="themeOptions"
|
||||||
@change="
|
@change="
|
||||||
theme => {
|
theme => {
|
||||||
|
|||||||
Reference in New Issue
Block a user