diff --git a/src/app.js b/src/app.js index 7dee1e3..25e3baa 100644 --- a/src/app.js +++ b/src/app.js @@ -86,6 +86,7 @@ class App { logger.debug('开始加载插件', this.plugins); let retryTimes = 0; + do { for (const slug in this.plugins) { const plugin = this.plugins[slug]; @@ -161,6 +162,14 @@ class App { // 进行插件加载 await plugin.load(pluginContext); plugin.loaded = true; + + logger.debug(panel.pushLoadedPlugin); + panel.pushLoadedPlugin({ + slug: plugin.slug, + name: plugin.name, + namespace: plugin.namespace ? globalContext.namespace : null, + description: plugin.description, + }); } } diff --git a/src/panel.jsx b/src/panel.jsx index 6acdf14..adf7f97 100644 --- a/src/panel.jsx +++ b/src/panel.jsx @@ -1,5 +1,8 @@ import '@ui5/webcomponents/dist/Card.js'; import '@ui5/webcomponents/dist/CardHeader.js'; +import '@ui5/webcomponents/dist/Tag.js'; + +import { app } from 'hyperapp'; import { createElement } from './utils/dom'; @@ -56,11 +59,63 @@ export function initializePanel(plugins) { pluginInitializers[slug] = initializer; }); + const $panelHeader = createElement(
); + $panel.appendChild($panelHeader); + function getPluginColorScheme(plugin) { + if (plugin.slug.startsWith('builtin-')) { + return 8; + } + if (plugin.namespace === '学在浙大') { + return 4; + } + if (plugin.namespace === '智云课堂') { + return 5; + } + if (plugin.namespace === 'PTA') { + return 6; + } + return 10; + } + const panelHeaderActions = { + pushLoadedPlugin: + (newPlugin) => + ({ loadedPlugins }) => { + console.debug('[zju-helper] push loaded plugin', newPlugin); + loadedPlugins.push(newPlugin); + return { loadedPlugins }; + }, + }; + app({ + node: $panelHeader, + init: { loadedPlugins: [] }, + actions: panelHeaderActions, + view: ({ loadedPlugins }) => ( +