我需要做一个计数器,以便在完成此操作后发送信号。 我尝试编码:
const q = require('daskeyboard-applet');
const logger = q.logger; // to access to the logger
class StandReminder extends q.DesktopApp {
// this method run () return a signal object
//we send a signal here
async run () {
logger.info("Running.");
const reminder = this.config.reminder;//I take the content of the JSON file with config
if (reminder) {
logger.info ("My text is: " + reminder);
return getQuote (reminder).then(quote => {
const reminder = quote.reminder;
const timeReminder = quote.timeReminder;
var counter = 0;
var increment = function (){
return counter = counter +1; // increment the counter
if (counter > reminder){
break;
}
return new q.Signal ({ //how we can send a signal
points : [
[
// blinking red light
new q.Point('#FF0000', q.Effects.BLINK)]
],
name: 'Stand Reminder',
message: `${reminder} : ${timeReminder}` //me permet d afficher dans la bulle
});
})
}
}
}
}
我的JS文件已链接到JSON文件。 JSON是:
{
"name": "q-applet-stock-quote",
"displayName": "Stock Quote",
"version": "1.0.3",
"description": "Changes the key colors based on stock price variation",
"longDescription": "Monitor your favorite stock tickers and stay on top of the stock market.",
"officialProductName": "",
"appUrl": "",
"publisherName": "Das Keyboard",
"isSingleton": false,
"videoUrl": "",
"icon": "assets/icon.png",
"image": "assets/q-applet-stock-quote-image.png",
"authorName": "Das Keyboard team",
"authorUrl": "https://twitter.com/daskeyboard",
"issuesUrl": "https://github.com/daskeyboard/q-applet-stock-quote/issues",
"homepage": "https://github.com/daskeyboard/q-applet-stock-quote",
"developerRepoUrl": "https://github.com/daskeyboard/q-applet-stock-quote",
"licenseUrl": "http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt",
"changelogUrl": "",
"qActionUrl": "",
"dependencies": {
"daskeyboard-applet": "^2.7.13"
},
"main": "index2.js",
"scripts": {
"test": "mocha"
},
"qConfig": {
"geometry": {
"width": 1,
"height": 1
},
"applet": {
"defaults": {}
},
"questions": [
{
"key": "reminder",
"label": "Choose the time",
"help": "You can find the stock ticker on the web",
"required": true,
"order": 1,
"controlType": "dropdown",
"options":[0, 10, 15, 20, 30, 40, 50]
}
],
"requirements": {
"applet": {
"reminder": "string"
}
}
},
"devDependencies": {
"mocha": "^5.2.0"
}
}
因此,我需要在不同类型的分钟中进行站立提醒。 JSON中的options
为用户描述了一系列不同的选择。在使用JS文件中的数据后,但我不知道我是否在JS文件中正确编写了计数器代码。我们计数器完成了,我向键盘发送了信号。我用q.Signal
说明了这一点,您能帮我吗?