Skip to content

Commit

Permalink
增加社区插件分类
Browse files Browse the repository at this point in the history
  • Loading branch information
cumany committed Feb 18, 2024
1 parent b779a42 commit 9905a8c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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)",
Expand Down
37 changes: 30 additions & 7 deletions src/components/plugin/PluginMarket.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const loadAllPlugins = async () => {
//@ts-ignore
const pluginManifests = props.app.plugins.manifests
plugin.isInstalled =
pluginManifests[plugin.id] !== undefined
plugin.isOutdated =
Expand Down Expand Up @@ -317,13 +316,37 @@ const displayedPlugins = computed<PluginInfo[]>(() => {
)
} 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(
Expand Down
3 changes: 2 additions & 1 deletion src/types/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -27,6 +27,7 @@ export interface PluginInfo {
readme_zh: string | null;
isInstalled: boolean | undefined;
isOutdated: boolean | undefined;
source: 'official' | 'community';
__entity: string;
}

Expand Down
1 change: 1 addition & 0 deletions src/utils/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9905a8c

Please sign in to comment.