为经典设置窗口添加实时读取和实时保存的能力
This commit is contained in:
parent
44d61785cf
commit
f06c82085e
3 changed files with 89 additions and 7 deletions
39
src/index.ts
39
src/index.ts
|
@ -177,6 +177,13 @@ export default class PluginSample extends Plugin {
|
|||
type: "textinput",
|
||||
title: "Readonly text",
|
||||
description: "Input description",
|
||||
action: {
|
||||
callback: () => {
|
||||
// Return data and save it in real time
|
||||
let value = this.settingUtils.takeAndSave("Input")
|
||||
console.log(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.settingUtils.addItem({
|
||||
key: "InputArea",
|
||||
|
@ -184,6 +191,13 @@ export default class PluginSample extends Plugin {
|
|||
type: "textarea",
|
||||
title: "Readonly text",
|
||||
description: "Input description",
|
||||
action: {
|
||||
callback: () => {
|
||||
// Read data in real time
|
||||
let value = this.settingUtils.take("InputArea")
|
||||
console.log(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.settingUtils.addItem({
|
||||
key: "Check",
|
||||
|
@ -191,9 +205,12 @@ export default class PluginSample extends Plugin {
|
|||
type: "checkbox",
|
||||
title: "Checkbox text",
|
||||
description: "Check description",
|
||||
checkbox: {
|
||||
action: {
|
||||
callback: () => {
|
||||
console.log("Checkbox clicked");
|
||||
// Return data and save it in real time
|
||||
let value = !this.settingUtils.get("Check")
|
||||
this.settingUtils.set("Check", value)
|
||||
console.log(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -201,11 +218,18 @@ export default class PluginSample extends Plugin {
|
|||
key: "Select",
|
||||
value: 1,
|
||||
type: "select",
|
||||
title: "Readonly text",
|
||||
title: "Select",
|
||||
description: "Select description",
|
||||
options: {
|
||||
1: "Option 1",
|
||||
2: "Option 2"
|
||||
},
|
||||
action: {
|
||||
callback: () => {
|
||||
// Read data in real time
|
||||
let value = this.settingUtils.take("Select")
|
||||
console.log(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.settingUtils.addItem({
|
||||
|
@ -218,6 +242,15 @@ export default class PluginSample extends Plugin {
|
|||
min: 0,
|
||||
max: 100,
|
||||
step: 1,
|
||||
},
|
||||
action:{
|
||||
// The callback is called after the action of Silder changes,
|
||||
// so it should be the this.settingUtils.get() method.
|
||||
callback: () => {
|
||||
// Read data in real time
|
||||
let value = this.settingUtils.get("Slider")
|
||||
console.log(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.settingUtils.addItem({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue