Apply formatting and minor style fixes across repo
Normalize code style across multiple packages: whitespace cleanup, consistent commas and trailing commas in arrays/enums/objects, fix table markdown lines in CI comment template, ensure newline at EOF, normalize header/object property quoting and spacing, remove stray blank lines and minor non-functional comment tweaks. These are formatting-only changes and small type/annotation spacing adjustments; no functional behavior changes intended.
This commit is contained in:
1 parent
d2d0b258bc
commit
974528fe7e
186 files changed
+1367
-1233
No files matched your search
@@ -6,8 +6,7 @@ import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { NetworkAdapterConfig } from 'napcat-types/napcat-onebot/config/config';
|
||||
|
||||
|
||||
let startTime: number = Date.now();
|
||||
const startTime: number = Date.now();
|
||||
let logger: PluginLogger | null = null;
|
||||
|
||||
interface BuiltinPluginConfig {
|
||||
@@ -24,10 +23,9 @@ interface BuiltinPluginConfig {
|
||||
let currentConfig: BuiltinPluginConfig = {
|
||||
prefix: '#napcat',
|
||||
enableReply: true,
|
||||
description: '这是一个内置插件的配置示例'
|
||||
description: '这是一个内置插件的配置示例',
|
||||
};
|
||||
|
||||
|
||||
export let plugin_config_ui: PluginConfigSchema = [];
|
||||
|
||||
const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
@@ -42,12 +40,12 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
ctx.NapCatConfig.select('theme', 'Theme Selection', [
|
||||
{ label: 'Light Mode', value: 'light' },
|
||||
{ label: 'Dark Mode', value: 'dark' },
|
||||
{ label: 'Auto', value: 'auto' }
|
||||
{ label: 'Auto', value: 'auto' },
|
||||
], 'light', 'Select a theme for the response (Demo purpose only)'),
|
||||
ctx.NapCatConfig.multiSelect('features', 'Enabled Features', [
|
||||
{ label: 'Version Info', value: 'version' },
|
||||
{ label: 'Status Report', value: 'status' },
|
||||
{ label: 'Debug Log', value: 'debug' }
|
||||
{ label: 'Debug Log', value: 'debug' },
|
||||
], ['version'], 'Select features to enable'),
|
||||
ctx.NapCatConfig.text('description', 'Description', '这是一个内置插件的配置示例', 'A multi-line text area for notes')
|
||||
);
|
||||
@@ -80,14 +78,14 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
pluginName: ctx.pluginName,
|
||||
generatedAt: new Date().toISOString(),
|
||||
uptime: Date.now() - startTime,
|
||||
config: currentConfig
|
||||
}, null, 2)
|
||||
config: currentConfig,
|
||||
}, null, 2),
|
||||
},
|
||||
{
|
||||
path: '/readme.txt',
|
||||
contentType: 'text/plain',
|
||||
content: `NapCat Builtin Plugin\n=====================\nThis is a demonstration of the staticOnMem feature.\nPlugin: ${ctx.pluginName}\nPath: ${ctx.pluginPath}`
|
||||
}
|
||||
content: `NapCat Builtin Plugin\n=====================\nThis is a demonstration of the staticOnMem feature.\nPlugin: ${ctx.pluginName}\nPath: ${ctx.pluginPath}`,
|
||||
},
|
||||
]);
|
||||
|
||||
// 注册 API 路由(需要鉴权,挂载到 /api/Plugin/ext/{pluginId}/)
|
||||
@@ -101,15 +99,15 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
uptimeFormatted: formatUptime(uptime),
|
||||
config: currentConfig,
|
||||
platform: process.platform,
|
||||
arch: process.arch
|
||||
}
|
||||
arch: process.arch,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
ctx.router.get('/config', (_req, res) => {
|
||||
res.json({
|
||||
code: 0,
|
||||
data: currentConfig
|
||||
data: currentConfig,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -141,8 +139,8 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
pluginName: ctx.pluginName,
|
||||
uptime,
|
||||
uptimeFormatted: formatUptime(uptime),
|
||||
platform: process.platform
|
||||
}
|
||||
platform: process.platform,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -152,8 +150,8 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
code: 0,
|
||||
data: {
|
||||
status: 'ok',
|
||||
timestamp: new Date().toISOString()
|
||||
}
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -165,7 +163,7 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
if (!pluginId) {
|
||||
res.status(400).json({
|
||||
code: -1,
|
||||
message: 'Plugin ID is required'
|
||||
message: 'Plugin ID is required',
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -176,7 +174,7 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
if (!targetPlugin) {
|
||||
res.status(404).json({
|
||||
code: -1,
|
||||
message: `Plugin '${pluginId}' not found or not loaded`
|
||||
message: `Plugin '${pluginId}' not found or not loaded`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -192,7 +190,7 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
hasCleanup: typeof targetPlugin.plugin_cleanup === 'function',
|
||||
hasConfigSchema: Array.isArray(targetPlugin.plugin_config_schema),
|
||||
hasConfigUI: Array.isArray(targetPlugin.plugin_config_ui),
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -202,7 +200,7 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => {
|
||||
title: '插件仪表盘',
|
||||
icon: '📊',
|
||||
htmlFile: 'webui/dashboard.html',
|
||||
description: '查看内置插件的运行状态和配置'
|
||||
description: '查看内置插件的运行状态和配置',
|
||||
});
|
||||
|
||||
logger.info('WebUI 路由已注册:');
|
||||
@@ -287,7 +285,7 @@ async function loadEndpointsForUrl (ui: PluginConfigUIController, apiUrl: string
|
||||
// 更新现有字段的选项
|
||||
ui.updateField('apiEndpoints', {
|
||||
options: mockEndpoints,
|
||||
description: `从 ${apiUrl} 加载的端点`
|
||||
description: `从 ${apiUrl} 加载的端点`,
|
||||
});
|
||||
} else {
|
||||
// 添加新字段
|
||||
@@ -297,7 +295,7 @@ async function loadEndpointsForUrl (ui: PluginConfigUIController, apiUrl: string
|
||||
label: 'API Endpoints',
|
||||
description: `从 ${apiUrl} 加载的端点`,
|
||||
options: mockEndpoints,
|
||||
default: []
|
||||
default: [],
|
||||
}, 'apiUrl');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user