diff --git a/package.json b/package.json index 842b665..20a799b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "miyoushe-emot-to-github", - "version": "0.3.4", + "version": "0.3.5", "type": "module", "description": "在github使用米游社表情包", "private": true, diff --git a/src/App.vue b/src/App.vue index 16ecc36..2a92e81 100644 --- a/src/App.vue +++ b/src/App.vue @@ -17,19 +17,24 @@ useEventListener(document, "focusin", e => { // 解决前进后退时浏览器还原 dom 却不还原 vue app 数据状态的问题——我把旧 dom 杀了不就好了? document.querySelectorAll(".miyoushe-emots").forEach(e => { if (!e.isSameNode(_this.value)) e.remove(); }); }); -function onInputEmot(src, name) { +/** + * @typedef {{id: number,src: string,name: string}} EmotImg + * @typedef {{[x: number]: EmotImg[]}} EmotTabs + */ +/** + * + * @param {EmotImg} param0 + */ +function onInputEmot({ src, name }) { inputEmot(currentInput.value, `${name}`); } const tabs = computed(() => emotList.value?.map(t => ({ group: t.id, name: t.name, src: t.icon })) ?? []) const currentTab = ref(tabs.value[0]?.group ?? "0"); -const tabData = computed(() => emotList.value - .map(g => { - return { - [g.id]: g.list.map(im => ({ id: im.id, src: im.icon, name: im.name })) - } - }).reduce((pv, v) => Object.assign(pv, v), {}) -); +/** + * @type {import('vue').ComputedRef} + */ +const tabData = computed(() => emotList.value.reduce((pv, g) => Object.assign(pv, { [g.id]: g.list.filter(v => v.is_available).map(im => ({ id: im.id, src: im.icon, name: im.name })) }), {}));