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://ccnetcore.com:19001/api/app
|
||||
VITE_API_URL=http://data.ccnetcore.com:19001/api/app
|
||||
|
||||
# SSO单点登录url
|
||||
VITE_SSO_SEVER_URL='http://localhost:18001'
|
||||
|
||||
@@ -11,7 +11,7 @@ VITE_WEB_ENV = 'production'
|
||||
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
|
||||
VITE_BUILD_COMPRESS = gzip
|
||||
|
||||
@@ -102,7 +102,6 @@ async function handleReset() {
|
||||
}
|
||||
catch (error) {
|
||||
if (error !== 'cancel') {
|
||||
console.error('重置失败:', error);
|
||||
ElMessage.error('重置失败');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import { useUserStore } from '@/stores/modules/user';
|
||||
|
||||
type MessageItem = BubbleProps & {
|
||||
key: number;
|
||||
role: 'ai' | 'user' | 'system';
|
||||
role: 'ai' | 'user' | 'assistant';
|
||||
avatar: string;
|
||||
thinkingStatus?: ThinkingStatus;
|
||||
thinlCollapse?: boolean;
|
||||
@@ -81,8 +81,6 @@ watch(
|
||||
const v = localStorage.getItem('chatContent');
|
||||
if (v) {
|
||||
// 发送消息
|
||||
console.log('发送消息 v', v);
|
||||
console.log('发送消息--error', bubbleItems);
|
||||
setTimeout(() => {
|
||||
startSSE(v);
|
||||
}, 350);
|
||||
@@ -181,7 +179,7 @@ async function startSSE(chatContent: string) {
|
||||
.slice(-6) // 然后取倒数第2到第7条(总共6条)
|
||||
.map((item: MessageItem) => ({
|
||||
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,
|
||||
})),
|
||||
@@ -222,7 +220,7 @@ function addMessage(message: string, isUser: boolean) {
|
||||
? avatar.value
|
||||
: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
|
||||
avatarSize: '32px',
|
||||
role: isUser ? 'user' : 'system',
|
||||
role: isUser ? 'user' : 'assistant',
|
||||
placement: isUser ? 'end' : 'start',
|
||||
isMarkdown: !isUser,
|
||||
loading: !isUser,
|
||||
|
||||
@@ -4,21 +4,21 @@ import { getModelList } from '@/api';
|
||||
|
||||
// 模型管理
|
||||
export const useModelStore = defineStore('model', () => {
|
||||
// 当前模型
|
||||
// 当前模型(需要持久化)
|
||||
const currentModelInfo = ref<GetSessionListVO>({});
|
||||
|
||||
// 模型菜单列表(不需要持久化)
|
||||
const modelList = ref<GetSessionListVO[]>([]);
|
||||
|
||||
// 设置当前模型
|
||||
const setCurrentModelInfo = (modelInfo: GetSessionListVO) => {
|
||||
currentModelInfo.value = modelInfo;
|
||||
};
|
||||
|
||||
// 模型菜单列表
|
||||
const modelList = ref<GetSessionListVO[]>([]);
|
||||
// 请求模型菜单列表
|
||||
const requestModelList = async () => {
|
||||
try {
|
||||
const res = await getModelList();
|
||||
console.log('res', res);
|
||||
modelList.value = res.data;
|
||||
}
|
||||
catch (error) {
|
||||
@@ -32,4 +32,8 @@ export const useModelStore = defineStore('model', () => {
|
||||
modelList,
|
||||
requestModelList,
|
||||
};
|
||||
}, {
|
||||
persist: {
|
||||
paths: ['currentModelInfo'], // 只持久化 currentModelInfo
|
||||
},
|
||||
});
|
||||
|
||||
@@ -108,6 +108,7 @@ function jwtPlugin(): {
|
||||
}
|
||||
|
||||
if (response.result?.code === 401) {
|
||||
ElMessage.error('登录已过期,请重新登录');
|
||||
userStore.logout();
|
||||
userStore.openLoginDialog();
|
||||
}
|
||||
@@ -118,9 +119,17 @@ function jwtPlugin(): {
|
||||
|
||||
onError: async (error) => {
|
||||
if (error.status === 403) {
|
||||
const data = await (error.response.json());
|
||||
// 弹窗提示
|
||||
ElMessage.error('业务错误,请稍后再试');
|
||||
console.error('Fetch error:', error);
|
||||
ElMessage.error(data.error.message);
|
||||
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']
|
||||
APIKeyManagement: typeof import('./../src/components/userPersonalCenter/components/APIKeyManagement.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']
|
||||
ElButton: typeof import('element-plus/es')['ElButton']
|
||||
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']
|
||||
ElDialog: typeof import('element-plus/es')['ElDialog']
|
||||
ElDivider: typeof import('element-plus/es')['ElDivider']
|
||||
|
||||
Reference in New Issue
Block a user