refactor(@vben/web-antd): 优化 Word模块的属性定义和类型安全
- 修改 typing.ts 中的 Props接口 - 优化 extractDocxInfo 函数的返回类型,增加对 filename 的 undefined 支持
This commit is contained in:
parent
2dd824324f
commit
655eca8e4d
@ -7,7 +7,7 @@ import type {
|
|||||||
|
|
||||||
import type { DrawerPlacement } from '@vben/common-ui';
|
import type { DrawerPlacement } from '@vben/common-ui';
|
||||||
|
|
||||||
import type { Props, ResultItem, WordTempItem } from '../typing';
|
import type { Props, ResultItem } from '../typing';
|
||||||
|
|
||||||
import { computed, h, ref, watch } from 'vue';
|
import { computed, h, ref, watch } from 'vue';
|
||||||
|
|
||||||
@ -42,13 +42,16 @@ import WordPreview from './word-preview.vue';
|
|||||||
defineOptions({ name: 'WordWorkView' });
|
defineOptions({ name: 'WordWorkView' });
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
item: {
|
item: () => {
|
||||||
|
return {
|
||||||
id: '',
|
id: '',
|
||||||
name: '',
|
name: '',
|
||||||
} as WordTempItem,
|
};
|
||||||
|
},
|
||||||
itemMessage: Array,
|
itemMessage: Array,
|
||||||
paramsData: Array,
|
paramsData: Array,
|
||||||
runChatFlow: () => async () => ({
|
runChatFlow: () => {
|
||||||
|
return {
|
||||||
event: '',
|
event: '',
|
||||||
conversationId: '',
|
conversationId: '',
|
||||||
messageFiles: [],
|
messageFiles: [],
|
||||||
@ -56,12 +59,15 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
taskId: '',
|
taskId: '',
|
||||||
id: '',
|
id: '',
|
||||||
answer: '',
|
answer: '',
|
||||||
}),
|
};
|
||||||
projectInfo: {
|
},
|
||||||
projectName: '',
|
projectInfo: () => {
|
||||||
|
return {
|
||||||
projectContext: '',
|
projectContext: '',
|
||||||
projectKeyAvoidTechOrKeyword: '',
|
projectKeyAvoidTechOrKeyword: '',
|
||||||
|
projectName: '',
|
||||||
userInitialInnovationPoint: '',
|
userInitialInnovationPoint: '',
|
||||||
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -182,7 +188,7 @@ function openPreviewDrawer(
|
|||||||
// ==================== Event ====================
|
// ==================== Event ====================
|
||||||
function extractDocxInfo(
|
function extractDocxInfo(
|
||||||
markdownLink: string,
|
markdownLink: string,
|
||||||
): null | { filename: string; url: string } {
|
): null | { filename: string | undefined; url: string } {
|
||||||
const fileRegex = /\[(.*?)\]/;
|
const fileRegex = /\[(.*?)\]/;
|
||||||
const urlRegex = /\((.*?)\)/;
|
const urlRegex = /\((.*?)\)/;
|
||||||
const fileMatch = markdownLink.match(fileRegex);
|
const fileMatch = markdownLink.match(fileRegex);
|
||||||
@ -254,7 +260,6 @@ const startFetching = async () => {
|
|||||||
h(
|
h(
|
||||||
Button,
|
Button,
|
||||||
{
|
{
|
||||||
size: 'normal',
|
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openPreviewDrawer('right', url);
|
openPreviewDrawer('right', url);
|
||||||
@ -265,13 +270,12 @@ const startFetching = async () => {
|
|||||||
h(
|
h(
|
||||||
Button,
|
Button,
|
||||||
{
|
{
|
||||||
size: 'normal',
|
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
style: { marginLeft: '10px' },
|
style: { marginLeft: '10px' },
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.download = filename;
|
link.download = filename as string;
|
||||||
document.body.append(link);
|
document.body.append(link);
|
||||||
link.click();
|
link.click();
|
||||||
link.remove();
|
link.remove();
|
||||||
@ -321,7 +325,6 @@ watch(
|
|||||||
h(
|
h(
|
||||||
Button,
|
Button,
|
||||||
{
|
{
|
||||||
size: 'normal',
|
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
openPreviewDrawer('right', url);
|
openPreviewDrawer('right', url);
|
||||||
@ -332,7 +335,6 @@ watch(
|
|||||||
h(
|
h(
|
||||||
Button,
|
Button,
|
||||||
{
|
{
|
||||||
size: 'normal',
|
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
style: { marginLeft: '10px' },
|
style: { marginLeft: '10px' },
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
|
@ -48,7 +48,7 @@ interface WorkflowResult {
|
|||||||
}
|
}
|
||||||
interface Props {
|
interface Props {
|
||||||
itemMessage?: ResultItem[];
|
itemMessage?: ResultItem[];
|
||||||
item?: null | WordTempItem;
|
item?: WordTempItem;
|
||||||
paramsData?: string[];
|
paramsData?: string[];
|
||||||
runChatFlow?: (
|
runChatFlow?: (
|
||||||
appId: null | string,
|
appId: null | string,
|
||||||
|
Loading…
Reference in New Issue
Block a user