diff --git a/dolphinscheduler-ui-next/src/utils/clipboard.ts b/dolphinscheduler-ui-next/src/utils/clipboard.ts index 714ea52663..ca0d72ab34 100644 --- a/dolphinscheduler-ui-next/src/utils/clipboard.ts +++ b/dolphinscheduler-ui-next/src/utils/clipboard.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -export const copy = (text: string): boolean => { +const copy = (text: string): boolean => { const inp = document.createElement('input') document.body.appendChild(inp) inp.value = text @@ -27,3 +27,5 @@ export const copy = (text: string): boolean => { inp.remove() return result } + +export default copy diff --git a/dolphinscheduler-ui-next/src/utils/index.ts b/dolphinscheduler-ui-next/src/utils/index.ts index b38fc75111..afce8157fc 100644 --- a/dolphinscheduler-ui-next/src/utils/index.ts +++ b/dolphinscheduler-ui-next/src/utils/index.ts @@ -20,13 +20,17 @@ import regex from './regex' import truncateText from './truncate-text' import log from './log' import downloadFile from './downloadFile' +import copy from './clipboard' +import removeUselessChildren from './tree-format' const utils = { mapping, regex, truncateText, log, - downloadFile + downloadFile, + copy, + removeUselessChildren } export default utils diff --git a/dolphinscheduler-ui-next/src/utils/tree-format.ts b/dolphinscheduler-ui-next/src/utils/tree-format.ts index 33e29b9000..5f7cea50ad 100644 --- a/dolphinscheduler-ui-next/src/utils/tree-format.ts +++ b/dolphinscheduler-ui-next/src/utils/tree-format.ts @@ -15,9 +15,9 @@ * limitations under the License. */ -export function removeUselessChildren( +const removeUselessChildren = ( list: { children?: []; dirctory?: boolean; disabled?: boolean }[] -) { +) => { if (!list.length) return list.forEach((item) => { if (item.dirctory && item.children?.length === 0) item.disabled = true @@ -29,3 +29,5 @@ export function removeUselessChildren( removeUselessChildren(item.children) }) } + +export default removeUselessChildren diff --git a/dolphinscheduler-ui-next/src/utils/truncate-text.ts b/dolphinscheduler-ui-next/src/utils/truncate-text.ts index 4f7b95eb3c..9799bda3aa 100644 --- a/dolphinscheduler-ui-next/src/utils/truncate-text.ts +++ b/dolphinscheduler-ui-next/src/utils/truncate-text.ts @@ -21,7 +21,7 @@ * @param {string} text * Each Chinese character is equal to two chars */ -export default function truncateText(text: string, n: number) { +const truncateText = (text: string, n: number) => { const exp = /[\u4E00-\u9FA5]/ let res = '' let len = text.length @@ -49,3 +49,5 @@ export default function truncateText(text: string, n: number) { } return res } + +export default truncateText \ No newline at end of file diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-main-jar.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-main-jar.ts index 5c33c4ed7e..41356b07d6 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-main-jar.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-main-jar.ts @@ -19,7 +19,7 @@ import { ref, onMounted, watch } from 'vue' import { useI18n } from 'vue-i18n' import { queryResourceByProgramType } from '@/service/modules/resources' import { useTaskNodeStore } from '@/store/project/task-node' -import { removeUselessChildren } from '@/utils/tree-format' +import utils from '@/utils' import type { IJsonItem, ProgramType, IMainJar } from '../types' export function useMainJar(model: { [field: string]: any }): IJsonItem { @@ -37,7 +37,7 @@ export function useMainJar(model: { [field: string]: any }): IJsonItem { type: 'FILE', programType }) - removeUselessChildren(res) + utils.removeUselessChildren(res) mainJarOptions.value = res || [] taskStore.updateMainJar(programType, res) } diff --git a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-resources.ts b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-resources.ts index 93c3452f9b..b9df51eefa 100644 --- a/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-resources.ts +++ b/dolphinscheduler-ui-next/src/views/projects/task/components/node/fields/use-resources.ts @@ -19,7 +19,7 @@ import { ref, onMounted } from 'vue' import { useI18n } from 'vue-i18n' import { queryResourceList } from '@/service/modules/resources' import { useTaskNodeStore } from '@/store/project/task-node' -import { removeUselessChildren } from '@/utils/tree-format' +import utils from '@/utils' import type { IJsonItem, IResource } from '../types' export function useResources(): IJsonItem { @@ -38,7 +38,7 @@ export function useResources(): IJsonItem { if (resourcesLoading.value) return resourcesLoading.value = true const res = await queryResourceList({ type: 'FILE' }) - removeUselessChildren(res) + utils.removeUselessChildren(res) resourcesOptions.value = res || [] resourcesLoading.value = false taskStore.updateResource(res) diff --git a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-text-copy.ts b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-text-copy.ts index 33b6f22c3b..55040f9a2c 100644 --- a/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-text-copy.ts +++ b/dolphinscheduler-ui-next/src/views/projects/workflow/components/dag/use-text-copy.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { copy } from '@/utils/clipboard' +import utils from '@/utils' import { useMessage } from 'naive-ui' import { useI18n } from 'vue-i18n' @@ -26,7 +26,7 @@ export function useTextCopy() { const { t } = useI18n() const message = useMessage() const copyText = (text: string) => { - if (copy(text)) { + if (utils.copy(text)) { message.success(t('project.dag.copy_success')) } } diff --git a/dolphinscheduler-ui-next/src/views/security/user-manage/components/use-authorize.ts b/dolphinscheduler-ui-next/src/views/security/user-manage/components/use-authorize.ts index 819a7a444f..4d7d26b41f 100644 --- a/dolphinscheduler-ui-next/src/views/security/user-manage/components/use-authorize.ts +++ b/dolphinscheduler-ui-next/src/views/security/user-manage/components/use-authorize.ts @@ -40,7 +40,7 @@ import { grantUDFFunc, grantNamespaceFunc } from '@/service/modules/users' -import { removeUselessChildren } from '@/utils/tree-format' +import utils from '@/utils' import type { TAuthType, IResourceOption, IOption } from '../types' export function useAuthorize() { @@ -127,7 +127,7 @@ export function useAuthorize() { authorizedFile({ userId }) ]) state.loading = false - removeUselessChildren(resources[0]) + utils.removeUselessChildren(resources[0]) const udfResources = [] as IResourceOption[] const fileResources = [] as IResourceOption[] resources[0].forEach((item: IResourceOption) => {