mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-27 01:21: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,44 @@
|
||||
import type { SettingHost, SettingItem } from './types'
|
||||
import { capitalize } from '../utils'
|
||||
import { subscribeSetting } from './resources'
|
||||
|
||||
export default function flip(art: SettingHost): SettingItem {
|
||||
const {
|
||||
i18n,
|
||||
icons,
|
||||
constructor: { SETTING_ITEM_WIDTH, FLIP },
|
||||
} = art
|
||||
|
||||
function getI18n(value: string) {
|
||||
return i18n.get(capitalize(value))
|
||||
}
|
||||
|
||||
function update() {
|
||||
const target = art.setting.find(`flip-${art.flip}`)
|
||||
art.setting.check(target)
|
||||
}
|
||||
|
||||
return {
|
||||
width: SETTING_ITEM_WIDTH,
|
||||
name: 'flip',
|
||||
html: i18n.get('Video Flip'),
|
||||
tooltip: getI18n(art.flip),
|
||||
icon: icons.flip,
|
||||
selector: FLIP.map((item) => {
|
||||
return {
|
||||
value: item,
|
||||
name: `flip-${item}`,
|
||||
default: item === art.flip,
|
||||
html: getI18n(item),
|
||||
}
|
||||
}),
|
||||
onSelect(item) {
|
||||
art.flip = item.value as string
|
||||
return item.html
|
||||
},
|
||||
mounted: (_element, item) => {
|
||||
update()
|
||||
subscribeSetting(art, item, 'flip', () => update())
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user