luci-app-jd-dailybonus: merge upstream code (#6262)

This commit is contained in:
EnnawYang 2021-01-26 18:38:53 +08:00 committed by GitHub
parent 9170d18d0d
commit 6ee0262477
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 11 deletions

View File

@ -15,6 +15,7 @@ function index()
entry({'admin', 'services', 'jd-dailybonus', 'check_update'}, call('check_update')) -- 检查更新
entry({'admin', 'services', 'jd-dailybonus', 'qrcode'}, call('qrcode')) -- 获取二维码
entry({'admin', 'services', 'jd-dailybonus', 'check_login'}, call('check_login')) -- 获取二维码
entry({'admin', 'services', 'jd-dailybonus', 'realtime_log'}, call('get_log')) -- 获取实时日志
end
-- 执行程序
@ -122,4 +123,10 @@ function check_login()
luci.http.prepare_content('application/json')
luci.http.write_json(return_json)
end
function get_log()
local fs = require "nixio.fs"
local log = fs.readfile("/var/log/jd_dailybonus.log") or ""
luci.http.write(log)
end

View File

@ -1,6 +1,4 @@
local fs = require "nixio.fs"
local jd = "jd-dailybonus"
local conffile = "/www/JD_DailyBonus.htm"
log = SimpleForm("logview")
log.submit = false
@ -11,7 +9,7 @@ t = log:field(TextValue, "1", nil)
t.rmempty = true
t.rows = 30
function t.cfgvalue()
return fs.readfile(conffile) or ""
return fs.readfile("/var/log/jd_dailybonus.log") or ""
end
t.readonly="readonly"

View File

@ -1,5 +1,4 @@
local fs = require "nixio.fs"
local jd = "jd-dailybonus"
s = SimpleForm("scriptview")

View File

@ -219,6 +219,7 @@
const QRCODE_URL = '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","qrcode")%>';
const CHECK_LOGIN_URL = '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","check_login")%>';
const UPDATE_URL = '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","update")%>';
const LOG_URL = '<%=luci.dispatcher.build_url("admin", "services", "jd-dailybonus","realtime_log")%>';
const CHECKING_TEXT = '<%= translate("正在检查是否存在新的版本 ...") %>';
const UPDATING_TEXT = '<%= translate("正在更新脚本,请稍候 ...") %>';
const NEW_VERSION = '<%= translate("当前已是最新版本:") %>';
@ -281,7 +282,7 @@
//获取实时日志
function get_realtime_log() {
XHR.poll(1, "/JD_DailyBonus.htm", null, x => {
XHR.poll(1, LOG_URL, null, x => {
let retArea = document.getElementById("log_content3");
if (x.response.search(" 秒") != -1) {
noChange++;

View File

@ -12,7 +12,7 @@
NAME=jd-dailybonus
TEMP_SCRIPT=/tmp/JD_DailyBonus.js
JD_SCRIPT=/usr/share/jd-dailybonus/JD_DailyBonus.js
LOG_HTM=/www/JD_DailyBonus.htm
LOG_FILE=/var/log/jd_dailybonus.log
CRON_FILE=/etc/crontabs/root
usage() {
cat <<-EOF
@ -60,13 +60,13 @@ add_cron() {
# Run Script
notify() {
grep "Cookie失效" /www/JD_DailyBonus.htm >/dev/null
grep "Cookie失效" ${LOG_FILE} >/dev/null
if [ $? -eq 0 ]; then
title="$(date '+%Y年%m月%d日') 京东签到 Cookie 失效"
else
title="$(date '+%Y年%m月%d日') 京东签到"
fi
desc=$(cat /www/JD_DailyBonus.htm | grep -E '签到号|签到概览|签到奖励|其他奖励|账号总计|其他总计' | sed 's/$/&\n/g')
desc=$(cat ${LOG_FILE} | grep -E '签到号|签到概览|签到奖励|其他奖励|账号总计|其他总计' | sed 's/$/&\n/g')
#serverchan
sckey=$(uci_get_by_type global serverchan)
if [ ! -z $sckey ]; then
@ -95,9 +95,9 @@ notify() {
}
run() {
echo -e $(date '+%Y-%m-%d %H:%M:%S %A') >$LOG_HTM 2>/dev/null
[ ! -f "/usr/bin/node" ] && echo -e "未安装node.js,请安装后再试!\nNode.js is not installed, please try again after installation!" >>$LOG_HTM && exit 1
(cd /usr/share/jd-dailybonus/ && node $JD_SCRIPT >>$LOG_HTM 2>/dev/null && notify &)
echo -e $(date '+%Y-%m-%d %H:%M:%S %A') >$LOG_FILE 2>/dev/null
[ ! -f "/usr/bin/node" ] && echo -e "未安装node.js,请安装后再试!\nNode.js is not installed, please try again after installation!" >>$LOG_FILE && exit 1
(cd /usr/share/jd-dailybonus/ && node $JD_SCRIPT >>$LOG_FILE 2>/dev/null && notify &)
}
save() {