feat: 春节彩蛋

This commit is contained in:
fofolee 2022-01-10 23:39:21 +08:00
parent 72f098e104
commit e0d688779f
4 changed files with 36 additions and 5 deletions

View File

@ -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 = '';

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

View File

@ -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

View File

@ -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
}
}
}