diff --git a/manifest.json b/manifest.json index 3aa9567..f03716d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "pkmer", "name": "PKMer", - "version": "0.7.5", + "version": "0.7.6", "minAppVersion": "1.3.5", "description": "A marketplace of third-party plugins and themes developed by Obsidian enthusiasts in China to enhance the experience of using Obsidian in China.", "author": "PKMer(windily-cloud&cumany)", diff --git a/src/components/plugin/PluginMarket.vue b/src/components/plugin/PluginMarket.vue index 4b12689..c85934b 100644 --- a/src/components/plugin/PluginMarket.vue +++ b/src/components/plugin/PluginMarket.vue @@ -50,7 +50,6 @@ const loadAllPlugins = async () => { //@ts-ignore const pluginManifests = props.app.plugins.manifests - plugin.isInstalled = pluginManifests[plugin.id] !== undefined plugin.isOutdated = @@ -317,13 +316,37 @@ const displayedPlugins = computed(() => { ) } else if (sortBy.value === "pkmerDownloadCount") { if (sortOrder.value === "asc") { - ResultPlugins = filteredList.value.sort( - (a, b) => b.pkmerDownloadCount - a.pkmerDownloadCount - ) + ResultPlugins = filteredList.value.sort((a, b) => { + if (a.source === "community" && b.source !== "community") { + // a.source 为 'community',b.source 不为 'community',a 排在 b 前面 + return -1 + } else if ( + a.source !== "community" && + b.source === "community" + ) { + // a.source 不为 'community',b.source 为 'community',b 排在 a 前面 + return 1 + } else { + // a.source 和 b.source 都为 'community',或都不是 'community',根据 pkmerDownloadCount 排序 + return b.pkmerDownloadCount - a.pkmerDownloadCount + } + }) } else { - ResultPlugins = filteredList.value.sort( - (a, b) => a.pkmerDownloadCount - b.pkmerDownloadCount - ) + ResultPlugins = filteredList.value.sort((a, b) => { + if (a.source === "community" && b.source !== "community") { + // a.source 为 'community',b.source 不为 'community',a 排在 b 前面 + return -1 + } else if ( + a.source !== "community" && + b.source === "community" + ) { + // a.source 不为 'community',b.source 为 'community',b 排在 a 前面 + return 1 + } else { + // a.source 和 b.source 都为 'community',或都不是 'community',根据 pkmerDownloadCount 排序 + return a.pkmerDownloadCount - b.pkmerDownloadCount + } + }) } } else { ResultPlugins = filteredList.value?.slice( diff --git a/src/types/plugin.ts b/src/types/plugin.ts index 6bec3ca..ec35f2f 100644 --- a/src/types/plugin.ts +++ b/src/types/plugin.ts @@ -2,7 +2,7 @@ * @Author: cumany cuman@qq.com * @Date: 2023-07-18 23:44:50 * @LastEditors: cumany cuman@qq.com - * @LastEditTime: 2023-08-03 16:16:05 + * @LastEditTime: 2024-02-18 10:20:59 * @Description: */ export interface PluginInfo { @@ -27,6 +27,7 @@ export interface PluginInfo { readme_zh: string | null; isInstalled: boolean | undefined; isOutdated: boolean | undefined; + source: 'official' | 'community'; __entity: string; } diff --git a/src/utils/downloader.ts b/src/utils/downloader.ts index f8fbc8f..2e58934 100644 --- a/src/utils/downloader.ts +++ b/src/utils/downloader.ts @@ -18,6 +18,7 @@ export default class PluginProcessor { private async getPluginUrl(pluginName: string, pluginVersion: string) { const currentTime = Date.now(); const cachedPluginUrl = localStorage.getItem('pluginUrl'); + console.log(cachedPluginUrl, "cachedPluginUrl"); // 如果有缓存的地址,并且插件名称和版本号都与缓存一致 if (cachedPluginUrl) { const cachedInfo = JSON.parse(cachedPluginUrl);