Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ui/src/assets/workflow/icon_image-generate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions ui/src/assets/workflow/icon_image-understand.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions ui/src/assets/workflow/icon_image_to_video.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/src/assets/workflow/icon_question.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions ui/src/assets/workflow/icon_speech_to_text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions ui/src/assets/workflow/icon_text_to_speech.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions ui/src/assets/workflow/icon_text_to_video.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/src/assets/workflow/icon_video-understand.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion ui/src/components/COMPONENT_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ Element Plus 使用 `ElOnlyChild` 处理浮层触发器。`el-tooltip`、`el-pop
基于 `md-editor-v3` 的全局自动注册组件。三个组件统一使用 User Store 中的当前语言,并为繁体中文
加载 `zh-TW` 语言包;底层组件的 Props 和事件通过 `$attrs` 透传。`MdEditor` 默认关闭 Prettier,
并透传 `defFooters` 插槽;`MdEditorMagnify` 在无工具栏编辑器的页脚提供放大按钮,弹窗中点击确定
才会写回内容并触发 `submitDialog`,取消或关闭弹窗会丢弃本次弹窗编辑;`MdPreview` 默认关闭代码
才会写回内容并触发 `submitDialog`,取消或关闭弹窗会丢弃本次弹窗编辑。组件位于配置了字段和规则的
`el-form-item` 中时,会像 `el-input` 一样按 `change`、`blur` 触发规则校验;未配置字段或规则时跳过,
传入 `:validate-event="false"` 可关闭自动校验。`MdPreview` 默认关闭代码
折叠。Admin 和 Chat 入口统一调用
`configureMarkdownEditor()`,将代码高亮、全屏、KaTeX、图片裁剪、Mermaid、ECharts 和 Prettier
配置为本地实例,避免运行时加载 CDN 资源;`md-editor-v3` v6 的图标已随依赖打包,不再维护或加载
Expand Down
28 changes: 24 additions & 4 deletions ui/src/components/global/markdown-editor/MdEditorMagnify.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
<script setup lang="ts">
import { ref } from 'vue'
import { nextTick, ref, watch } from 'vue'
import { useFormItem } from 'element-plus'
import type { Footers } from 'md-editor-v3'

defineOptions({ name: 'MdEditorMagnify', inheritAttrs: false })

const modelValue = defineModel<string>({ required: true })
defineProps<{ title: string }>()
const props = withDefaults(defineProps<{ title: string; validateEvent?: boolean }>(), { validateEvent: true })

const emit = defineEmits<{ submitDialog: [content: string] }>()
const { formItem } = useFormItem()

const footers: Footers[] = ['=', 0]
const dialogVisible = ref(false)
const dialogContent = ref('')

// 仅接入配置了字段的 FormItem;规则及 trigger 是否匹配由 FormItem 自身判定。
function validateFormItem(trigger: 'blur' | 'change') {
if (!props.validateEvent || !formItem?.propString) return
formItem.validate(trigger).catch(() => {})
}

watch(modelValue, () => validateFormItem('change'))

function openEditorDialog() {
dialogContent.value = modelValue.value
dialogVisible.value = true
Expand All @@ -22,15 +32,25 @@ function closeEditorDialog() {
dialogVisible.value = false
}

function submitEditorDialog() {
async function submitEditorDialog() {
modelValue.value = dialogContent.value
emit('submitDialog', dialogContent.value)
closeEditorDialog()
await nextTick()
validateFormItem('blur')
}
</script>

<template>
<MdEditor v-model="modelValue" :preview="false" :toolbars="[]" :footers="footers" class="magnify-md-editor" v-bind="$attrs">
<MdEditor
v-model="modelValue"
:preview="false"
:toolbars="[]"
:footers="footers"
class="magnify-md-editor"
v-bind="$attrs"
@blur="validateFormItem('blur')"
>
<template #defFooters>
<el-button text @click="openEditorDialog" class="mr-1 mb-1">
<MkIcon name="icon_magnify_outlined" />
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/global/markdown-editor/md-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
font-weight: 400;
line-height: 22px;
font-family: var(--mk-font-family) !important;
height: 150px;
height: 130px;

.cm-content {
color: var(--mk-N900);
Expand Down
1 change: 1 addition & 0 deletions ui/src/styles/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
--color-success: var(--mk-success);
--color-warning: var(--mk-warning);
--color-purple: var(--mk-purple);
--color-blue: var(--mk-blue);
--color-N100: var(--mk-N100);
--color-N300: var(--mk-N300);
--color-N350: var(--mk-N350);
Expand Down
1 change: 1 addition & 0 deletions ui/src/styles/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// );

--mk-purple: #7f3bf5;
--mk-blue: #14c0ff;
// 用于背景底色。
--mk-N100: #f5f6f7;
--mk-N100-rgb: 245 246 247;
Expand Down
76 changes: 18 additions & 58 deletions ui/src/views/workflow/application/ApplicationWorkflowView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,56 +140,22 @@ function loadApplicationDetail() {
}

/* 发布工作流 */
// const canPublish = computed(() => perm.application.workspace.publish(applicationId))
// function getValidationMessage(error: unknown) {
// if (typeof error === 'string') return error
// if (error instanceof Error) return error.message
// if (!error || typeof error !== 'object') return '工作流校验失败'

// const validationError = error as {
// errMessage?: unknown
// node?: { properties?: { stepName?: string } }
// }
// const stepName = validationError.node?.properties?.stepName
// const message =
// typeof validationError.errMessage === 'string' ? validationError.errMessage : '工作流配置不完整'

// return stepName ? `${stepName} 节点,${message}` : message
// }

// function validateWorkflow() {
// const graphData = getGraphData()
// if (!graphData) return Promise.resolve<LogicFlow.GraphData | undefined>(undefined)

// return (workflowRef.value?.validate() ?? Promise.resolve([]))
// .then(() => {
// type ValidationGraph = ConstructorParameters<typeof WorkFlowInstance>[0]
// new WorkFlowInstance(graphData as unknown as ValidationGraph).is_valid()
// return graphData
// })
// .catch((error: unknown) => {
// MsgError(getValidationMessage(error))
// return undefined
// })
// }

// function handlePublish() {
// validateWorkflow().then((graphData) => {
// if (!graphData) return

// publishing.value = true
// return saveApplication(graphData)
// .then(() => ApplicationApi.putApplicationPublish(applicationId))
// .then((application) => {
// applicationDetail.value = application
// saveTime.value = application.update_time || saveTime.value
// MsgSuccess('发布成功')
// })
// .finally(() => {
// publishing.value = false
// })
// })
// }
function handlePublish() {
workflowRef.value?.validate().then(() => {
// publishing.value = true
// return saveApplication(graphData)
// .then(() => ApplicationApi.putApplicationPublish(applicationId))
// .then((application) => {
// applicationDetail.value = application
// saveTime.value = application.update_time || saveTime.value
// MsgSuccess('发布成功')
// })
// .finally(() => {
// publishing.value = false
// })
})
}

/* 自动保存 */
// const AUTO_SAVE_INTERVAL = 60_000
Expand Down Expand Up @@ -274,15 +240,9 @@ onMounted(() => {
/>
<el-button plain :loading="saving && !publishing" :disabled="loading || saving || publishing" @click="handleSave()"> 保存 </el-button>
<el-button type="primary" plain :disabled="loading || saving" @click="handleDebug"> 调试 </el-button>
<!-- <el-button
v-if="canPublish"
type="primary"
:loading="publishing"
:disabled="loading || saving || publishing"
@click="handlePublish"
>
发布
</el-button>

<el-button type="primary" :loading="publishing" :disabled="loading || saving || publishing" @click="handlePublish"> 发布 </el-button>
<!--

<MkDropdown v-if="canEdit" trigger="click">
<el-button text aria-label="更多工作流设置">
Expand Down
Loading
Loading