Refactor plugin store types and update category logic
Simplified PluginStoreItem types by removing unused fields and standardizing the minimum version property. Updated frontend plugin store page to use new categories ('官方', '工具', '娱乐', '其它') instead of download-based sorting, aligning with the revised type definitions.
This commit is contained in:
1 parent
89d1a912ee
commit
e43e58e6a0
4 files changed
+16
-31
No files matched your search
@@ -5,7 +5,8 @@ import { builtinModules } from 'module';
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat();
|
const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat();
|
||||||
|
// 依赖排除
|
||||||
|
const external = [];
|
||||||
// 构建后拷贝插件
|
// 构建后拷贝插件
|
||||||
function copyToShellPlugin () {
|
function copyToShellPlugin () {
|
||||||
return {
|
return {
|
||||||
@@ -68,7 +69,10 @@ export default defineConfig({
|
|||||||
entry: 'index.ts',
|
entry: 'index.ts',
|
||||||
formats: ['es'],
|
formats: ['es'],
|
||||||
fileName: () => 'index.mjs',
|
fileName: () => 'index.mjs',
|
||||||
}
|
},
|
||||||
|
rollupOptions: {
|
||||||
|
external: [...nodeModules, ...external],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
plugins: [nodeResolve(), copyToShellPlugin()],
|
plugins: [nodeResolve(), copyToShellPlugin()],
|
||||||
});
|
});
|
||||||
@@ -7,17 +7,9 @@ export interface PluginStoreItem {
|
|||||||
description: string; // 插件描述
|
description: string; // 插件描述
|
||||||
author: string; // 作者
|
author: string; // 作者
|
||||||
homepage?: string; // 主页链接
|
homepage?: string; // 主页链接
|
||||||
repository?: string; // 仓库地址
|
|
||||||
downloadUrl: string; // 下载地址
|
downloadUrl: string; // 下载地址
|
||||||
tags?: string[]; // 标签
|
tags?: string[]; // 标签
|
||||||
icon?: string; // 图标URL
|
minVersion?: string; // 最低版本要求
|
||||||
screenshots?: string[]; // 截图
|
|
||||||
minNapCatVersion?: string; // 最低NapCat版本要求
|
|
||||||
dependencies?: Record<string, string>; // 依赖
|
|
||||||
downloads?: number; // 下载次数
|
|
||||||
rating?: number; // 评分
|
|
||||||
createdAt?: string; // 创建时间
|
|
||||||
updatedAt?: string; // 更新时间
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PluginStoreList {
|
export interface PluginStoreList {
|
||||||
|
|||||||
@@ -64,16 +64,13 @@ export default function PluginStorePage () {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按下载量排序
|
|
||||||
filtered.sort((a, b) => (b.downloads || 0) - (a.downloads || 0));
|
|
||||||
|
|
||||||
// 定义主要分类
|
// 定义主要分类
|
||||||
const categories: Record<string, PluginStoreItem[]> = {
|
const categories: Record<string, PluginStoreItem[]> = {
|
||||||
all: filtered,
|
all: filtered,
|
||||||
popular: filtered.filter(p => (p.downloads || 0) > 5000),
|
official: filtered.filter(p => p.tags?.includes('官方')),
|
||||||
tools: filtered.filter(p => p.tags?.some(t => ['工具', '管理', '群管理'].includes(t))),
|
tools: filtered.filter(p => p.tags?.includes('工具')),
|
||||||
entertainment: filtered.filter(p => p.tags?.some(t => ['娱乐', '音乐', '游戏'].includes(t))),
|
entertainment: filtered.filter(p => p.tags?.includes('娱乐')),
|
||||||
message: filtered.filter(p => p.tags?.some(t => ['消息处理', '自动回复', '欢迎'].includes(t))),
|
other: filtered.filter(p => !p.tags?.some(t => ['官方', '工具', '娱乐'].includes(t))),
|
||||||
};
|
};
|
||||||
|
|
||||||
return categories;
|
return categories;
|
||||||
@@ -82,10 +79,10 @@ export default function PluginStorePage () {
|
|||||||
const tabs = useMemo(() => {
|
const tabs = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
{ key: 'all', title: '全部', count: categorizedPlugins.all?.length || 0 },
|
{ key: 'all', title: '全部', count: categorizedPlugins.all?.length || 0 },
|
||||||
{ key: 'popular', title: '热门推荐', count: categorizedPlugins.popular?.length || 0 },
|
{ key: 'official', title: '官方', count: categorizedPlugins.official?.length || 0 },
|
||||||
{ key: 'tools', title: '工具管理', count: categorizedPlugins.tools?.length || 0 },
|
{ key: 'tools', title: '工具', count: categorizedPlugins.tools?.length || 0 },
|
||||||
{ key: 'entertainment', title: '娱乐功能', count: categorizedPlugins.entertainment?.length || 0 },
|
{ key: 'entertainment', title: '娱乐', count: categorizedPlugins.entertainment?.length || 0 },
|
||||||
{ key: 'message', title: '消息处理', count: categorizedPlugins.message?.length || 0 },
|
{ key: 'other', title: '其它', count: categorizedPlugins.other?.length || 0 },
|
||||||
];
|
];
|
||||||
}, [categorizedPlugins]);
|
}, [categorizedPlugins]);
|
||||||
|
|
||||||
|
|||||||
@@ -7,17 +7,9 @@ export interface PluginStoreItem {
|
|||||||
description: string; // 插件描述
|
description: string; // 插件描述
|
||||||
author: string; // 作者
|
author: string; // 作者
|
||||||
homepage?: string; // 主页链接
|
homepage?: string; // 主页链接
|
||||||
repository?: string; // 仓库地址
|
|
||||||
downloadUrl: string; // 下载地址
|
downloadUrl: string; // 下载地址
|
||||||
tags?: string[]; // 标签
|
tags?: string[]; // 标签
|
||||||
icon?: string; // 图标URL
|
minVersion?: string; // 最低版本要求
|
||||||
screenshots?: string[]; // 截图
|
|
||||||
minNapCatVersion?: string; // 最低NapCat版本要求
|
|
||||||
dependencies?: Record<string, string>; // 依赖
|
|
||||||
downloads?: number; // 下载次数
|
|
||||||
rating?: number; // 评分
|
|
||||||
createdAt?: string; // 创建时间
|
|
||||||
updatedAt?: string; // 更新时间
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PluginStoreList {
|
export interface PluginStoreList {
|
||||||
|
|||||||
Reference in new issue
Block a user