Commit 29886bb4fa3c711eed0920213d6e07928e4b0bc6
1 parent
43bc7e14
perf(views/ContentHeader/headerRightBtn): 新增了external扩展目录,这里升级版本有冲突WARNING
Showing
3 changed files
with
113 additions
and
1 deletions
| 1 | +<template> | ||
| 2 | + <n-space class="go-mt-0"> | ||
| 3 | + <n-button v-for="item in comBtnList" :key="item.title" :type="item.type" ghost @click="item.event"> | ||
| 4 | + <template #icon> | ||
| 5 | + <component :is="item.icon"></component> | ||
| 6 | + </template> | ||
| 7 | + <span>{{ item.title }}</span> | ||
| 8 | + </n-button> | ||
| 9 | + </n-space> | ||
| 10 | +</template> | ||
| 11 | + | ||
| 12 | +<script setup lang="ts"> | ||
| 13 | +import { computed } from 'vue' | ||
| 14 | +import { renderIcon, goDialog, fetchPathByName, routerTurnByPath, setSessionStorage, getLocalStorage } from '@/utils' | ||
| 15 | +import { PreviewEnum } from '@/enums/pageEnum' | ||
| 16 | +import { StorageEnum } from '@/enums/storageEnum' | ||
| 17 | +import { useRoute } from 'vue-router' | ||
| 18 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | ||
| 19 | +import { syncData } from '../../../ContentEdit/components/EditTools/hooks/useSyncUpdate.hook' | ||
| 20 | +import { icon } from '@/plugins' | ||
| 21 | +import { cloneDeep } from 'lodash' | ||
| 22 | + | ||
| 23 | +const { BrowsersOutlineIcon, SendIcon, AnalyticsIcon } = icon.ionicons5 | ||
| 24 | +const chartEditStore = useChartEditStore() | ||
| 25 | + | ||
| 26 | +const routerParamsInfo = useRoute() | ||
| 27 | + | ||
| 28 | +// 预览 | ||
| 29 | +const previewHandle = () => { | ||
| 30 | + const path = fetchPathByName(PreviewEnum.CHART_PREVIEW_NAME, 'href') | ||
| 31 | + if (!path) return | ||
| 32 | + const { id } = routerParamsInfo.params | ||
| 33 | + // id 标识 | ||
| 34 | + const previewId = typeof id === 'string' ? id : id[0] | ||
| 35 | + const storageInfo = chartEditStore.getStorageInfo | ||
| 36 | + const sessionStorageInfo = getLocalStorage(StorageEnum.GO_CHART_STORAGE_LIST) || [] | ||
| 37 | + | ||
| 38 | + if (sessionStorageInfo?.length) { | ||
| 39 | + const repeateIndex = sessionStorageInfo.findIndex((e: { id: string }) => e.id === previewId) | ||
| 40 | + // 重复替换 | ||
| 41 | + if (repeateIndex !== -1) { | ||
| 42 | + sessionStorageInfo.splice(repeateIndex, 1, { id: previewId, ...storageInfo }) | ||
| 43 | + setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo) | ||
| 44 | + } else { | ||
| 45 | + sessionStorageInfo.push({ | ||
| 46 | + id: previewId, | ||
| 47 | + ...storageInfo | ||
| 48 | + }) | ||
| 49 | + setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, sessionStorageInfo) | ||
| 50 | + } | ||
| 51 | + } else { | ||
| 52 | + setSessionStorage(StorageEnum.GO_CHART_STORAGE_LIST, [{ id: previewId, ...storageInfo }]) | ||
| 53 | + } | ||
| 54 | + // 跳转 | ||
| 55 | + routerTurnByPath(path, [previewId], undefined, true) | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +// 发布 | ||
| 59 | +const sendHandle = () => { | ||
| 60 | + goDialog({ | ||
| 61 | + message: '想体验发布功能,请前往 master-fetch 分支查看: https://demo.mtruning.club/#/login', | ||
| 62 | + positiveText: '了然', | ||
| 63 | + closeNegativeText: true, | ||
| 64 | + onPositiveCallback: () => {} | ||
| 65 | + }) | ||
| 66 | +} | ||
| 67 | + | ||
| 68 | +const btnList = [ | ||
| 69 | + { | ||
| 70 | + select: true, | ||
| 71 | + title: '同步内容', | ||
| 72 | + type: 'primary', | ||
| 73 | + icon: renderIcon(AnalyticsIcon), | ||
| 74 | + event: syncData | ||
| 75 | + }, | ||
| 76 | + { | ||
| 77 | + select: true, | ||
| 78 | + title: '预览', | ||
| 79 | + icon: renderIcon(BrowsersOutlineIcon), | ||
| 80 | + event: previewHandle | ||
| 81 | + }, | ||
| 82 | + // { | ||
| 83 | + // select: true, | ||
| 84 | + // title: '发布', | ||
| 85 | + // icon: renderIcon(SendIcon), | ||
| 86 | + // event: sendHandle | ||
| 87 | + // } | ||
| 88 | +] | ||
| 89 | + | ||
| 90 | +const comBtnList = computed(() => { | ||
| 91 | + if (chartEditStore.getEditCanvas.isCodeEdit) { | ||
| 92 | + return btnList | ||
| 93 | + } | ||
| 94 | + const cloneList = cloneDeep(btnList) | ||
| 95 | + cloneList.shift() | ||
| 96 | + return cloneList | ||
| 97 | +}) | ||
| 98 | +</script> | ||
| 99 | + | ||
| 100 | +<style lang="scss" scoped> | ||
| 101 | +.align-center { | ||
| 102 | + margin-top: -4px; | ||
| 103 | +} | ||
| 104 | +</style> |
| @@ -52,7 +52,12 @@ const chartEditStore = useChartEditStore() | @@ -52,7 +52,12 @@ const chartEditStore = useChartEditStore() | ||
| 52 | chartHistoryStoreStore.canvasInit(chartEditStore.getEditCanvas) | 52 | chartHistoryStoreStore.canvasInit(chartEditStore.getEditCanvas) |
| 53 | 53 | ||
| 54 | const HeaderLeftBtn = loadAsyncComponent(() => import('./ContentHeader/headerLeftBtn/index.vue')) | 54 | const HeaderLeftBtn = loadAsyncComponent(() => import('./ContentHeader/headerLeftBtn/index.vue')) |
| 55 | -const HeaderRightBtn = loadAsyncComponent(() => import('./ContentHeader/headerRightBtn/index.vue')) | 55 | +/** |
| 56 | + * THINGS_KIT 升级版本这里有冲突 | ||
| 57 | + * 源文件 './ContentHeader/headerRightBtn/index.vue' | ||
| 58 | + * 修改后 './ContentHeader/headerRightBtn/external/index.vue' | ||
| 59 | + */ | ||
| 60 | +const HeaderRightBtn = loadAsyncComponent(() => import('./ContentHeader/headerRightBtn/external/index.vue')) | ||
| 56 | const HeaderTitle = loadAsyncComponent(() => import('./ContentHeader/headerTitle/index.vue')) | 61 | const HeaderTitle = loadAsyncComponent(() => import('./ContentHeader/headerTitle/index.vue')) |
| 57 | const ContentLayers = loadAsyncComponent(() => import('./ContentLayers/index.vue')) | 62 | const ContentLayers = loadAsyncComponent(() => import('./ContentLayers/index.vue')) |
| 58 | const ContentCharts = loadAsyncComponent(() => import('./ContentCharts/index.vue')) | 63 | const ContentCharts = loadAsyncComponent(() => import('./ContentCharts/index.vue')) |