feat:优化插件显示

This commit is contained in:
SengokuCola
2026-05-05 00:39:24 +08:00
parent 4641fa1a15
commit caec568a24
5 changed files with 25 additions and 2 deletions

View File

@@ -121,6 +121,7 @@ export async function fetchPluginList(): Promise<ApiResponse<PluginInfo[]>> {
rating: 0,
review_count: 0,
installed: false,
source: 'market' as const,
published_at: new Date().toISOString(),
updated_at: new Date().toISOString(),
}))

View File

@@ -288,10 +288,23 @@ export function useConfigAutoSave<T>(
isInitialLoad: boolean,
triggerAutoSave: (sectionName: ConfigSectionName, data: unknown) => void
): void {
const previousSnapshotRef = useRef<string | null>(null)
useEffect(() => {
if (config && !isInitialLoad) {
if (!config) {
return
}
const snapshot = JSON.stringify(config)
if (isInitialLoad || previousSnapshotRef.current === null) {
previousSnapshotRef.current = snapshot
return
}
if (snapshot !== previousSnapshotRef.current) {
previousSnapshotRef.current = snapshot
triggerAutoSave(sectionName, config)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [config])
}, [config, isInitialLoad])
}

View File

@@ -43,6 +43,11 @@ export function MarketplaceTab({
console.warn('[过滤] 跳过无 manifest 的插件:', plugin.id)
return false
}
// 全部插件只展示 plugin-repo 中存在的市场插件,本地独有插件只在“已安装”显示。
if (plugin.source === 'local') {
return false
}
// 搜索过滤
const matchesSearch = searchQuery === '' ||

View File

@@ -239,6 +239,7 @@ function PluginsPageContent() {
review_count: 0,
installed: true,
installed_version: installedPlugin.manifest.version,
source: 'local',
published_at: new Date().toISOString(),
updated_at: new Date().toISOString(),
})
@@ -636,6 +637,7 @@ function PluginsPageContent() {
const getFilteredPluginCount = (tab: 'all' | 'installed' | 'updates') => {
return plugins.filter(p => {
if (!p.manifest) return false
if (tab === 'all' && p.source === 'local') return false
const matchesSearch = searchQuery === '' ||
p.manifest.name?.toLowerCase().includes(searchQuery.toLowerCase()) ||
p.manifest.description?.toLowerCase().includes(searchQuery.toLowerCase()) ||

View File

@@ -82,6 +82,8 @@ export interface PluginInfo {
screenshots?: string[]
/** 更新日志 */
changelog?: string
/** 插件来源plugin-repo 市场或本地已安装插件 */
source?: 'market' | 'local'
}
/**