diff --git a/src/assets/js/index.js b/src/assets/js/index.js index e87a109..fb0c650 100644 --- a/src/assets/js/index.js +++ b/src/assets/js/index.js @@ -6,9 +6,22 @@ import qcfeatures from "./qcfeatures.js" import qcpanel from "./qcpanel.js" import qcparser from "./qcparser.js" -! function() { +! function () { + // 春节彩蛋 + let showSpringFestivalEgg = () => { + let eggs = UTOOLS.getDB(UTOOLS.DBPRE.CFG + 'eggs') + let thisYear = (new Date()).getFullYear() + if (!eggs.years) eggs.years = [] + if (eggs.years.includes(thisYear)) return + let egg = window.springFestivalEgg() + if (!egg.springFestival) return + utools.showNotification(egg.msg) + eggs.years.push(thisYear) + UTOOLS.putDB(eggs, UTOOLS.DBPRE.CFG + 'eggs') + } // 进入插件 utools.onPluginEnter(async ({ code, type, payload }) => { + showSpringFestivalEgg() // 暗黑模式 if (utools.isDarkColors()) { !$('#darkmode').length && $('head').append(` @@ -133,7 +146,7 @@ import qcparser from "./qcparser.js" // 启动子命令输入 // 清空输出 // $("#out").empty(); - var rule = String.raw `\{\{subinput(:.+?){0,1}\}\}` + var rule = String.raw`\{\{subinput(:.+?){0,1}\}\}` var matched = cmd.match(new RegExp(rule)) var placeholder = matched[1] || ':请输入' var subinput = ''; diff --git a/src/logo_spring_festival.png b/src/logo_spring_festival.png new file mode 100644 index 0000000..9125125 Binary files /dev/null and b/src/logo_spring_festival.png differ diff --git a/src/plugin.json b/src/plugin.json index bd4feea..21b1568 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -4,10 +4,10 @@ "main": "index.html", "homepage": "https://github.com/fofolee/uTools-quickcommand", "publishPage": "https://yuanliao.info/d/424", - "version": "2.4.0", + "version": "2.4.2", "author": "云之轩", "unpack":"autopep8.py", - "logo": "logo.png", + "logo": "logo_spring_festival.png", "preload": "preload.js", "pluginSetting": { "single": false diff --git a/src/preload.js b/src/preload.js index 00e5c66..8549d7e 100644 --- a/src/preload.js +++ b/src/preload.js @@ -3,11 +3,12 @@ const os = require('os'); const child_process = require("child_process") const iconv = require('iconv-lite') const electron = require('electron') -const { NodeVM } = require('vm2') +const { NodeVM } = require('./assets/plugins/vm2') const path = require("path") const util = require("util") const PinyinMatch = require('pinyin-match'); const axios = require('axios'); +const solarLunar = require("solarLunar") // axios.defaults.adapter = require('axios/lib/adapters/http') if (!utools.isWindows()) process.env.PATH += ':/usr/local/bin:/usr/local/sbin' @@ -875,3 +876,20 @@ runCodeFile = (cmd, option, terminal, callback) => { // callback(stdout, stderr) // }) } + +window.springFestivalEgg = () => { + let today = new Date() + const solar2lunarData = solarLunar.solar2lunar(today.getFullYear(), today.getMonth() + 1, today.getDate()) + let springFestivalDays = ["初一", "初二", "初三", "初四", "初五", "初六"] + if (solar2lunarData.monthCn == "正月" && springFestivalDays.includes(solar2lunarData.dayCn)) { + return { + springFestival: true, + msg: "今天是农历" + solar2lunarData.yearCn + solar2lunarData.monthCn + solar2lunarData.dayCn + ", 春节快乐!" + } + } else { + return { + springFestival: false, + msg: "今天是农历" + solar2lunarData.yearCn + solar2lunarData.monthCn + solar2lunarData.dayCn + } + } +}