From 20f62dae6c541f64597c04f84c884d9d28ffc908 Mon Sep 17 00:00:00 2001 From: Feynman Date: Tue, 29 Apr 2025 11:56:28 +0800 Subject: [PATCH 1/7] refactor: migrate Form.vue and ConditionBox.vue to Composition API - Converted Form.vue and ConditionBox.vue components to use the Composition API with ` diff --git a/packages/form/src/components/field-select/index.jsx b/packages/form/src/components/field-select/index.jsx index 1102da5d8e..940912e24f 100644 --- a/packages/form/src/components/field-select/index.jsx +++ b/packages/form/src/components/field-select/index.jsx @@ -150,9 +150,6 @@ const DefineFieldSelect = defineComponent({ popper-class="field-select-popper" options={fieldOptions.value} dataSource={fieldOptions.value} - onUpdate:modelValue={(val) => { - console.log('onUpdate:modelValue', val) - }} > {{ option: ({ option }) => ( diff --git a/packages/form/src/index.js b/packages/form/src/index.js index 30f31edf67..3429810878 100644 --- a/packages/form/src/index.js +++ b/packages/form/src/index.js @@ -1,13 +1,14 @@ -import i18n from '@tap/i18n' import { registerValidateRules } from '@formily/core' +import { composeExport } from '@formily/element-plus/lib/__builtins__' +import i18n from '@tap/i18n' import cronParse from 'cron-parser' import * as components from './components' -import { composeExport } from '@formily/element-plus/lib/__builtins__' import langs from './locale' +import SchemaForm from './SchemaForm.vue' +import SchemaToForm from './SchemaToForm.vue' import './style.scss' -import SchemaToForm from './SchemaToForm' -export { SchemaToForm } +export { SchemaForm, SchemaToForm } export const validateCron = (value) => { value = value?.trim() @@ -24,8 +25,8 @@ export const validateCron = (value) => { if (cronParse.parseExpression(value).hasNext()) { return true } - } catch (e) { - console.log('cron-rule', e) // eslint-disable-line + } catch (error) { + console.log('cron-rule', error) // eslint-disable-line } return false } @@ -33,11 +34,13 @@ export const validateCron = (value) => { // cron表达式校验 registerValidateRules({ cron(value, rule) { - return validateCron(value) ? '' : rule.message || i18n.t('packages_form_src_index_cronbiao') + return validateCron(value) + ? '' + : rule.message || i18n.t('packages_form_src_index_cronbiao') }, }) -export { composeExport, langs, components } +export { components, composeExport, langs } export * from './components' export * from './shared' From 70d5c795ce9df4bc0e80ea73c16b36da18195f3e Mon Sep 17 00:00:00 2001 From: Feynman Date: Fri, 2 May 2025 20:26:47 +0800 Subject: [PATCH 4/7] refactor: remove unused components and hooks, and update i18n usage - Deleted App.tsx and related hooks (useI18n, useMessage) as they were no longer needed. - Updated App.vue to utilize the new i18n structure with useI18n. - Replaced direct i18n calls with ElMessage in ObjectList and ObjectTable components for improved messaging. - Cleaned up imports and ensured consistent usage of the new i18n methods across components. --- apps/daas/src/App.tsx | 51 ------------------- apps/daas/src/App.vue | 11 ++-- apps/daas/src/hooks/index.ts | 2 - apps/daas/src/hooks/useI18n.ts | 23 --------- apps/daas/src/hooks/useMessage.ts | 4 -- .../src/views/data-discovery/ObjectList.tsx | 3 -- .../src/views/data-discovery/ObjectTable.tsx | 6 +-- packages/i18n/src/locale/lang/en.js | 29 +++++++---- packages/i18n/src/locale/lang/zh-CN.js | 11 ++-- packages/i18n/src/locale/lang/zh-TW.js | 11 ++-- .../src/components/StudioHeader.jsx | 21 ++++---- 11 files changed, 54 insertions(+), 118 deletions(-) delete mode 100644 apps/daas/src/App.tsx delete mode 100644 apps/daas/src/hooks/index.ts delete mode 100644 apps/daas/src/hooks/useI18n.ts delete mode 100644 apps/daas/src/hooks/useMessage.ts diff --git a/apps/daas/src/App.tsx b/apps/daas/src/App.tsx deleted file mode 100644 index 1b0d86f9d8..0000000000 --- a/apps/daas/src/App.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { defineComponent, provide, ref } from 'vue' -import { workerApi } from '@tap/api' -import { provideI18n, useMessage, I18n } from './hooks' -import LockedDialog from './components/LockedDialog.vue' - -export default defineComponent({ - setup() { - const showLocked = ref(false) - const lockedFeature = - import.meta.env.VUE_APP_MODE === 'community' - ? { - sharedMiningList: true, - dataVerificationList: true, - alarmSetting: true, - roleList: true, - valid_total: true, - webhookAlerts: true, - } - : {} - - provideI18n() - provide('checkAgent', async (cb) => { - const Message = useMessage() - const data = await workerApi.getAvailableAgent() - if (!data?.result?.length) { - Message.error(I18n.$t('agent_check_error')) - } else { - cb && cb() - } - }) - provide('buried', () => {}) - provide('lockedFeature', lockedFeature) - provide('openLocked', () => { - showLocked.value = true - }) - return () => { - return ( -
- - - (showLocked.value = val), - }} - > -
- ) - } - }, -}) diff --git a/apps/daas/src/App.vue b/apps/daas/src/App.vue index 74089ed64e..78cc98b564 100644 --- a/apps/daas/src/App.vue +++ b/apps/daas/src/App.vue @@ -1,11 +1,12 @@ - +
-
+
span:empty) { + padding: 0; + } .el-message-box__message { width: 100%; } - .el-message-box__headerbtn { display: flex; justify-content: center; diff --git a/packages/business/src/components/error-message/index.jsx b/packages/business/src/components/error-message/index.jsx index 3b16a70088..7d9453e538 100644 --- a/packages/business/src/components/error-message/index.jsx +++ b/packages/business/src/components/error-message/index.jsx @@ -75,7 +75,7 @@ export function ErrorMessage(stack, message) { title: '', showClose: true, closeIcon: CloseIcon, - customClass: ' w-80 max-w-1000 rounded-lg pro-message-box', + customClass: ' w-80 max-w-1000', message: renderDialog(stack), confirmButtonText: i18n.t('public_button_close'), ...(import.meta.env.VUE_APP_PLATFORM === 'DAAS' diff --git a/packages/business/src/components/error-message/index.scss b/packages/business/src/components/error-message/index.scss index b7a465a049..e1d26416d2 100644 --- a/packages/business/src/components/error-message/index.scss +++ b/packages/business/src/components/error-message/index.scss @@ -25,10 +25,4 @@ display: block; } } -} - -.pro-message-box { - .el-message-box__header { - padding: 0 !important; - } } \ No newline at end of file diff --git a/packages/business/src/locale/lang/zh-TW.js b/packages/business/src/locale/lang/zh-TW.js index 73a4456ddf..433e710537 100644 --- a/packages/business/src/locale/lang/zh-TW.js +++ b/packages/business/src/locale/lang/zh-TW.js @@ -568,6 +568,7 @@ export default { '此操作會丟失當前正在創建(編輯)的校驗任務', packages_business_verification_backConfirmTitle: '是否放棄創建(編輯)校驗任務?', + packages_business_verification_history_source_total_rows: '源總行數', packages_business_verification_source_total_rows: '源總行數', packages_business_verification_form_label_error_save_count: '錯誤保存條數', packages_business_verification_button_auto_add_table: '自動添加表', diff --git a/packages/i18n/src/locale/lang/en.js b/packages/i18n/src/locale/lang/en.js index 56a458bfe8..706866ea7d 100644 --- a/packages/i18n/src/locale/lang/en.js +++ b/packages/i18n/src/locale/lang/en.js @@ -393,4 +393,5 @@ export default { public_form_design: 'Form Design', public_code_edit: 'Code Edit', public_preview_form: 'Preview Form', + public_template_example: 'Template Example', } diff --git a/packages/i18n/src/locale/lang/zh-CN.js b/packages/i18n/src/locale/lang/zh-CN.js index 207dd7faf2..656212488e 100644 --- a/packages/i18n/src/locale/lang/zh-CN.js +++ b/packages/i18n/src/locale/lang/zh-CN.js @@ -384,4 +384,5 @@ export default { public_form_design: '表单设计', public_code_edit: '代码编辑', public_preview_form: '预览表单', + public_template_example: '模板示例', } diff --git a/packages/i18n/src/locale/lang/zh-TW.js b/packages/i18n/src/locale/lang/zh-TW.js index b14c40f33b..b67bdb3120 100644 --- a/packages/i18n/src/locale/lang/zh-TW.js +++ b/packages/i18n/src/locale/lang/zh-TW.js @@ -382,4 +382,5 @@ export default { public_form_design: '表單設計', public_code_edit: '代碼編輯', public_preview_form: '預覽表單', + public_template_example: '模板示例', } From 5009898352b435187b26b14c2a07b0f303d5533b Mon Sep 17 00:00:00 2001 From: Feynman Date: Sat, 3 May 2025 16:01:16 +0800 Subject: [PATCH 6/7] refactor: update error message component styles and fix data mapping in ConditionBox - Changed the border radius class in the error message component for improved styling. - Updated data mapping in ConditionBox.vue to correctly reference the response structure, ensuring accurate data handling. - Enhanced error handling by ensuring safe access to selected states in InfiniteSelect.vue. --- .../src/components/error-message/index.jsx | 2 +- .../verification/components/ConditionBox.vue | 18 +++++++++--------- .../infinite-select/InfiniteSelect.vue | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/business/src/components/error-message/index.jsx b/packages/business/src/components/error-message/index.jsx index 7d9453e538..ecc5381215 100644 --- a/packages/business/src/components/error-message/index.jsx +++ b/packages/business/src/components/error-message/index.jsx @@ -16,7 +16,7 @@ function renderDialog(stack) {
diff --git a/packages/business/src/views/verification/components/ConditionBox.vue b/packages/business/src/views/verification/components/ConditionBox.vue index dbfaf87e6e..83f2f0e1da 100644 --- a/packages/business/src/views/verification/components/ConditionBox.vue +++ b/packages/business/src/views/verification/components/ConditionBox.vue @@ -1001,7 +1001,7 @@ const getConnectionsListMethod = async ( }) const response: ApiResponse = { - items: result.data.items.map((item: ConnectionItem) => { + items: result.items.map((item: ConnectionItem) => { const findDynamicSchema = item.capabilities.find( (t: any) => t.id === 'dynamic_schema', ) @@ -1030,7 +1030,7 @@ const getConnectionsListMethod = async ( databaseType, } }), - total: result.data.total, + total: result.total, } return response @@ -1068,10 +1068,10 @@ const getTableListMethod = async ( filter: JSON.stringify(params), }) const result: ApiResponse = { - items: res.data.items.map((t: TableItem) => t.name), - total: res.data.total, + items: res.items.map((t: TableItem) => t.name), + total: res.total, } - res.data.items.forEach((el: TableItem) => { + res.items.forEach((el: TableItem) => { // 缓存起来 setFieldsByItem( [nodeId, connectionId, el.name], @@ -1132,9 +1132,9 @@ const getTablesInTask = async ( const res = await metadataInstancesApi.nodeSchemaPage(params) - const tableList = res.data.items?.map((t: TableItem) => t.name) || [] - const total = res.data.total - res.data.items.forEach((el: TableItem) => { + const tableList = res.items?.map((t: TableItem) => t.name) || [] + const total = res.total + res.items.forEach((el: TableItem) => { setFieldsByItem( [nodeId, connectionId, el.name], el.fields.map((t: any) => { @@ -1738,7 +1738,7 @@ const handleChangeTable = ( } metadataInstancesApi.nodeSchemaPage(params).then((data: any) => { item.target.fields = - data.data.items?.[0]?.fields.map((t: any) => { + data.items?.[0]?.fields.map((t: any) => { const { id, field_name, primary_key_position, primaryKey, unique } = t return { id, field_name, primary_key_position, primaryKey, unique } }) || [] diff --git a/packages/form/src/components/infinite-select/InfiniteSelect.vue b/packages/form/src/components/infinite-select/InfiniteSelect.vue index 2933cc9d5c..798a39b8df 100644 --- a/packages/form/src/components/infinite-select/InfiniteSelect.vue +++ b/packages/form/src/components/infinite-select/InfiniteSelect.vue @@ -87,7 +87,7 @@ const labelContent = ref('') // 回显数据 const setCurrentLabel = async () => { - const [current] = selectRef.value.states.selected + const [current] = selectRef.value?.states.selected || [] if (!current) return From f2076deadc2f2ec542fd500bfdd36cbf3524a16f Mon Sep 17 00:00:00 2001 From: Feynman Date: Mon, 5 May 2025 22:16:47 +0800 Subject: [PATCH 7/7] refactor: update Vue imports and improve code readability in command.js and Editor.vue TAP-6488 - Replaced Vue import with named import for nextTick in command.js for consistency with Vue 3 standards. - Enhanced string interpolation in command.js for better readability. - Simplified checkMaterializedView method in Editor.vue by directly accessing query from this.$route. - Removed unnecessary comments and cleaned up code structure in Editor.vue and editor.js for improved clarity. --- packages/dag/src/Editor.vue | 10 +++-- packages/dag/src/command.js | 73 +++++++++++++++++++------------ packages/dag/src/mixins/editor.js | 41 ++++++----------- 3 files changed, 64 insertions(+), 60 deletions(-) diff --git a/packages/dag/src/Editor.vue b/packages/dag/src/Editor.vue index a82ffd4f26..13bb0e6b64 100644 --- a/packages/dag/src/Editor.vue +++ b/packages/dag/src/Editor.vue @@ -121,8 +121,6 @@ export default { this.initNodeView() await this.initView(true) this.autoAddNode(query) - this.checkMaterializedView(query) - // this.initWS() } catch (error) { console.error(error) } @@ -338,10 +336,13 @@ export default { this.setTaskId(dataflow.id) this.setEditVersion(dataflow.editVersion) this.setTaskInfo(this.dataflow) + await this.$router.replace({ name: 'DataflowEditor', params: { id: dataflow.id, action: 'dataflowEdit' }, + query: { ...this.$route.query }, }) + this.$nextTick(() => { this.$refs.paperScroller.initVisibleArea() }) @@ -626,7 +627,8 @@ export default { }) }, - async checkMaterializedView(query = {}) { + async checkMaterializedView() { + const { query } = this.$route const { by, connectionId, tableName } = query let connection @@ -635,7 +637,7 @@ export default { await this.$router.replace({ params: { - action: 'dataflowEdit', + id: this.$route.params.id, }, query: { ...query, diff --git a/packages/dag/src/command.js b/packages/dag/src/command.js index b308836b6d..d3a92a1baa 100644 --- a/packages/dag/src/command.js +++ b/packages/dag/src/command.js @@ -1,5 +1,5 @@ import i18n from '@tap/i18n' -import * as Vue from 'vue' +import { nextTick } from 'vue' import { NODE_PREFIX } from './constants' function getRealId(str) { @@ -72,7 +72,7 @@ class NodeCommand extends Command { state.instance.setSuspendDrawing(true) this.elIds.forEach((id) => { - const el = document.querySelector('#' + id) + const el = document.querySelector(`#${id}`) state.instance.removeAllEndpoints(id) state.instance.destroyDraggable(el) state.instance.destroyDroppable(el) @@ -84,7 +84,7 @@ class NodeCommand extends Command { state.store.commit('dataflow/batchRemoveNode', this.nodeIds) - Vue.nextTick(() => { + nextTick(() => { state.instance.setSuspendDrawing(false, true) }) } @@ -118,7 +118,10 @@ class RemoveNodeCommand extends NodeCommand { async exec(state) { this.connections = state.instance .getConnections('*') - .filter((c) => this.elIds.includes(c.targetId) || this.elIds.includes(c.sourceId)) + .filter( + (c) => + this.elIds.includes(c.targetId) || this.elIds.includes(c.sourceId), + ) .map((c) => ({ sourceId: c.sourceId, targetId: c.targetId, @@ -131,10 +134,10 @@ class RemoveNodeCommand extends NodeCommand { state.instance.setSuspendDrawing(true) state.store.commit('dataflow/addNodes', this.nodes) - Vue.nextTick(() => { + nextTick(() => { this.connections?.forEach((c) => { state.instance.connect({ - uuids: [c.sourceId + '_source', c.targetId + '_target'], + uuids: [`${c.sourceId}_source`, `${c.targetId}_target`], }) state.store.commit('dataflow/addConnection', { source: getRealId(c.sourceId), @@ -157,7 +160,10 @@ class ConnectionCommand extends Command { source: NODE_PREFIX + connection.source, target: NODE_PREFIX + connection.target, } - this.uuids = [this.connectionData.source + '_source', this.connectionData.target + '_target'] + this.uuids = [ + `${this.connectionData.source}_source`, + `${this.connectionData.target}_target`, + ] } add(state, uuids = this.uuids, connection = this.connection) { @@ -227,7 +233,7 @@ class MoveNodeCommand extends Command { state.store.commit('dataflow/updateNodeProperties', info) }) - Vue.nextTick(() => { + nextTick(() => { state.instance.setSuspendDrawing(false, true) // state.store.dispatch('dataflow/updateDag') // 自动保存 }) @@ -254,16 +260,24 @@ class AddNodeOnConnectionCommand extends ConnectionCommand { exec(state) { this.remove(state) state.store.commit('dataflow/addNode', this.node) - Vue.nextTick(() => { + nextTick(() => { const nodeId = NODE_PREFIX + this.node.id - this.add(state, [this.connectionData.source + '_source', nodeId + '_target'], { - source: this.connection.source, - target: this.node.id, - }) - this.add(state, [nodeId + '_source', this.connectionData.target + '_target'], { - source: this.node.id, - target: this.connection.target, - }) + this.add( + state, + [`${this.connectionData.source}_source`, `${nodeId}_target`], + { + source: this.connection.source, + target: this.node.id, + }, + ) + this.add( + state, + [`${nodeId}_source`, `${this.connectionData.target}_target`], + { + source: this.node.id, + target: this.connection.target, + }, + ) }) } @@ -288,7 +302,7 @@ class QuickAddTargetCommand extends ConnectionCommand { exec(state) { state.store.commit('dataflow/addNode', this.node) - Vue.nextTick(() => { + nextTick(() => { this.add(state) }) } @@ -311,7 +325,7 @@ class QuickAddSourceCommand extends ConnectionCommand { exec(state) { state.store.commit('dataflow/addNode', this.node) - Vue.nextTick(() => { + nextTick(() => { this.add(state) }) } @@ -335,10 +349,13 @@ class AddDagCommand extends NodeCommand { async exec(state) { state.store.commit('dataflow/addNodes', this.nodes) state.store.commit('dataflow/addEdges', this.edges) - await Vue.nextTick() + await nextTick() this.edges.forEach(({ source, target }) => { state.instance.connect({ - uuids: [`${NODE_PREFIX}${source}_source`, `${NODE_PREFIX}${target}_target`], + uuids: [ + `${NODE_PREFIX}${source}_source`, + `${NODE_PREFIX}${target}_target`, + ], }) }) } @@ -349,14 +366,14 @@ class AddDagCommand extends NodeCommand { } export { - CommandManager, - AddNodeCommand, - RemoveNodeCommand, AddConnectionCommand, - RemoveConnectionCommand, - MoveNodeCommand, + AddDagCommand, + AddNodeCommand, AddNodeOnConnectionCommand, - QuickAddTargetCommand, + CommandManager, + MoveNodeCommand, QuickAddSourceCommand, - AddDagCommand, + QuickAddTargetCommand, + RemoveConnectionCommand, + RemoveNodeCommand, } diff --git a/packages/dag/src/mixins/editor.js b/packages/dag/src/mixins/editor.js index 19422381d9..b03c685836 100644 --- a/packages/dag/src/mixins/editor.js +++ b/packages/dag/src/mixins/editor.js @@ -110,7 +110,8 @@ export default { }, }, watch: { - $route() { + '$route.params.id': function (n, o) { + if (!o) return this.initView() }, }, @@ -792,36 +793,15 @@ export default { async initView(first) { const { id } = this.$route.params - this.stopDagWatch?.() - - if (this.$route.params.action === 'dataflowEdit') { - // 保存后路由跳转 - this.setStateDirty(false) - this.setStateReadonly(false) - this.stopDagWatch = this.$watch( - () => this.allNodes.length + this.allEdges.length, - () => { - this.updateDag({ vm: this }) - }, - ) - this.startLoopTask(id) - this.initWS() - // 从查看进入编辑,清掉轮询 - return Promise.resolve() - } - - if (this.$route.params.action === 'dataflowViewer') { - this.setStateReadonly(true) - return Promise.resolve() - } + const routeName = this.$route.name - // this.dataflow.id = id + this.stopDagWatch?.() if (!first) { this.resetWorkspace() this.initNodeView() } - const routeName = this.$route.name + if ( [ 'DataflowViewer', @@ -831,7 +811,6 @@ export default { ].includes(routeName) ) { await this.openDataflow(id) - // await this.startLoop() this.setStateReadonly(true) if ( routeName === 'MigrateViewer' || @@ -846,8 +825,15 @@ export default { // 检查任务是否可编辑 if (this.checkGotoViewer()) return // 跳转到viewer不需要继续往下走 } else { - return await this.newDataflow() + await this.newDataflow() + + this.setStateDirty(false) + this.setStateReadonly(false) + this.startLoopTask(id) + this.initWS() + this.checkMaterializedView() } + this.stopDagWatch = this.$watch( () => this.allNodes.length + this.allEdges.length, () => { @@ -1111,7 +1097,6 @@ export default { */ handleDelete() { const selectNodes = this.$store.getters['dataflow/getSelectedNodes'] - console.log('delete.selectNodes', selectNodes) // eslint-disable-line this.command.exec(new RemoveNodeCommand(selectNodes)) this.resetSelectedNodes() this.deleteSelectedConnections()