From 22e723587d2b409332f2a131c540f2bac3fcd06a Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 29 Apr 2024 12:30:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8F=92=E4=BB=B6=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/plugin/PluginCardListView.vue | 261 +++++++++++++----------- yarn.lock | 8 +- 2 files changed, 141 insertions(+), 128 deletions(-) diff --git a/src/views/plugin/PluginCardListView.vue b/src/views/plugin/PluginCardListView.vue index 34e0d190..49c66443 100644 --- a/src/views/plugin/PluginCardListView.vue +++ b/src/views/plugin/PluginCardListView.vue @@ -8,10 +8,28 @@ import PluginCard from '@/components/cards/PluginCard.vue' import noImage from '@images/logos/plugin.png' import { useDisplay } from 'vuetify' import { isNullOrEmptyObject } from '@/@core/utils' +import { VFadeTransition } from 'vuetify/lib/components/index.mjs' + +const route = useRoute() // 显示器宽度 const display = useDisplay() +// +const activeTab = ref(route.params.tab) + +// tabs +const tabs = [ + { + title: '我的插件', + tab: 'myplugin', + }, + { + title: '插件市场', + tab: 'pluginmarket', + }, +] + // 已安装插件列表 const dataList = ref([]) @@ -57,7 +75,7 @@ const progressText = ref('正在安装插件...') // 过滤表单 const filterForm = reactive({ // 名称 - name: [] as string[], + name: '' as string, // 作者 author: [] as string[], // 标签 @@ -66,8 +84,6 @@ const filterForm = reactive({ repo: [] as string[], }) -// 名称过滤项 -const nameFilterOptions = ref([]) // 作者过滤项 const authorFilterOptions = ref([]) // 标签过滤项 @@ -83,10 +99,9 @@ function initOptions(item: Plugin) { const optionMutipleValue = (options: Array, value: string | undefined) => { value && value.split(',').forEach(v => !options.includes(v) && options.push(v)) } - optionValue(nameFilterOptions.value, item.plugin_name) optionValue(authorFilterOptions.value, item.plugin_author) optionMutipleValue(labelFilterOptions.value, item.plugin_label) - optionValue(repoFilterOptions.value, item.repo_url) + optionValue(repoFilterOptions.value, handleRepoUrl(item.repo_url)) } // 关闭插件市场窗口 @@ -171,12 +186,6 @@ const filterPlugins = computed(() => { }) }) -// 新安装了插件 -function pluginInstalled() { - pluginDialogClose() - refreshData() -} - // 获取插件列表数据 async function fetchInstalledPlugins() { try { @@ -243,6 +252,8 @@ const sortedUninstalledList = computed(() => { filter.length === 0 || (value && filter.includes(value)) const matchMultiple = (filter: Array, value: string | undefined) => filter.length === 0 || (value && value.split(',').some(v => filter.includes(v))) + const filterText = (filter: string, value: string | undefined) => + !filter || (value && value.toLowerCase().includes(filter.toLowerCase())) // 过滤后的数据列表 const ret_list: Plugin[] = [] @@ -251,10 +262,10 @@ const sortedUninstalledList = computed(() => { marketList.value.forEach(value => { if (value) { if ( - match(filterForm.name, value.plugin_name) && + filterText(filterForm.name, `${value.plugin_name} ${value.plugin_desc}`) && match(filterForm.author, value.plugin_author) && matchMultiple(filterForm.label, value.plugin_label) && - match(filterForm.repo, value.repo_url) + match(filterForm.repo, handleRepoUrl(value.repo_url)) ) { ret_list.push(value) } @@ -274,6 +285,18 @@ function pluginLabels(label: string | undefined) { return label.split(',') } +// 新安装了插件 +function pluginInstalled() { + pluginDialogClose() + refreshData() +} + +// 处理掉github地址的前缀 +function handleRepoUrl(url: string | undefined) { + if (!url) return '' + return url.replace('https:github.com/', '').replace('https://raw.githubusercontent.com/', '') +} + // 加载时获取数据 onBeforeMount(async () => { await refreshData() @@ -282,118 +305,108 @@ onBeforeMount(async () => {