From f665b75fc4847326b80fc0bb7ec0f86412a58b85 Mon Sep 17 00:00:00 2001 From: mtruning <1262327911@qq.com> Date: Sun, 9 Jan 2022 17:12:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E7=BB=98=E5=88=B6?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=A0=B7=E5=BC=8F=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E9=A6=96=E9=A1=B5=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/icon.ts | 7 +- src/utils/page.ts | 36 +++++++-- src/utils/plugin.ts | 11 +-- src/utils/utils.ts | 11 ++- .../chart/components/ContentBox/index.vue | 2 +- .../chart/components/ContentCharts/index.vue | 4 +- .../chart/components/ContentDetails/index.vue | 6 +- .../chart/components/HeaderLeftBtn/index.vue | 76 +++++++++++-------- .../chart/components/HeaderTitle/index.vue | 24 ++++-- src/views/chart/index.vue | 2 +- 10 files changed, 118 insertions(+), 61 deletions(-) diff --git a/src/plugins/icon.ts b/src/plugins/icon.ts index c46e1a6a..12c21cd2 100644 --- a/src/plugins/icon.ts +++ b/src/plugins/icon.ts @@ -36,7 +36,8 @@ import { Cube as CubeIcon, ChevronBackOutline as ChevronBackOutlineIcon, Flash as FlashIcon, - SettingsSharp as SettingsSharpIcon + SettingsSharp as SettingsSharpIcon, + Home as HomeIcon } from '@vicons/ionicons5' // ionicons5 在这里 @@ -116,7 +117,9 @@ const ionicons5 = { // 后端数据(闪电) FlashIcon, // 设置(齿轮) - SettingsSharpIcon + SettingsSharpIcon, + // 回退 + HomeIcon } // https://www.xicons.org/#/ 还有很多 diff --git a/src/utils/page.ts b/src/utils/page.ts index a4680772..c7de2709 100644 --- a/src/utils/page.ts +++ b/src/utils/page.ts @@ -1,7 +1,9 @@ +import { useRoute } from 'vue-router' import { ResultEnum } from '@/enums/httpEnum' import { ErrorPageNameMap, PageEnum } from '@/enums/pageEnum' import router from '@/router' import { docPath, giteeSourceCodePath } from '@/settings/pathConst' +import { goDialog } from '@/utils/plugin' /** * * 根据名字跳转路由 @@ -21,12 +23,12 @@ export const routerTurnByName = ( } if (isReplace) { router.replace({ - name: pageName + name: pageName, }) return } router.push({ - name: pageName + name: pageName, }) } @@ -37,7 +39,7 @@ export const routerTurnByName = ( */ export const fetchPathByName = (pageName: string, p?: string) => { const pathData = router.resolve({ - name: pageName + name: pageName, }) return p ? (pathData as any)[p] : pathData } @@ -65,12 +67,12 @@ export const routerTurnByPath = ( } if (isReplace) { router.replace({ - path: fullPath + path: fullPath, }) return } router.push({ - path: fullPath + path: fullPath, }) } @@ -123,3 +125,27 @@ export const openDoc = () => { export const openGiteeSourceCode = () => { openNewWindow(giteeSourceCodePath) } + +/** + * * 获取当前路由下的参数 + * @returns object + */ +export const fetchRouteParams = () => { + const route = useRoute() + return route.params +} + +/** + * * 是否需要确认 + * @param confirm + */ +export const goHome = (confirm?: boolean, message?: string) => { + if (confirm) { + goDialog({ + message, + onPositiveCallback: () => { + routerTurnByName(PageEnum.BASE_HOME_NAME) + }, + }) + } +} diff --git a/src/utils/plugin.ts b/src/utils/plugin.ts index 503f2815..718afb12 100644 --- a/src/utils/plugin.ts +++ b/src/utils/plugin.ts @@ -7,16 +7,16 @@ import { renderIcon } from '@/utils' /** * * render 对话框 - * @param { Function } dialogFn dialog函数,暂时必须从页面传过来 * @param { Object} params 配置参数 + * @param { Function } dialogFn 函数 */ export const goDialog = ( params: { // 基本 - type: DialogEnum + type?: DialogEnum message?: string // 回调 - onPositiveCallback?: Function + onPositiveCallback: Function onNegativeCallback?: Function // 异步 promise?: boolean @@ -56,12 +56,13 @@ export const goDialog = ( } } - const d: DialogReactive = (typeObj as any)[type]['fn']({ + const d: DialogReactive = (typeObj as any)[type || DialogEnum.warning]['fn']({ title: '提示', icon: renderIcon(InformationCircleIcon, { size: dialogIconSize }), - content: (typeObj as any)[type]['message'], + content: (typeObj as any)[type || DialogEnum.warning]['message'], positiveText: '确定', negativeText: '取消', + // 是否通过遮罩关闭 maskClosable: maskClosable, onPositiveClick: async () => { // 执行异步 diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 792374aa..30a95681 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -55,6 +55,12 @@ export const requireFallbackImg = (path?: string, name?: string) => { ).href } +/** + * 全屏操作函数 + * @param isFullscreen + * @param isEnabled + * @returns + */ export const screenfullFn = (isFullscreen?: boolean, isEnabled?: boolean) => { // 是否是全屏 if (isFullscreen) return screenfull.isFullscreen @@ -72,12 +78,11 @@ export const screenfullFn = (isFullscreen?: boolean, isEnabled?: boolean) => { /** * * 挂载监听 - * @returns url */ export const goAddEventListener = ( target: EventTarget, type: K, - listener: EventListenerOrEventListenerObject, + listener: any, options?: boolean | AddEventListenerOptions | undefined ) => { if (!target) return @@ -90,9 +95,9 @@ export const goAddEventListener = ( options ) } + /** * * 卸载监听 - * @returns url */ export const goRemoveEventListener = ( target: EventTarget, diff --git a/src/views/chart/components/ContentBox/index.vue b/src/views/chart/components/ContentBox/index.vue index ea232572..4dab72ca 100644 --- a/src/views/chart/components/ContentBox/index.vue +++ b/src/views/chart/components/ContentBox/index.vue @@ -1,7 +1,7 @@ diff --git a/src/views/chart/components/HeaderLeftBtn/index.vue b/src/views/chart/components/HeaderLeftBtn/index.vue index 49baaee9..e71c28a2 100644 --- a/src/views/chart/components/HeaderLeftBtn/index.vue +++ b/src/views/chart/components/HeaderLeftBtn/index.vue @@ -1,51 +1,58 @@ diff --git a/src/views/chart/components/HeaderTitle/index.vue b/src/views/chart/components/HeaderTitle/index.vue index 744f61a6..6e0ed6c5 100644 --- a/src/views/chart/components/HeaderTitle/index.vue +++ b/src/views/chart/components/HeaderTitle/index.vue @@ -5,9 +5,7 @@ 工作空间 - - - {{ comTitle }} - + {{ comTitle }} import { ref, nextTick, computed } from 'vue' +import { fetchRouteParams } from '@/utils' import { icon } from '@/plugins' const { FishIcon } = icon.ionicons5 const focus = ref(false) -const title = ref('') const inputInstRef = ref(null) +// 根据路由 id 参数获取项目信息 +const fetchProhectInfoById = () => { + const { id } = fetchRouteParams() + if (id.length) { + // todo 从后端获取项目信息并存储 + return '编辑项目' + id[0] + } + return '' + +} + +const title = ref(fetchProhectInfoById()) + + const comTitle = computed(() => { - title.value = title.value.replace(/\s/g,""); + title.value = title.value.replace(/\s/g, ""); return title.value.length ? title.value : '新项目' }) const handleFocus = () => { focus.value = true nextTick(() => { - ;(inputInstRef).value.focus() + ; (inputInstRef).value.focus() }) } diff --git a/src/views/chart/index.vue b/src/views/chart/index.vue index 40fe45d9..70404fdd 100644 --- a/src/views/chart/index.vue +++ b/src/views/chart/index.vue @@ -13,8 +13,8 @@ - +