feat:优化插件显示
This commit is contained in:
@@ -121,6 +121,7 @@ export async function fetchPluginList(): Promise<ApiResponse<PluginInfo[]>> {
|
|||||||
rating: 0,
|
rating: 0,
|
||||||
review_count: 0,
|
review_count: 0,
|
||||||
installed: false,
|
installed: false,
|
||||||
|
source: 'market' as const,
|
||||||
published_at: new Date().toISOString(),
|
published_at: new Date().toISOString(),
|
||||||
updated_at: new Date().toISOString(),
|
updated_at: new Date().toISOString(),
|
||||||
}))
|
}))
|
||||||
|
|||||||
@@ -288,10 +288,23 @@ export function useConfigAutoSave<T>(
|
|||||||
isInitialLoad: boolean,
|
isInitialLoad: boolean,
|
||||||
triggerAutoSave: (sectionName: ConfigSectionName, data: unknown) => void
|
triggerAutoSave: (sectionName: ConfigSectionName, data: unknown) => void
|
||||||
): void {
|
): void {
|
||||||
|
const previousSnapshotRef = useRef<string | null>(null)
|
||||||
|
|
||||||
useEffect(() => {
|
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)
|
triggerAutoSave(sectionName, config)
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [config])
|
}, [config, isInitialLoad])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ export function MarketplaceTab({
|
|||||||
console.warn('[过滤] 跳过无 manifest 的插件:', plugin.id)
|
console.warn('[过滤] 跳过无 manifest 的插件:', plugin.id)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 全部插件只展示 plugin-repo 中存在的市场插件,本地独有插件只在“已安装”显示。
|
||||||
|
if (plugin.source === 'local') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// 搜索过滤
|
// 搜索过滤
|
||||||
const matchesSearch = searchQuery === '' ||
|
const matchesSearch = searchQuery === '' ||
|
||||||
|
|||||||
@@ -239,6 +239,7 @@ function PluginsPageContent() {
|
|||||||
review_count: 0,
|
review_count: 0,
|
||||||
installed: true,
|
installed: true,
|
||||||
installed_version: installedPlugin.manifest.version,
|
installed_version: installedPlugin.manifest.version,
|
||||||
|
source: 'local',
|
||||||
published_at: new Date().toISOString(),
|
published_at: new Date().toISOString(),
|
||||||
updated_at: new Date().toISOString(),
|
updated_at: new Date().toISOString(),
|
||||||
})
|
})
|
||||||
@@ -636,6 +637,7 @@ function PluginsPageContent() {
|
|||||||
const getFilteredPluginCount = (tab: 'all' | 'installed' | 'updates') => {
|
const getFilteredPluginCount = (tab: 'all' | 'installed' | 'updates') => {
|
||||||
return plugins.filter(p => {
|
return plugins.filter(p => {
|
||||||
if (!p.manifest) return false
|
if (!p.manifest) return false
|
||||||
|
if (tab === 'all' && p.source === 'local') return false
|
||||||
const matchesSearch = searchQuery === '' ||
|
const matchesSearch = searchQuery === '' ||
|
||||||
p.manifest.name?.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
p.manifest.name?.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||||
p.manifest.description?.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
p.manifest.description?.toLowerCase().includes(searchQuery.toLowerCase()) ||
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ export interface PluginInfo {
|
|||||||
screenshots?: string[]
|
screenshots?: string[]
|
||||||
/** 更新日志 */
|
/** 更新日志 */
|
||||||
changelog?: string
|
changelog?: string
|
||||||
|
/** 插件来源:plugin-repo 市场或本地已安装插件 */
|
||||||
|
source?: 'market' | 'local'
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user