-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(dashboard): add plugin WebUI entries to sidebar with MDI icon support #8569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Soulter
merged 16 commits into
AstrBotDevs:master
from
lxfight:feature/plugin-webui-sidebar
Jun 5, 2026
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d4ca3ce
feat(plugin): support icon field in metadata.yaml for sidebar icon
lxfight ca292c2
feat(sidebar): add isRawTitle support for non-i18n sidebar titles
lxfight 57f4a43
feat(sidebar): add usePluginSidebarItems composable for dynamic plugi…
lxfight 57e452d
feat(sidebar): inject plugin WebUI items into sidebar before More group
lxfight ee0ee2d
refactor(plugin-page): remove header, make iframe full-screen
lxfight 9745800
feat(sidebar): restore plugin WebUI collapsible group
lxfight e8e41ee
fix(plugin-page): prevent iframe from capturing mousemove during side…
lxfight 8883a2f
refactor(sidebar): share plugin state reactively instead of polling
lxfight b650dbe
fix(sidebar): restore initial plugin data fetch on sidebar mount
lxfight b6a1ead
feat(sidebar): render plugin icons via MDI SVG CDN instead of subset …
lxfight 5f44fed
fix(sidebar): render plugin icons as inline SVG with currentColor for…
lxfight d036e00
docs: add plugin sidebar icon documentation
lxfight 384315d
docs: require mdi- prefix for plugin icon field
lxfight 46acc41
chore: ruff format
lxfight 9985976
fix: address review feedback
lxfight 54138c7
chore: remove webui icon
Soulter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import { reactive, shallowRef, onMounted, watch } from "vue"; | ||
| import axios from "axios"; | ||
| import type { menu } from "@/layouts/full/vertical-sidebar/sidebarItem"; | ||
|
|
||
| const DEFAULT_ICON = "mdi-puzzle"; | ||
| const GROUP_I18N_KEY = "core.navigation.pluginWebui"; | ||
| const GROUP_ICON = "mdi-puzzle-outline"; | ||
|
|
||
| interface PluginEntry { | ||
| name: string; | ||
| display_name?: string | null; | ||
| activated: boolean; | ||
| pages: string[]; | ||
| } | ||
|
|
||
| /** 模块级共享状态,由 useExtensionPage.getExtensions() 更新 */ | ||
| export const pluginSidebarState = reactive<{ | ||
| plugins: PluginEntry[]; | ||
| }>({ | ||
| plugins: [], | ||
| }); | ||
|
|
||
| function buildPluginItems(plugins: PluginEntry[]): menu | null { | ||
| const activeWithPages = plugins.filter( | ||
| (p) => p.activated && Array.isArray(p.pages) && p.pages.length > 0, | ||
| ); | ||
|
|
||
| if (activeWithPages.length === 0) return null; | ||
|
|
||
| const children: menu[] = activeWithPages.map((p) => { | ||
| const displayName = p.display_name || p.name || "Unknown Plugin"; | ||
| const firstPage = p.pages[0]; | ||
|
|
||
| return { | ||
| title: displayName, | ||
| icon: DEFAULT_ICON, | ||
| to: `/plugin-page/${encodeURIComponent(p.name)}/${encodeURIComponent(firstPage)}`, | ||
| isRawTitle: true, | ||
| }; | ||
| }); | ||
|
|
||
| return { | ||
| title: GROUP_I18N_KEY, | ||
| icon: GROUP_ICON, | ||
| children, | ||
| }; | ||
| } | ||
|
|
||
| let initialFetched = false; | ||
|
|
||
| async function initPluginState() { | ||
| if (initialFetched) return; | ||
| initialFetched = true; | ||
| try { | ||
| const res = await axios.get("/api/plugin/get"); | ||
| if (res.data?.status === "ok") { | ||
| pluginSidebarState.plugins = res.data.data ?? []; | ||
| } | ||
| } catch { | ||
| // 静默失败,后续 getExtensions() 会补充 | ||
| } | ||
| } | ||
|
|
||
| export function usePluginSidebarItems() { | ||
| const pluginItems = shallowRef<menu | null>(null); | ||
|
|
||
| function refreshItems() { | ||
| pluginItems.value = buildPluginItems(pluginSidebarState.plugins); | ||
| } | ||
|
|
||
| onMounted(async () => { | ||
| await initPluginState(); | ||
| refreshItems(); | ||
| }); | ||
|
|
||
| watch( | ||
| () => pluginSidebarState.plugins, | ||
| () => { | ||
| refreshItems(); | ||
| }, | ||
| ); | ||
|
|
||
| return { pluginItems }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,5 +45,6 @@ | |
| "configTabs": { | ||
| "normal": "Normal Config", | ||
| "system": "System Config" | ||
| } | ||
| }, | ||
| "pluginWebui": "Plugin Pages" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,5 +45,6 @@ | |
| "configTabs": { | ||
| "normal": "普通配置", | ||
| "system": "系统配置" | ||
| } | ||
| }, | ||
| "pluginWebui": "插件页面" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.