mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Update default values & export names
This commit is contained in:
parent
23dabcdab7
commit
3fc6b3130c
@ -1,4 +1,4 @@
|
|||||||
import { newSwitchComponentWrapper, defineSwitchMetadata } from '@/components/switch-options'
|
import { wrapSwitchOptions, defineSwitchMetadata } from '@/components/switch-options'
|
||||||
|
|
||||||
import { addComponentListener, getComponentSettings } from '@/core/settings'
|
import { addComponentListener, getComponentSettings } from '@/core/settings'
|
||||||
import { sq } from '@/core/spin-query'
|
import { sq } from '@/core/spin-query'
|
||||||
@ -9,11 +9,6 @@ import { mainSiteUrls } from '@/core/utils/urls'
|
|||||||
|
|
||||||
const switchMetadata = defineSwitchMetadata({
|
const switchMetadata = defineSwitchMetadata({
|
||||||
name: 'simplifyOptions',
|
name: 'simplifyOptions',
|
||||||
dimAt: 'checked',
|
|
||||||
switchProps: {
|
|
||||||
checkedIcon: 'mdi-eye-off-outline',
|
|
||||||
notCheckedIcon: 'mdi-eye-outline',
|
|
||||||
},
|
|
||||||
switches: {
|
switches: {
|
||||||
categories: {
|
categories: {
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
@ -47,7 +42,7 @@ const switchMetadata = defineSwitchMetadata({
|
|||||||
})
|
})
|
||||||
const console = useScopedConsole('简化首页')
|
const console = useScopedConsole('简化首页')
|
||||||
|
|
||||||
export const component = newSwitchComponentWrapper(switchMetadata)({
|
export const component = wrapSwitchOptions(switchMetadata)({
|
||||||
name: 'simplifyHome',
|
name: 'simplifyHome',
|
||||||
displayName: '简化首页',
|
displayName: '简化首页',
|
||||||
description: '隐藏原版首页不需要的元素 / 分区.',
|
description: '隐藏原版首页不需要的元素 / 分区.',
|
||||||
|
|||||||
@ -1,14 +1,9 @@
|
|||||||
import { newSwitchComponentWrapper } from '@/components/switch-options'
|
import { wrapSwitchOptions } from '@/components/switch-options'
|
||||||
import { styledComponentEntry } from '@/components/styled-component'
|
import { styledComponentEntry } from '@/components/styled-component'
|
||||||
import { liveUrls } from '@/core/utils/urls'
|
import { liveUrls } from '@/core/utils/urls'
|
||||||
|
|
||||||
export const component = newSwitchComponentWrapper({
|
export const component = wrapSwitchOptions({
|
||||||
name: 'simplifyOptions',
|
name: 'simplifyOptions',
|
||||||
dimAt: 'checked',
|
|
||||||
switchProps: {
|
|
||||||
checkedIcon: 'mdi-eye-off-outline',
|
|
||||||
notCheckedIcon: 'mdi-eye-outline',
|
|
||||||
},
|
|
||||||
switches: {
|
switches: {
|
||||||
vip: {
|
vip: {
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
v-for="name of Object.keys(options.switches)"
|
v-for="name of Object.keys(options.switches)"
|
||||||
:key="name"
|
:key="name"
|
||||||
:class="{ dim: isDim(name) }"
|
:class="{ dim: isDim(name) }"
|
||||||
v-bind="options.switchProps || {}"
|
v-bind="mergedSwitchProps"
|
||||||
:checked="componentOptions[`switch-${name}`]"
|
:checked="componentOptions[`switch-${name}`]"
|
||||||
@change="componentOptions[`switch-${name}`] = $event"
|
@change="componentOptions[`switch-${name}`] = $event"
|
||||||
>
|
>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
v-for="name of Object.keys(options.switches)"
|
v-for="name of Object.keys(options.switches)"
|
||||||
:key="name"
|
:key="name"
|
||||||
:class="{ dim: isDim(name) }"
|
:class="{ dim: isDim(name) }"
|
||||||
v-bind="options.switchProps || {}"
|
v-bind="mergedSwitchProps"
|
||||||
:checked="componentOptions[`switch-${name}`]"
|
:checked="componentOptions[`switch-${name}`]"
|
||||||
@change="componentOptions[`switch-${name}`] = $event"
|
@change="componentOptions[`switch-${name}`] = $event"
|
||||||
>
|
>
|
||||||
@ -82,6 +82,15 @@ export default Vue.extend({
|
|||||||
componentOptions,
|
componentOptions,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
mergedSwitchProps() {
|
||||||
|
return {
|
||||||
|
checkedIcon: 'mdi-eye-off-outline',
|
||||||
|
notCheckedIcon: 'mdi-eye-outline',
|
||||||
|
...this.options.switchProps,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
options() {
|
options() {
|
||||||
this.updateColumnsCount()
|
this.updateColumnsCount()
|
||||||
@ -97,10 +106,13 @@ export default Vue.extend({
|
|||||||
element.style.setProperty('--columns', columns.toString())
|
element.style.setProperty('--columns', columns.toString())
|
||||||
},
|
},
|
||||||
isDim(name: string) {
|
isDim(name: string) {
|
||||||
return (
|
if (this.options.dimAt === 'checked' || this.options.dimAt === undefined) {
|
||||||
(this.componentOptions[`switch-${name}`] && this.options.dimAt === 'checked') ||
|
return this.componentOptions[`switch-${name}`]
|
||||||
this.options.dimAt === 'notChecked'
|
}
|
||||||
)
|
if (this.options.dimAt === 'notChecked') {
|
||||||
|
return !this.componentOptions[`switch-${name}`]
|
||||||
|
}
|
||||||
|
return false
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -21,6 +21,8 @@ export interface SwitchOptions {
|
|||||||
iconPosition?: 'left' | 'right'
|
iconPosition?: 'left' | 'right'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @deprecated */
|
||||||
export const createSwitchOptions = (options: SwitchOptions) => {
|
export const createSwitchOptions = (options: SwitchOptions) => {
|
||||||
if (options.radio === undefined) {
|
if (options.radio === undefined) {
|
||||||
options.radio = false
|
options.radio = false
|
||||||
|
|||||||
@ -68,13 +68,13 @@ export interface SwitchMetadata<N extends string, S extends string> {
|
|||||||
/**
|
/**
|
||||||
* 控制开关变暗的时机
|
* 控制开关变暗的时机
|
||||||
*
|
*
|
||||||
* `undefined`: 始终不变暗
|
* `false`: 始终不变暗
|
||||||
* `'checked'`: 当开关关闭时变暗
|
* `'checked'`: 当开关开启时变暗
|
||||||
* `'notChecked'`: 始终为变暗状态
|
* `'notChecked'`: 当开关关闭时变暗
|
||||||
*
|
*
|
||||||
* @default undefined
|
* @default 'checked'
|
||||||
*/
|
*/
|
||||||
dimAt?: undefined | 'checked' | 'notChecked'
|
dimAt?: false | 'checked' | 'notChecked'
|
||||||
/** 配置每个开关的图标 */
|
/** 配置每个开关的图标 */
|
||||||
switchProps?: {
|
switchProps?: {
|
||||||
checkedIcon?: string
|
checkedIcon?: string
|
||||||
@ -102,7 +102,7 @@ export interface SwitchMetadataOption<N extends string, S extends string> {
|
|||||||
name: N
|
name: N
|
||||||
switches: SwitchItemsMetadata<S>
|
switches: SwitchItemsMetadata<S>
|
||||||
radio: boolean
|
radio: boolean
|
||||||
dimAt: undefined | 'checked' | 'notChecked'
|
dimAt: false | 'checked' | 'notChecked'
|
||||||
switchProps?: {
|
switchProps?: {
|
||||||
checkedIcon?: string
|
checkedIcon?: string
|
||||||
notCheckedIcon?: string
|
notCheckedIcon?: string
|
||||||
@ -291,7 +291,7 @@ export type SwitchComponentWrapper<N extends string, S extends string> = <O exte
|
|||||||
* @param metadata - 相关配置元数据。可使用 {@link defineSwitchMetadata} 在外部定义
|
* @param metadata - 相关配置元数据。可使用 {@link defineSwitchMetadata} 在外部定义
|
||||||
* @returns 组件包装器
|
* @returns 组件包装器
|
||||||
*/
|
*/
|
||||||
export const newSwitchComponentWrapper = <N extends string, S extends string>(
|
export const wrapSwitchOptions = <N extends string, S extends string>(
|
||||||
metadata: SwitchMetadata<N, S>,
|
metadata: SwitchMetadata<N, S>,
|
||||||
): SwitchComponentWrapper<N, S> => {
|
): SwitchComponentWrapper<N, S> => {
|
||||||
const extendOptions = newSwitchOptionsMetadataExtender(metadata.switches)
|
const extendOptions = newSwitchOptionsMetadataExtender(metadata.switches)
|
||||||
@ -313,5 +313,6 @@ export const newSwitchComponentWrapper = <N extends string, S extends string>(
|
|||||||
return component as SwitchComponentMetadata<O, N, S>
|
return component as SwitchComponentMetadata<O, N, S>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export const newSwitchComponentWrapper = wrapSwitchOptions
|
||||||
|
|
||||||
export { createSwitchOptions } from './switch-options-old'
|
export { createSwitchOptions } from './switch-options-old'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user