mirror of
https://github.com/labring/FastGPT.git
synced 2025-08-05 22:55:27 +00:00
feat: adapt v1 system plugin (#1366)
This commit is contained in:
@@ -63,7 +63,10 @@ export async function getInitConfig() {
|
||||
initSystemConfig(),
|
||||
// getSimpleModeTemplates(),
|
||||
getSystemVersion(),
|
||||
getSystemPlugin()
|
||||
getSystemPlugin(),
|
||||
|
||||
// abandon
|
||||
getSystemPluginV1()
|
||||
]);
|
||||
|
||||
console.log({
|
||||
@@ -164,3 +167,29 @@ function getSystemPlugin() {
|
||||
|
||||
global.communityPlugins = fileTemplates;
|
||||
}
|
||||
function getSystemPluginV1() {
|
||||
if (global.communityPluginsV1 && global.communityPluginsV1.length > 0) return;
|
||||
|
||||
const basePath =
|
||||
process.env.NODE_ENV === 'development'
|
||||
? 'data/pluginTemplates/v1'
|
||||
: '/app/data/pluginTemplates/v1';
|
||||
// read data/pluginTemplates directory, get all json file
|
||||
const files = readdirSync(basePath);
|
||||
// filter json file
|
||||
const filterFiles = files.filter((item) => item.endsWith('.json'));
|
||||
|
||||
// read json file
|
||||
const fileTemplates: (PluginTemplateType & { weight: number })[] = filterFiles.map((filename) => {
|
||||
const content = readFileSync(`${basePath}/${filename}`, 'utf-8');
|
||||
return {
|
||||
...JSON.parse(content),
|
||||
id: `${PluginSourceEnum.community}-${filename.replace('.json', '')}`,
|
||||
source: PluginSourceEnum.community
|
||||
};
|
||||
});
|
||||
|
||||
fileTemplates.sort((a, b) => b.weight - a.weight);
|
||||
|
||||
global.communityPluginsV1 = fileTemplates;
|
||||
}
|
||||
|
Reference in New Issue
Block a user