-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* splited feature settings * fixed nested object mutation with state proxy not functioning
- Loading branch information
Showing
17 changed files
with
232 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Tooltip } from "@material-tailwind/react"; | ||
import { memo } from "react"; | ||
|
||
|
||
function ExperienmentFeatureIcon(): JSX.Element { | ||
return ( | ||
<Tooltip content="测试阶段, 可能会出现BUG或未知问题, 届时请到 github 回报。"> | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5} stroke="currentColor" className="w-5 h-5"> | ||
<path strokeLinecap="round" strokeLinejoin="round" d="M9.75 3.104v5.714a2.25 2.25 0 0 1-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 0 1 4.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0 1 12 15a9.065 9.065 0 0 0-6.23-.693L5 14.5m14.8.8 1.402 1.402c1.232 1.232.65 3.318-1.067 3.611A48.309 48.309 0 0 1 12 21c-2.773 0-5.491-.235-8.135-.687-1.718-.293-2.3-2.379-1.067-3.61L5 14.5" /> | ||
</svg> | ||
</Tooltip> | ||
) | ||
} | ||
|
||
|
||
export default memo(ExperienmentFeatureIcon) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
import * as jimaku from './jimaku' | ||
import * as superchat from './superchat' | ||
|
||
import type { FeatureType } from '~features' | ||
import type { TableType } from "~database" | ||
import type { StateProxy } from "~hooks/binding" | ||
|
||
export type FeatureSettingsDefinition = { | ||
offlineTable: TableType | false | ||
enabledRoomList: boolean | ||
} | ||
|
||
export type FeatureSettingSchema<T> = T extends FeatureFragment<infer U> ? U : never | ||
|
||
export interface FeatureFragment<T extends object> { | ||
title: string | ||
define: FeatureSettingsDefinition | ||
default?: React.FC<StateProxy<T>>, | ||
defaultSettings: Readonly<T> | ||
} | ||
|
||
export type FeatureSettings = typeof featureSettings | ||
|
||
const featureSettings = { | ||
jimaku, | ||
superchat | ||
} | ||
|
||
export default (featureSettings as { [K in FeatureType]: FeatureSettings[K] }) | ||
|
||
export const featureTypes: FeatureType[] = Object.keys(featureSettings) as FeatureType[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { type ChangeEvent, Fragment } from "react" | ||
import type { FeatureSettingsDefinition } from "." | ||
import type { StateProxy } from "~hooks/binding" | ||
import ExperienmentFeatureIcon from "~settings/components/ExperientmentFeatureIcon" | ||
import SwitchListItem from "~settings/components/SwitchListItem" | ||
|
||
|
||
export const title: string = '同传弹幕过滤' | ||
|
||
export const define: FeatureSettingsDefinition= { | ||
enabledRoomList: true, | ||
offlineTable: 'jimakus' | ||
} | ||
|
||
export type FeatureSettingSchema = { | ||
noNativeVtuber: boolean | ||
jimakuPopupWindow: boolean | ||
} | ||
|
||
export const defaultSettings: Readonly<FeatureSettingSchema> = { | ||
noNativeVtuber: false, | ||
jimakuPopupWindow: false | ||
} | ||
|
||
|
||
function JimakuFeatureSettings({ state, useHandler }: StateProxy<FeatureSettingSchema>): JSX.Element { | ||
|
||
const checker = useHandler<ChangeEvent<HTMLInputElement>, boolean>(e => e.target.checked) | ||
|
||
return ( | ||
<Fragment> | ||
<SwitchListItem | ||
label="过滤国内虚拟主播" | ||
hint="此功能目前处于测试阶段, 因此无法过滤所有的国V" | ||
value={state.noNativeVtuber} | ||
onChange={checker('noNativeVtuber')} | ||
marker={<ExperienmentFeatureIcon />} | ||
/> | ||
<SwitchListItem label="启用同传弹幕彈出式视窗" hint="使用弹出式视窗时必须开着直播间才能运行" value={state.jimakuPopupWindow} onChange={checker('jimakuPopupWindow')} /> | ||
</Fragment> | ||
) | ||
} | ||
|
||
|
||
export default JimakuFeatureSettings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { FeatureSettingsDefinition } from "." | ||
|
||
export const title: string = '醒目留言' | ||
|
||
export const define: FeatureSettingsDefinition = { | ||
enabledRoomList: false, | ||
offlineTable: 'superchats' | ||
} | ||
|
||
export type FeatureSettingSchema = {} | ||
|
||
export const defaultSettings: Readonly<FeatureSettingSchema> = {} | ||
|
||
|
||
function SuperchatFeatureSettings(): JSX.Element { | ||
return ( | ||
<></> | ||
) | ||
} | ||
|
||
|
||
export default SuperchatFeatureSettings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.