Compare commits
No commits in common. "752a7029b936c0cc29b21f4ad6bea67850ae4b18" and "a08474d32c28e22f2083d075a570d7682f6d7054" have entirely different histories.
752a7029b9
...
a08474d32c
@ -7,7 +7,7 @@ import VueOfficePptx from '@vue-office/pptx';
|
|||||||
|
|
||||||
// import '@vue-office/pptx/lib/index.css';
|
// import '@vue-office/pptx/lib/index.css';
|
||||||
// http://47.112.173.8:6802/static/66f3cfd95e364a239d8036390db658ae.pptx
|
// http://47.112.173.8:6802/static/66f3cfd95e364a239d8036390db658ae.pptx
|
||||||
// const url = ref('');
|
const url = ref('');
|
||||||
const pptx = ref('/pptx/66f3cfd95e364a239d8036390db658ae.pptx');
|
const pptx = ref('/pptx/66f3cfd95e364a239d8036390db658ae.pptx');
|
||||||
const pptStyle = ref({
|
const pptStyle = ref({
|
||||||
height: 'calc(100vh - 100px)',
|
height: 'calc(100vh - 100px)',
|
||||||
@ -30,11 +30,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
|
|||||||
},
|
},
|
||||||
onOpenChange(isOpen: boolean) {
|
onOpenChange(isOpen: boolean) {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
const data = drawerApi.getData<Record<string, any>>();
|
url.value = drawerApi.getData<Record<string, any>>();
|
||||||
if (data) {
|
|
||||||
pptx.value = `/pptx/${data}`; // 更新 docx 的值
|
|
||||||
}
|
|
||||||
// url.value = drawerApi.getData<Record<string, any>>();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -48,7 +48,7 @@ defineOptions({
|
|||||||
name: 'SpiderWorkView',
|
name: 'SpiderWorkView',
|
||||||
});
|
});
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
withDefaults(defineProps<Props>(), {
|
||||||
item: () => null,
|
item: () => null,
|
||||||
runWorkflow: () => async () => ({
|
runWorkflow: () => async () => ({
|
||||||
data: {
|
data: {
|
||||||
@ -65,12 +65,8 @@ const [PreviewDrawer, previewDrawerApi] = useVbenDrawer({
|
|||||||
// placement: 'left',
|
// placement: 'left',
|
||||||
});
|
});
|
||||||
|
|
||||||
function openPreviewDrawer(
|
function openPreviewDrawer(placement: DrawerPlacement = 'right') {
|
||||||
placement: DrawerPlacement = 'right',
|
previewDrawerApi.setState({ placement }).open();
|
||||||
filename?: string,
|
|
||||||
) {
|
|
||||||
const fileData = filename.value;
|
|
||||||
previewDrawerApi.setState({ placement }).setData(fileData).open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const startFetching = async () => {
|
const startFetching = async () => {
|
||||||
@ -78,43 +74,21 @@ const startFetching = async () => {
|
|||||||
fetchStatus.value = 'fetching';
|
fetchStatus.value = 'fetching';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await props.runWorkflow(
|
// const res = await props.runWorkflow(
|
||||||
{
|
// {
|
||||||
appid: 'ee3889b6-50fa-463e-b956-3b93447727fc',
|
// appid: props.item.id,
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
userId: '1562',
|
// userId: '1562',
|
||||||
conversationId: '',
|
// conversationId: '',
|
||||||
files: [],
|
// files: [],
|
||||||
inputs: {
|
// inputs: {
|
||||||
declarationDoc: value.value,
|
// declarationDoc: value.value,
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
);
|
// );
|
||||||
const { result } = res.data.outputs;
|
|
||||||
|
|
||||||
// 判断是否是以 .pptx 结尾的 URL
|
|
||||||
function isPptxURL(str: string): boolean {
|
|
||||||
return str.endsWith('.pptx');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用正则提取 /static/ 后面的文件名部分
|
|
||||||
function extractPptxFilename(url: string): null | string {
|
|
||||||
const match = url.match(/\/static\/([a-f0-9-]+\.pptx)$/i);
|
|
||||||
if (match) {
|
|
||||||
return match[1]; // 返回类似:9e1c421e-991c-411f-8176-6350a97e70f3.pptx
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filename = ref('');
|
|
||||||
|
|
||||||
if (result && isPptxURL(result)) {
|
|
||||||
filename.value = extractPptxFilename(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 保存抓取结果 url http://47.112.173.8:6802/static/66f3cfd95e364a239d8036390db658ae.pptx
|
// 保存抓取结果 url http://47.112.173.8:6802/static/66f3cfd95e364a239d8036390db658ae.pptx
|
||||||
fetchResult.value = `/static/${filename.value}`;
|
fetchResult.value = '/static/66f3cfd95e364a239d8036390db658ae.pptx';
|
||||||
resultItems.value.push({
|
resultItems.value.push({
|
||||||
key: resultItems.value.length + 1,
|
key: resultItems.value.length + 1,
|
||||||
role: 'ai',
|
role: 'ai',
|
||||||
@ -126,7 +100,7 @@ const startFetching = async () => {
|
|||||||
size: 'nomarl',
|
size: 'nomarl',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openPreviewDrawer('right', filename);
|
openPreviewDrawer('right');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'文档预览',
|
'文档预览',
|
||||||
@ -139,15 +113,7 @@ const startFetching = async () => {
|
|||||||
style: {
|
style: {
|
||||||
marginLeft: '10px',
|
marginLeft: '10px',
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {},
|
||||||
// 创建隐藏的 <a> 标签用于触发下载
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = result; // 设置下载链接
|
|
||||||
link.download = filename; // 设置下载文件名
|
|
||||||
document.body.append(link); // 将 <a> 标签添加到页面中
|
|
||||||
link.click(); // 触发点击事件开始下载
|
|
||||||
link.remove(); // 下载完成后移除 <a> 标签
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
'文档下载',
|
'文档下载',
|
||||||
),
|
),
|
||||||
|
@ -7,8 +7,8 @@ import VueOfficeDocx from '@vue-office/docx';
|
|||||||
|
|
||||||
import '@vue-office/docx/lib/index.css';
|
import '@vue-office/docx/lib/index.css';
|
||||||
|
|
||||||
// const url = ref('');
|
const url = ref('');
|
||||||
const docx = ref<any>(`/docx/027c6b7c-fea6-4964-839b-27857c4d3181.docx`);
|
const docx = ref<any>('/docx/027c6b7c-fea6-4964-839b-27857c4d3181.docx');
|
||||||
const pptStyle = ref({
|
const pptStyle = ref({
|
||||||
height: 'calc(100vh - 100px)',
|
height: 'calc(100vh - 100px)',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@ -29,11 +29,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
|
|||||||
},
|
},
|
||||||
onOpenChange(isOpen: boolean) {
|
onOpenChange(isOpen: boolean) {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
const data = drawerApi.getData<Record<string, any>>();
|
url.value = drawerApi.getData<Record<string, any>>();
|
||||||
if (data) {
|
|
||||||
docx.value = `/docx/${data}`; // 更新 docx 的值
|
|
||||||
}
|
|
||||||
// url.value = drawerApi.getData<Record<string, any>>();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -67,12 +67,9 @@ const [PreviewDrawer, previewDrawerApi] = useVbenDrawer({
|
|||||||
connectedComponent: WordPreview,
|
connectedComponent: WordPreview,
|
||||||
// placement: 'left',
|
// placement: 'left',
|
||||||
});
|
});
|
||||||
function openPreviewDrawer(
|
|
||||||
placement: DrawerPlacement = 'right',
|
function openPreviewDrawer(placement: DrawerPlacement = 'right') {
|
||||||
filename?: string,
|
previewDrawerApi.setState({ placement }).open();
|
||||||
) {
|
|
||||||
const fileData = filename.value;
|
|
||||||
previewDrawerApi.setState({ placement }).setData(fileData).open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const startFetching = async () => {
|
const startFetching = async () => {
|
||||||
@ -114,29 +111,7 @@ const startFetching = async () => {
|
|||||||
content: value.value || '',
|
content: value.value || '',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const { answer } = res;
|
fetchResult.value = '/static/9e1c421e-991c-411f-8176-6350a97e70f3.docx';
|
||||||
|
|
||||||
// 判断是否是以 .docx 结尾的 URL
|
|
||||||
function isDocxURL(str: string): boolean {
|
|
||||||
return str.endsWith('.docx');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 使用正则提取 /static/ 后面的文件名部分
|
|
||||||
function extractDocxFilename(url: string): null | string {
|
|
||||||
const match = url.match(/\/static\/([a-f0-9-]+\.docx)$/i);
|
|
||||||
if (match) {
|
|
||||||
return match[1]; // 返回类似:9e1c421e-991c-411f-8176-6350a97e70f3.docx
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const filename = ref('');
|
|
||||||
|
|
||||||
if (answer && isDocxURL(answer)) {
|
|
||||||
filename.value = extractDocxFilename(answer);
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchResult.value = `/static/${filename.value}`;
|
|
||||||
resultItems.value.push({
|
resultItems.value.push({
|
||||||
key: resultItems.value.length + 1,
|
key: resultItems.value.length + 1,
|
||||||
role: 'ai',
|
role: 'ai',
|
||||||
@ -148,7 +123,7 @@ const startFetching = async () => {
|
|||||||
size: 'nomarl',
|
size: 'nomarl',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openPreviewDrawer('right', filename);
|
openPreviewDrawer('right');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'文档预览',
|
'文档预览',
|
||||||
@ -161,15 +136,7 @@ const startFetching = async () => {
|
|||||||
style: {
|
style: {
|
||||||
marginLeft: '10px',
|
marginLeft: '10px',
|
||||||
},
|
},
|
||||||
onClick: () => {
|
onClick: () => {},
|
||||||
// 创建隐藏的 <a> 标签用于触发下载
|
|
||||||
const link = document.createElement('a');
|
|
||||||
link.href = answer; // 设置下载链接
|
|
||||||
link.download = filename; // 设置下载文件名
|
|
||||||
document.body.append(link); // 将 <a> 标签添加到页面中
|
|
||||||
link.click(); // 触发点击事件开始下载
|
|
||||||
link.remove(); // 下载完成后移除 <a> 标签
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
'文档下载',
|
'文档下载',
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user