|
|
@@ -268,6 +268,8 @@
|
|
|
import type { EChartsType } from 'echarts';
|
|
|
// [perf-base-v1] 卡6: v-html 消毒——marked/katex 输出经公共 DOMPurify 白名单消毒后再进 formatMessage
|
|
|
import { sanitizeHtml } from '/@/utils/markdownSafe';
|
|
|
+ // [perf-base-v1] 卡7: Dify 接口地址配置化,原硬编码 http://39.97.59.228:8000/v1 改走 VUE_APP_URL.difyUrl(开发经 vite proxy /dify 转发)
|
|
|
+ import { difyBase, difyApiKey } from '/@/utils/aiChatApi';
|
|
|
// [perf-base-v1] 卡2b: @vue-office 三组件改异步加载,仅 isShowDoc 预览时才会拉取 office-preview chunk
|
|
|
const VueOfficePdf = defineAsyncComponent(() => import('@vue-office/pdf/lib/v3/vue-office-pdf.mjs'));
|
|
|
const VueOfficeDocx = defineAsyncComponent(() => import('@vue-office/docx/lib/v3/vue-office-docx.mjs'));
|
|
|
@@ -288,7 +290,8 @@
|
|
|
const isShowDoc = ref(false);
|
|
|
const fileType = ref('');
|
|
|
const fileUrl = ref('');
|
|
|
- const APIKEY = ref('Bearer app-tSFRUnv0Qkbtik1dwtlhnpkd');
|
|
|
+ // [perf-base-v1] 卡7: API Key 改从 config.js(VUE_APP_URL.difyApiKey)读取,生产环境应由后端代理下发,勿依赖前端硬编码兜底值
|
|
|
+ const APIKEY = ref('Bearer ' + difyApiKey);
|
|
|
interface ListItem {
|
|
|
id: number;
|
|
|
name?: string;
|
|
|
@@ -555,7 +558,7 @@
|
|
|
message_files.value.push(files);
|
|
|
}
|
|
|
try {
|
|
|
- const response = await fetch('http://39.97.59.228:8000/v1/chat-messages', {
|
|
|
+ const response = await fetch(`${difyBase}/v1/chat-messages`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
@@ -751,7 +754,7 @@
|
|
|
formData.append('user', userid);
|
|
|
|
|
|
try {
|
|
|
- const response = await fetch(`http://39.97.59.228:8000/v1/files/upload`, {
|
|
|
+ const response = await fetch(`${difyBase}/v1/files/upload`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
Authorization: APIKEY.value,
|
|
|
@@ -784,7 +787,7 @@
|
|
|
//停止响应
|
|
|
async function stopReq() {
|
|
|
try {
|
|
|
- let response = await fetch(`http://39.97.59.228:8000/v1/chat-messages/${taskID.value}/stop`, {
|
|
|
+ let response = await fetch(`${difyBase}/v1/chat-messages/${taskID.value}/stop`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
@@ -807,7 +810,7 @@
|
|
|
// 最大重试次数
|
|
|
const maxRetries = API_KEYS.length - 1;
|
|
|
try {
|
|
|
- let response = await fetch(`http://39.97.59.228:8000/v1/messages?conversation_id=${id}&user=${userid}`, {
|
|
|
+ let response = await fetch(`${difyBase}/v1/messages?conversation_id=${id}&user=${userid}`, {
|
|
|
method: 'GET',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
@@ -901,7 +904,7 @@
|
|
|
//停止响应
|
|
|
async function getNextSuggest() {
|
|
|
try {
|
|
|
- let response = await fetch(`http://39.97.59.228:8000/v1/messages/${messageID.value}/suggested?user=${userid}`, {
|
|
|
+ let response = await fetch(`${difyBase}/v1/messages/${messageID.value}/suggested?user=${userid}`, {
|
|
|
method: 'GET',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
@@ -925,7 +928,7 @@
|
|
|
// 保存修改
|
|
|
const handleSave = async (item: ListItem) => {
|
|
|
try {
|
|
|
- let response = await fetch(`http://39.97.59.228:8000/v1/conversations/${item.id}/name`, {
|
|
|
+ let response = await fetch(`${difyBase}/v1/conversations/${item.id}/name`, {
|
|
|
method: 'POST',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
@@ -955,7 +958,7 @@
|
|
|
onOk: async () => {
|
|
|
// 原有删除逻辑不变
|
|
|
try {
|
|
|
- let response = await fetch(`http://39.97.59.228:8000/v1/conversations/${item.id}`, {
|
|
|
+ let response = await fetch(`${difyBase}/v1/conversations/${item.id}`, {
|
|
|
method: 'DELETE',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
@@ -989,7 +992,7 @@
|
|
|
async function getHistoryList() {
|
|
|
sessionHistory.value = [];
|
|
|
try {
|
|
|
- const fetch1 = fetch(`http://39.97.59.228:8000/v1/conversations?user=${userid}`, {
|
|
|
+ const fetch1 = fetch(`${difyBase}/v1/conversations?user=${userid}`, {
|
|
|
method: 'get',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|
|
|
@@ -1004,7 +1007,7 @@
|
|
|
return { data: [] }; // 失败时返回空数组
|
|
|
});
|
|
|
|
|
|
- const fetch2 = fetch(`http://39.97.59.228:8000/v1/conversations?user=${userid}`, {
|
|
|
+ const fetch2 = fetch(`${difyBase}/v1/conversations?user=${userid}`, {
|
|
|
method: 'get',
|
|
|
headers: {
|
|
|
'Content-Type': 'application/json',
|