MCPcopy Index your code
hub / github.com/ZToolsCenter/ZTools / getPluginDbData

Method getPluginDbData

src/main/api/renderer/plugins.ts:751–793  ·  view source on GitHub ↗
(pluginName: string)

Source from the content-addressed store, hash-verified

749
750 // 获取插件存储的数据库数据
751 private getPluginDbData(pluginName: string): {
752 success: boolean
753 data?: any
754 error?: string
755 } {
756 try {
757 if (pluginName === 'ZTOOLS') {
758 const allData = lmdbInstance.allDocs('ZTOOLS/')
759 return {
760 success: true,
761 data: allData.map((item: any) => ({
762 id: item._id.substring('ZTOOLS/'.length),
763 data: item.data,
764 rev: item._rev,
765 updatedAt: item.updatedAt || item._updatedAt
766 }))
767 }
768 }
769
770 if (!pluginName) {
771 return { success: false, error: '插件标识无效' }
772 }
773
774 const prefix = getPluginDataPrefix(pluginName)
775 const allData = lmdbInstance.allDocs(prefix)
776
777 if (!allData || allData.length === 0) {
778 return { success: true, data: [] }
779 }
780
781 const formattedData = allData.map((item: any) => ({
782 id: item._id.substring(prefix.length),
783 data: item.data,
784 rev: item._rev,
785 updatedAt: item.updatedAt || item._updatedAt
786 }))
787
788 return { success: true, data: formattedData }
789 } catch (error: unknown) {
790 console.error('[Plugins] 获取插件数据失败:', error)
791 return { success: false, error: error instanceof Error ? error.message : '获取失败' }
792 }
793 }
794}
795
796const pluginsAPI = new PluginsAPI()

Callers 1

setupIPCMethod · 0.95

Calls 2

getPluginDataPrefixFunction · 0.90
allDocsMethod · 0.45

Tested by

no test coverage detected