Skip to content

Commit 4967645

Browse files
Msquittto陈潇文
andauthored
[frontend] 修复应用导出问题 (#6)
* [frontend] 修复应用导出问题 * [frontend] 插件类目去除对话助手 * [frontend] 去除灵感大全多选 * [frontend] 修改引用appId,tenantId方式 --------- Co-authored-by: 陈潇文 <chenxiaowen17@huawei.com>
1 parent 011a405 commit 4967645

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

app-engine/frontend/src/pages/chatPreview/components/inspiration/add-inspiration.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React, { useEffect, useState, useRef, useImperativeHandle } from 'react';
99
import { Form, Input, Drawer, Switch, Table, Popover, Select, Button } from 'antd';
1010
import { QuestionCircleOutlined } from '@ant-design/icons';
11-
import { useParams } from 'react-router-dom';
11+
import { TENANT_ID } from "@/pages/chatPreview/components/send-editor/common/config";
1212
import { uuid } from '@/common/util';
1313
import { useTranslation } from 'react-i18next';
1414
import { addInspiration, editInspiration } from '@/shared/http/aipp';
@@ -19,7 +19,7 @@ import { useAppSelector } from '@/store/hook';
1919
const AddIns = (props) => {
2020
const { t } = useTranslation();
2121
const { addRef, refreshData } = props;
22-
const { tenantId, appId } = useParams();
22+
const appId = useAppSelector((state) => state.appStore.appId);
2323
const [showModal, setShowModal] = useState(false);
2424
const [cachePromptVar, setCachePromptVar] = useState(null);
2525
const [promptVar, setPromptVar] = useState([]);
@@ -67,16 +67,6 @@ const AddIns = (props) => {
6767
</>
6868
)
6969
},
70-
{
71-
title: t('multiple'),
72-
dataIndex: 'multiple',
73-
key: 'multiple',
74-
render: (checked, record) => (
75-
<>
76-
<Switch checked={checked} onChange={(checked) => handleTableChange(checked, record, 'multiple')} />
77-
</>
78-
)
79-
},
8070
{
8171
title: t('operate'),
8272
key: 'action',
@@ -101,7 +91,7 @@ const AddIns = (props) => {
10191
const addCallback = async (params) => {
10292
params.id = uuid();
10393
let parentId = 'root';
104-
const res: any = await addInspiration(tenantId, appId, parentId, params);
94+
const res: any = await addInspiration(TENANT_ID, appId, parentId, params);
10595
if (res.code === 0) {
10696
setShowModal(false);
10797
Message({ type: 'success', content: t('addedSuccessfully') });
@@ -115,7 +105,7 @@ const AddIns = (props) => {
115105
let parentId = '';
116106
let categoryArr = category.current.split(':');
117107
parentId = categoryArr[categoryArr.length - 1] || '';
118-
const res: any = await editInspiration(tenantId, appId, parentId, editId.current, params);
108+
const res: any = await editInspiration(TENANT_ID, appId, parentId, editId.current, params);
119109
if (res.code === 0) {
120110
setShowModal(false);
121111
Message({ type: 'success', content: t('operationSucceeded') });

app-engine/frontend/src/pages/plugin/helper.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ export const minePluginCategories = [
6666
{ key: 'HTTP', label: 'Http' },
6767
{ key: 'LANGCHAIN', label: 'LangChain' },
6868
{ key: 'LLAMAINDEX', label: 'LlamaIndex' },
69-
{ key: 'CHATBOT', label: i18n.t('conversationAssistant') },
70-
// { key: 'AGENT', label: i18n.t('agent') },
7169
{ key: 'WORKFLOW', label: i18n.t('workFlow') },
7270
];
7371

app-engine/frontend/src/shared/http/apps.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { del, get, post, patch } from './http';
88
import serviceConfig from './httpConfig';
99
const { APP_URL } = serviceConfig;
10+
import { getCookie } from '@/shared/utils/common';
1011

1112
// 获取应用市场列表
1213
export function queryAppsApi(tenantId, params) {
@@ -141,19 +142,21 @@ export function getFeedBackData(data) {
141142
// 导出数据
142143
export function exportFeedBackData(data) {
143144
const url = `${APP_URL}/metrics/export`;
144-
var xhr = new XMLHttpRequest();
145+
let xhr = new XMLHttpRequest();
145146
xhr.open('POST', url, true);
146147
xhr.setRequestHeader('Content-Type', 'application/json');
148+
xhr.setRequestHeader('X-Auth-Token', getCookie('__Host-X-Auth-Token'));
149+
xhr.setRequestHeader('X-Csrf-Token', getCookie('__Host-X-Csrf-Token'));
147150
xhr.responseType = 'blob';
148151
xhr.onload = function () {
149152
if (xhr.status === 200) {
150-
var contentDisposition = xhr.getResponseHeader('Content-Disposition');
151-
var match = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
152-
var filename = match[1].replace(/['"]/g, '');
153+
let contentDisposition = xhr.getResponseHeader('Content-Disposition');
154+
let match = contentDisposition.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/);
155+
let filename = match[1].replace(/['"]/g, '');
153156
filename = decodeURI(filename.split('UTF-8')[1]);
154-
var blob = new Blob([xhr.response], { type: 'application/octet-stream' });
155-
var url = URL.createObjectURL(blob);
156-
var a = document.createElement('a');
157+
let blob = new Blob([xhr.response], { type: 'application/octet-stream' });
158+
let url = URL.createObjectURL(blob);
159+
let a = document.createElement('a');
157160
a.href = url;
158161
a.download = filename;
159162
document.body.appendChild(a);
@@ -162,10 +165,9 @@ export function exportFeedBackData(data) {
162165
}
163166
};
164167
xhr.send(JSON.stringify(data));
165-
return post(url, data);
166168
}
167169

168170
// 获取公告
169171
export function getAnnouncement() {
170172
return get(`${APP_URL}/announcement`);
171-
}
173+
}

0 commit comments

Comments
 (0)