|
@@ -21,7 +21,7 @@
|
|
|
:key="menu.key"
|
|
|
class="menu"
|
|
|
:class="{active: uiType.current === menu.key}"
|
|
|
- @click="uiType.change(menu.key as any)"
|
|
|
+ @click="clickHandler(menu.key)"
|
|
|
>
|
|
|
<ui-icon :type="menu.icon" class="icon" />
|
|
|
<p>{{ menu.text }}</p>
|
|
@@ -37,6 +37,7 @@ import { uiType } from '@/hook/useGraphic'
|
|
|
import icons, {typeKeys} from "@/graphic/CanvasStyle/ImageLabels/SVGIcons"
|
|
|
import {computed, ref, watch} from "vue";
|
|
|
import UiInput from "@/components/base/components/input/index.vue";
|
|
|
+import {uses} from '@/store/SVGLabel'
|
|
|
|
|
|
|
|
|
const typeMenusRaw = typeKeys.map(({type, children}) => ({
|
|
@@ -48,25 +49,50 @@ const typeMenusRaw = typeKeys.map(({type, children}) => ({
|
|
|
}))
|
|
|
}))
|
|
|
const keyword = ref("")
|
|
|
-console.log(typeMenusRaw)
|
|
|
-const typeMenus = computed(() => typeMenusRaw
|
|
|
- .map(
|
|
|
- (typeMenu) => ({
|
|
|
- ...typeMenu,
|
|
|
- children: typeMenu.children
|
|
|
- .filter(item => item.text.includes(keyword.value))
|
|
|
- .sort((a, b) => a.icon.localeCompare(b.icon))
|
|
|
- })
|
|
|
- )
|
|
|
- .filter(typeMenu => typeMenu.children.length > 0)
|
|
|
-)
|
|
|
+const typeMenus = computed(() => {
|
|
|
+ const raws = typeMenusRaw.map((typeMenu) => ({
|
|
|
+ ...typeMenu,
|
|
|
+ children: typeMenu.children
|
|
|
+ .filter(item => item.text.includes(keyword.value))
|
|
|
+ .sort((a, b) => a.icon.localeCompare(b.icon))
|
|
|
+ }));
|
|
|
+ const items = [
|
|
|
+ {
|
|
|
+ title: "常用",
|
|
|
+ children: uses.value
|
|
|
+ .sort((item1, item2) => item2.count - item1.count).slice(0, 10)
|
|
|
+ .map(item => {
|
|
|
+ for (let menu of typeMenusRaw) {
|
|
|
+ const findItem = menu.children.find(menuItem => menuItem.key === item.key);
|
|
|
+ if (findItem) {
|
|
|
+ return findItem
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .filter(item => !!item)
|
|
|
+ },
|
|
|
+ ...raws
|
|
|
+ ]
|
|
|
+
|
|
|
+
|
|
|
+ return items.filter(item => item.children.length)
|
|
|
+})
|
|
|
const showTypeMenu = ref()
|
|
|
watch(
|
|
|
typeMenus,
|
|
|
() => showTypeMenu.value = typeMenus.value[0],
|
|
|
{ immediate: true }
|
|
|
)
|
|
|
-console.log(typeMenus, showTypeMenu.value)
|
|
|
+
|
|
|
+const clickHandler = (key) => {
|
|
|
+ const findUse = uses.value.find(use => use.key === key);
|
|
|
+ if (findUse) {
|
|
|
+ findUse.count++
|
|
|
+ } else {
|
|
|
+ uses.value.push({ key, count: 1 })
|
|
|
+ }
|
|
|
+ uiType.change(key as any)
|
|
|
+}
|
|
|
|
|
|
defineEmits<{ (e: "quit") }>();
|
|
|
|