mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 17:51:20 -08:00
refactor(core): CORE-14 split typed settings and scope tree lifetimes
This commit is contained in:
1 parent
697817eceb
commit
64d1939daa
51 files changed
+28144
-1519
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import type { SettingHost, SettingItem } from './types'
|
||||
import { subscribeSetting } from './resources'
|
||||
|
||||
export default function aspectRatio(art: SettingHost): SettingItem {
|
||||
const {
|
||||
i18n,
|
||||
icons,
|
||||
constructor: { SETTING_ITEM_WIDTH, ASPECT_RATIO },
|
||||
} = art
|
||||
|
||||
function getI18n(value: string) {
|
||||
return value === 'default' ? i18n.get('Default') : value
|
||||
}
|
||||
|
||||
function update() {
|
||||
const target = art.setting.find(`aspect-ratio-${art.aspectRatio}`)
|
||||
art.setting.check(target)
|
||||
}
|
||||
|
||||
return {
|
||||
width: SETTING_ITEM_WIDTH,
|
||||
name: 'aspect-ratio',
|
||||
html: i18n.get('Aspect Ratio'),
|
||||
icon: icons.aspectRatio,
|
||||
tooltip: getI18n(art.aspectRatio),
|
||||
selector: ASPECT_RATIO.map((item) => {
|
||||
return {
|
||||
value: item,
|
||||
name: `aspect-ratio-${item}`,
|
||||
default: item === art.aspectRatio,
|
||||
html: getI18n(item),
|
||||
}
|
||||
}),
|
||||
onSelect(item) {
|
||||
art.aspectRatio = item.value as string
|
||||
return item.html
|
||||
},
|
||||
mounted: (_element, item) => {
|
||||
update()
|
||||
subscribeSetting(art, item, 'aspectRatio', () => update())
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user