diff --git a/registry/lib/components/style/custom-navbar/built-in-items.ts b/registry/lib/components/style/custom-navbar/built-in-items.ts index 1a598ef0b..3db34589a 100644 --- a/registry/lib/components/style/custom-navbar/built-in-items.ts +++ b/registry/lib/components/style/custom-navbar/built-in-items.ts @@ -4,10 +4,10 @@ import { ranking } from './ranking/ranking' import { userInfo } from './user-info/user-info' import { logo } from './logo/logo' import { home } from './home/home' -import { livesIframe, mangaIframe } from './iframe/iframe' +import { mangaIframe } from './iframe/iframe' import { games } from './games/games' import { blanks } from './flexible-blank/flexible-blank' -import { bangumi, music, shop, match, creations } from './simple-links/simple-links' +import { bangumi, music, shop, match, creations, lives } from './simple-links/simple-links' import { upload } from './upload/upload' import { search } from './search/search' import { feeds } from './feeds/feeds' @@ -25,7 +25,7 @@ export const getBuiltInItems = (): CustomNavbarItemInit[] => [ ranking, music, games, - livesIframe, + lives, shop, match, mangaIframe, diff --git a/registry/lib/components/style/custom-navbar/entry.ts b/registry/lib/components/style/custom-navbar/entry.ts index 587fcdb8d..f2be6dec0 100644 --- a/registry/lib/components/style/custom-navbar/entry.ts +++ b/registry/lib/components/style/custom-navbar/entry.ts @@ -3,6 +3,7 @@ import { addComponentListener } from '@/core/settings' import { isIframe, isNotHtml, matchUrlPattern, mountVueComponent } from '@/core/utils' import { setupNotifyStyle } from './notify-style' import { setupLinkPopupContentAlignStyle } from './link-popup-content-align-style' +import { migrateOrders } from './orders-migration' export const entry: ComponentEntry = async ({ metadata: { name } }) => { // const url = document.URL.replace(location.search, '') @@ -50,6 +51,7 @@ export const entry: ComponentEntry = async ({ metadata: { name } }) => { if (matchUrlPattern('https://www.bilibili.com/account/history')) { document.body.classList.add('history-page') } + migrateOrders() const CustomNavbar = await import('./CustomNavbar.vue') const customNavbar: Vue & { styles: string[] diff --git a/registry/lib/components/style/custom-navbar/iframe/iframe.ts b/registry/lib/components/style/custom-navbar/iframe/iframe.ts index 7e88d918e..2ce32c5b5 100644 --- a/registry/lib/components/style/custom-navbar/iframe/iframe.ts +++ b/registry/lib/components/style/custom-navbar/iframe/iframe.ts @@ -21,15 +21,6 @@ const getIframeItem = (config: NavbarIframeConfig): CustomNavbarItemInit & Navba noPopupPadding: true, transparentPopup: true, }) -export const livesIframe = getIframeItem({ - src: 'https://live.bilibili.com/blackboard/dropdown-menu.html', - href: 'https://live.bilibili.com', - width: 528, - height: 266, - lazy: true, - displayName: '直播', - iframeName: 'lives', -}) export const mangaIframe = getIframeItem({ src: 'https://manga.bilibili.com/eden/bilibili-nav-panel.html', href: 'https://manga.bilibili.com', diff --git a/registry/lib/components/style/custom-navbar/orders-migration.ts b/registry/lib/components/style/custom-navbar/orders-migration.ts new file mode 100644 index 000000000..84a8f1c1d --- /dev/null +++ b/registry/lib/components/style/custom-navbar/orders-migration.ts @@ -0,0 +1,18 @@ +import { getComponentSettings } from '@/core/settings' +import type { CustomNavbarOptions } from '.' + +export const migrateOrders = () => { + const migrations = [ + ['gamesIframe', 'games'], + ['livesIframe', 'lives'], + ] + + const { options } = getComponentSettings('customNavbar') + migrations.forEach(([from, to]) => { + const oldOrder = options.order[from] + if (oldOrder !== undefined) { + options.order[to] = oldOrder + delete options.order[from] + } + }) +} diff --git a/registry/lib/components/style/custom-navbar/simple-links/simple-links.ts b/registry/lib/components/style/custom-navbar/simple-links/simple-links.ts index 4e3650f34..7234221d6 100644 --- a/registry/lib/components/style/custom-navbar/simple-links/simple-links.ts +++ b/registry/lib/components/style/custom-navbar/simple-links/simple-links.ts @@ -42,3 +42,8 @@ export const creations = getSimpleLinkItem({ displayName: '创作中心', href: 'https://member.bilibili.com/platform/home', }) +export const lives = getSimpleLinkItem({ + name: 'lives', + displayName: '直播', + href: 'https://live.bilibili.com', +})