Commit c989940b3622e4e23c02d4db72b1de254460d4d4
1 parent
29886bb4
perf(views/ContentHeader/headerLeftBtn): 新增了external扩展目录,这里升级版本有冲突WARNING
Showing
2 changed files
with
168 additions
and
0 deletions
1 | +<template> | ||
2 | + <n-space class="header-left-btn" :size="25"> | ||
3 | + <n-button disabled size="small" quaternary @click="goHomeHandle()"> | ||
4 | + <template #icon> | ||
5 | + <n-icon :depth="3"> | ||
6 | + <home-icon></home-icon> | ||
7 | + </n-icon> | ||
8 | + </template> | ||
9 | + </n-button> | ||
10 | + <n-space> | ||
11 | + <!-- 模块展示按钮 --> | ||
12 | + <n-tooltip v-for="item in btnList" :key="item.key" placement="bottom" trigger="hover"> | ||
13 | + <template #trigger> | ||
14 | + <n-button size="small" ghost :type="styleHandle(item)" @click="clickHandle(item)"> | ||
15 | + <component :is="item.icon"></component> | ||
16 | + </n-button> | ||
17 | + </template> | ||
18 | + <span>{{ item.title }}</span> | ||
19 | + </n-tooltip> | ||
20 | + | ||
21 | + <n-divider vertical /> | ||
22 | + | ||
23 | + <!-- 历史记录按钮 --> | ||
24 | + <n-tooltip v-for="item in historyList" :key="item.key" placement="bottom" trigger="hover"> | ||
25 | + <template #trigger> | ||
26 | + <n-button size="small" ghost type="primary" :disabled="!item.select" @click="clickHistoryHandle(item)"> | ||
27 | + <component :is="item.icon"></component> | ||
28 | + </n-button> | ||
29 | + </template> | ||
30 | + <span>{{ item.title }}</span> | ||
31 | + </n-tooltip> | ||
32 | + <n-divider vertical /> | ||
33 | + <!-- 保存 --> | ||
34 | + <n-tooltip placement="bottom" trigger="hover"> | ||
35 | + <template #trigger> | ||
36 | + <div class="save-btn"> | ||
37 | + <n-button size="small" type="primary" ghost @click="dataSyncUpdate()"> | ||
38 | + <template #icon> | ||
39 | + <n-icon> | ||
40 | + <Save /> | ||
41 | + </n-icon> | ||
42 | + </template> | ||
43 | + </n-button> | ||
44 | + </div> | ||
45 | + </template> | ||
46 | + <span>保存</span> | ||
47 | + </n-tooltip> | ||
48 | + </n-space> | ||
49 | + </n-space> | ||
50 | +</template> | ||
51 | + | ||
52 | +<script setup lang="ts"> | ||
53 | +import { toRefs, Ref, reactive, computed } from 'vue' | ||
54 | +import { renderIcon, goDialog, goHome } from '@/utils' | ||
55 | +import { icon } from '@/plugins' | ||
56 | +import { Save } from '@vicons/carbon' | ||
57 | +import { useRemoveKeyboard } from '../../../hooks/useKeyboard.hook' | ||
58 | + | ||
59 | +import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' | ||
60 | + | ||
61 | +import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' | ||
62 | +import { HistoryStackEnum } from '@/store/modules/chartHistoryStore/chartHistoryStore.d' | ||
63 | +// THINGS_KIT 修改同步逻辑 | ||
64 | +import { useSyncRemote } from '../../../hooks/external/useRemote.hook' | ||
65 | +import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore' | ||
66 | +import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d' | ||
67 | + | ||
68 | +const { LayersIcon, BarChartIcon, PrismIcon, HomeIcon, ArrowBackIcon, ArrowForwardIcon } = icon.ionicons5 | ||
69 | +const { setItem } = useChartLayoutStore() | ||
70 | +const { getLayers, getCharts, getDetails } = toRefs(useChartLayoutStore()) | ||
71 | +const chartEditStore = useChartEditStore() | ||
72 | +const chartHistoryStore = useChartHistoryStore() | ||
73 | +const { dataSyncUpdate } = useSyncRemote() | ||
74 | + | ||
75 | +interface ItemType<T> { | ||
76 | + key: T | ||
77 | + select: Ref<boolean> | boolean | ||
78 | + title: string | ||
79 | + icon: any | ||
80 | +} | ||
81 | + | ||
82 | +const btnList = reactive<ItemType<ChartLayoutStoreEnum>[]>([ | ||
83 | + { | ||
84 | + key: ChartLayoutStoreEnum.CHARTS, | ||
85 | + select: getCharts, | ||
86 | + title: '图表组件', | ||
87 | + icon: renderIcon(BarChartIcon) | ||
88 | + }, | ||
89 | + { | ||
90 | + key: ChartLayoutStoreEnum.LAYERS, | ||
91 | + select: getLayers, | ||
92 | + title: '图层控制', | ||
93 | + icon: renderIcon(LayersIcon) | ||
94 | + }, | ||
95 | + { | ||
96 | + key: ChartLayoutStoreEnum.DETAILS, | ||
97 | + select: getDetails, | ||
98 | + title: '详情设置', | ||
99 | + icon: renderIcon(PrismIcon) | ||
100 | + } | ||
101 | +]) | ||
102 | + | ||
103 | +const isBackStack = computed(() => chartHistoryStore.getBackStack.length > 1) | ||
104 | + | ||
105 | +const isForwardStack = computed(() => chartHistoryStore.getForwardStack.length > 0) | ||
106 | + | ||
107 | +const historyList = reactive<ItemType<HistoryStackEnum>[]>([ | ||
108 | + { | ||
109 | + key: HistoryStackEnum.BACK_STACK, | ||
110 | + // 一定会有初始化画布 | ||
111 | + select: isBackStack, | ||
112 | + title: '后退', | ||
113 | + icon: renderIcon(ArrowBackIcon) | ||
114 | + }, | ||
115 | + { | ||
116 | + key: HistoryStackEnum.FORWARD_STACK, | ||
117 | + select: isForwardStack, | ||
118 | + title: '前进', | ||
119 | + icon: renderIcon(ArrowForwardIcon) | ||
120 | + } | ||
121 | +]) | ||
122 | + | ||
123 | + | ||
124 | +// store 描述的是展示的值,所以和 ContentConfigurations 的 collapsed 是相反的 | ||
125 | +const styleHandle = (item: ItemType<ChartLayoutStoreEnum>) => { | ||
126 | + if (item.key === ChartLayoutStoreEnum.DETAILS) { | ||
127 | + return item.select ? '' : 'primary' | ||
128 | + } | ||
129 | + return item.select ? 'primary' : '' | ||
130 | +} | ||
131 | + | ||
132 | +// 布局处理 | ||
133 | +const clickHandle = (item: ItemType<ChartLayoutStoreEnum>) => { | ||
134 | + setItem(item.key, !item.select) | ||
135 | +} | ||
136 | + | ||
137 | +// 历史记录处理 | ||
138 | +const clickHistoryHandle = (item: ItemType<HistoryStackEnum>) => { | ||
139 | + switch (item.key) { | ||
140 | + case HistoryStackEnum.BACK_STACK: | ||
141 | + chartEditStore.setBack() | ||
142 | + break; | ||
143 | + case HistoryStackEnum.FORWARD_STACK: | ||
144 | + chartEditStore.setForward() | ||
145 | + break; | ||
146 | + } | ||
147 | +} | ||
148 | + | ||
149 | +// 返回首页 | ||
150 | +const goHomeHandle = () => { | ||
151 | + goDialog({ | ||
152 | + message: '返回将不会保存任何操作', | ||
153 | + isMaskClosable: true, | ||
154 | + onPositiveCallback: () => { | ||
155 | + goHome() | ||
156 | + useRemoveKeyboard() | ||
157 | + } | ||
158 | + }) | ||
159 | +} | ||
160 | +</script> | ||
161 | +<style lang="scss" scoped> | ||
162 | +.header-left-btn { | ||
163 | + margin-left: -37px; | ||
164 | +} | ||
165 | +</style> |