feat: 单选框设置

This commit is contained in:
unanmed 2024-02-03 17:41:56 +08:00
parent 04fb447ce3
commit 0c9e0543ee
2 changed files with 34 additions and 4 deletions

View File

@ -78,7 +78,7 @@ dam4.png ---- 存档 59
[] 优化开头动画
[x] 玩家可以设置字体大小
[] 完全删除 functions.js
[] 优化插件加载系统
[x] 优化插件加载系统
[] 优化 Scroll 组件
[] 重写技能控制系统
[x] 自定义快捷键
@ -114,4 +114,4 @@ dam4.png ---- 存档 59
[] 机关门显示绑定怪物
[] 自定义状态栏,通过申请空间进行布局
[x] 复写 apirewrite()
[] 对 vnode 进行简单的包装,提供出显示文字、显示图片等 api 以及修改 css 的 api
[x] 对 vnode 进行简单的包装,提供出显示文字、显示图片等 api 以及修改 css 的 api

View File

@ -1,5 +1,5 @@
import type { SettingComponent, SettingComponentProps } from '../setting';
import { Button, InputNumber } from 'ant-design-vue';
import { Button, InputNumber, Radio } from 'ant-design-vue';
import { mainUi } from './ui';
import { gameKey } from './hotkey';
@ -11,6 +11,7 @@ interface Components {
Number: SettingComponent;
HotkeySetting: SettingComponent;
ToolbarEditor: SettingComponent;
RadioSetting: (items: string[]) => SettingComponent;
}
export function createSettingComponents() {
@ -19,7 +20,8 @@ export function createSettingComponents() {
Boolean: BooleanSetting,
Number: NumberSetting,
HotkeySetting,
ToolbarEditor
ToolbarEditor,
RadioSetting
};
return com;
}
@ -105,6 +107,34 @@ function NumberSetting(props: SettingComponentProps) {
);
}
function RadioSetting(items: string[]) {
return (props: SettingComponentProps) => {
const { setting, displayer, item } = props;
const changeValue = (value: number) => {
if (isNaN(value)) return;
setting.setValue(displayer.selectStack.join('.'), value);
displayer.update();
};
return (
<div>
{items.map((v, i) => {
return (
<Radio
value={i}
checked={i === item.value}
onClick={() => changeValue(i)}
>
{v}
</Radio>
);
})}
</div>
);
};
}
function showSpecialSetting(id: string, vBind?: any) {
const ui = mainUi.get(id);
mainUi.showEnd();