Merge pull request #27 from tengfei-xy/main

为checkout添加切换状态时添加回调函数
This commit is contained in:
Frostime 2024-04-05 17:14:06 +08:00 committed by GitHub
commit 6700d611b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 11 additions and 1 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
.vscode
.DS_Store
pnpm-lock.yaml
package-lock.json
package.zip
node_modules
dev

View file

@ -191,6 +191,11 @@ export default class PluginSample extends Plugin {
type: "checkbox",
title: "Checkbox text",
description: "Check description",
checkbox: {
callback: () => {
console.log("Checkbox clicked");
}
}
});
this.settingUtils.addItem({
key: "Select",

3
src/libs/index.d.ts vendored
View file

@ -12,6 +12,9 @@ interface ISettingItem {
step: number;
};
options?: { [key: string | number]: string };
checkbox?: {
callback: () => void;
}
button?: {
label: string;
callback: () => void;

View file

@ -104,6 +104,7 @@ export class SettingUtils {
element.checked = item.value;
element.className = "b3-switch fn__flex-center";
itemElement = element;
element.onchange = item.checkbox?.callback ?? (() => { });
break;
case 'select':
let selectElement: HTMLSelectElement = document.createElement('select');