mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Specify the return type of method getGeneralSettings
This commit is contained in:
parent
c68acc079d
commit
5678c19868
@ -5,11 +5,16 @@ import { CdnTypes } from '@/core/cdn-types'
|
||||
import { addComponentListener } from '@/core/settings'
|
||||
import { DownloadPackageEmitMode } from '@/core/download-mode'
|
||||
import { ComponentEntry, componentsTags } from '../types'
|
||||
import { defineOptionsMetadata, defineComponentMetadata } from '../define'
|
||||
import {
|
||||
defineComponentMetadata,
|
||||
defineOptionsMetadata,
|
||||
OptionsOfMetadata,
|
||||
} from '../define'
|
||||
import { provideActions } from './external-actions'
|
||||
import description from './desc.md'
|
||||
|
||||
export const WidgetsPlugin = 'widgets'
|
||||
|
||||
export enum SettingsPanelDockSide {
|
||||
Left = '左侧',
|
||||
Right = '右侧',
|
||||
@ -65,14 +70,23 @@ const options = defineOptionsMetadata({
|
||||
},
|
||||
})
|
||||
|
||||
export type Options = OptionsOfMetadata<typeof options>
|
||||
|
||||
const entry: ComponentEntry<typeof options> = async ({ metadata }) => {
|
||||
const { isIframe } = await import('@/core/utils')
|
||||
if (isIframe()) {
|
||||
return
|
||||
}
|
||||
addComponentListener(`${metadata.name}.dockSide`, (value: SettingsPanelDockSide) => {
|
||||
document.body.classList.toggle('settings-panel-dock-right', value === SettingsPanelDockSide.Right)
|
||||
}, true)
|
||||
addComponentListener(
|
||||
`${metadata.name}.dockSide`,
|
||||
(value: SettingsPanelDockSide) => {
|
||||
document.body.classList.toggle(
|
||||
'settings-panel-dock-right',
|
||||
value === SettingsPanelDockSide.Right,
|
||||
)
|
||||
},
|
||||
true,
|
||||
)
|
||||
requestIdleCallback(async () => {
|
||||
const Container = await import('./SettingsContainer.vue')
|
||||
const instance = mountVueComponent(Container)
|
||||
|
||||
@ -8,7 +8,8 @@ import {
|
||||
} from '@/components/component'
|
||||
import { PluginMetadata } from '@/plugins/plugin'
|
||||
// import serialize from 'serialize-javascript'
|
||||
import { settings, ComponentSettings } from '../settings'
|
||||
import type { Options as SettingsPanelOptions } from '@/components/settings-panel'
|
||||
import { ComponentSettings, settings } from '../settings'
|
||||
import { matchUrlPattern } from '../utils'
|
||||
|
||||
/**
|
||||
@ -23,11 +24,9 @@ export const metadataToOptions = <O extends UnknownOptions>(
|
||||
* 生成组件设置
|
||||
* @param component 组件定义
|
||||
*/
|
||||
export const componentToSettings = <
|
||||
Om extends OptionalOptionsMetadata
|
||||
>(component: ComponentMetadata<Om>): (
|
||||
ComponentSettings<OptionsFromOptionalMetadata<Om>>
|
||||
) => {
|
||||
export const componentToSettings = <Om extends OptionalOptionsMetadata>(
|
||||
component: ComponentMetadata<Om>,
|
||||
): ComponentSettings<OptionsFromOptionalMetadata<Om>> => {
|
||||
const { options: meta } = component
|
||||
return {
|
||||
enabled: component.enabledByDefault ?? true,
|
||||
@ -99,7 +98,7 @@ export const getComponentSettings = <R extends UnknownOptions = UnknownOptions>(
|
||||
/**
|
||||
* 获取通用设置 (`settingsPanel`组件的`options`)
|
||||
*/
|
||||
export const getGeneralSettings = () => getComponentSettings('settingsPanel').options
|
||||
export const getGeneralSettings = () => getComponentSettings<SettingsPanelOptions>('settingsPanel').options
|
||||
/**
|
||||
* 判断此组件是否启用, 启用的条件为:
|
||||
* - 若定义了排除列表, 当前URL必须不匹配其排除列表中任意一项(`Component.urlExclude`)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user