perf: 大优化,移除 @pureadmin/components , 打包大小未启用压缩前减少 0.4 MB , 首屏请求减少 2.3 MB 的资源

This commit is contained in:
xiaoxian521
2022-11-26 23:37:00 +08:00
parent 63f2540745
commit 4f786d6262
28 changed files with 416 additions and 803 deletions

View File

@@ -1,16 +1,15 @@
<script setup lang="ts">
import { ref, computed } from "vue";
import { clone } from "@pureadmin/utils";
import { transformI18n } from "@/plugins/i18n";
import { TreeSelect } from "@pureadmin/components";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { usePermissionStoreHook } from "@/store/modules/permission";
import {
deleteChildren,
getNodeByUniqueId,
appendFieldByUniqueId
} from "@/utils/tree";
import { useDetail } from "./hooks";
import { ref, computed } from "vue";
import { clone } from "@pureadmin/utils";
import { transformI18n } from "@/plugins/i18n";
import { useMultiTagsStoreHook } from "@/store/modules/multiTags";
import { usePermissionStoreHook } from "@/store/modules/permission";
defineOptions({
name: "Tabs"
@@ -25,14 +24,15 @@ const treeData = computed(() => {
});
});
const value = ref<string[]>([]);
const currentValues = ref<string[]>([]);
const multiTags = computed(() => {
return useMultiTagsStoreHook()?.multiTags;
});
function onCloseTags() {
value.value.forEach(uniqueId => {
if (currentValues.value.length === 0) return;
currentValues.value.forEach(uniqueId => {
const currentPath =
getNodeByUniqueId(treeData.value, uniqueId).redirect ??
getNodeByUniqueId(treeData.value, uniqueId).path;
@@ -77,32 +77,27 @@ function onCloseTags() {
</div>
<el-divider />
<TreeSelect
<el-tree-select
class="w-[300px]"
v-model:value="value"
show-search
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
node-key="uniqueId"
placeholder="请选择要关闭的标签"
:fieldNames="{
children: 'children',
key: 'uniqueId',
value: 'uniqueId'
}"
allow-clear
clearable
multiple
tree-default-expand-all
:tree-data="treeData"
filterable
default-expand-all
:props="{
label: data => transformI18n(data.meta.title),
value: 'uniqueId',
children: 'children',
disabled: 'disabled'
}"
:data="treeData"
v-model="currentValues"
>
<template #tagRender="{ closable, onClose, option }">
<el-tag class="mr-[3px]" :closable="closable" @close="onClose">
{{ transformI18n(option.meta.title) }}
</el-tag>
</template>
<template #title="{ data }">
<template #default="{ data }">
<span>{{ transformI18n(data.meta.title) }}</span>
</template>
</TreeSelect>
</el-tree-select>
<el-button class="m-2" @click="onCloseTags">关闭标签</el-button>
<el-divider />