1
0
forked from x/volcanos
This commit is contained in:
bergyu 2021-10-20 16:47:47 +08:00
parent 1711066127
commit adc60fd88f
5 changed files with 100 additions and 96 deletions

View File

@ -143,10 +143,8 @@ const html = {
} }
const lang = { const lang = {
STRING: "string", OBJECT: "object", FUNCTION: "function", STRING: "string", OBJECT: "object", FUNCTION: "function",
ENTER: "Enter", ENTER: "Enter",
} }
function shy(help, meta, list, cb) { function shy(help, meta, list, cb) {
var index = 0, args = arguments; function next(type) { var index = 0, args = arguments; function next(type) {
if (index < args.length && (!type || type == typeof args[index])) { if (index < args.length && (!type || type == typeof args[index])) {

View File

@ -3,7 +3,7 @@ const kit = require("utils/kit.js")
App({ App({
data: {}, conf: {serve: "https://shylinux.com/chat", space: ""}, data: {}, conf: {serve: "https://shylinux.com/chat", space: ""},
requests: function(cmd, data, cb) { wx.showLoading() requests: function(cmd, data, cb) { wx.showLoading()
this.request(cmd, data, function(msg) { wx.hideLoading(), can.base.isFunc(cb) && cb(msg) }) this.request(cmd, data, function(msg) { wx.hideLoading(), typeof cb == "function" && cb(msg) })
}, },
request: function(cmd, data, cb) { var app = this; data.sessid = app.conf.sessid, data.pod = app.conf.space request: function(cmd, data, cb) { var app = this; data.sessid = app.conf.sessid, data.pod = app.conf.space
wx.request({method: "POST", url: app.conf.serve+"/"+cmd, data: data, success: function(res) { var msg = res.data wx.request({method: "POST", url: app.conf.serve+"/"+cmd, data: data, success: function(res) { var msg = res.data
@ -22,7 +22,7 @@ App({
var line = {}; kit.List(msg.key, function(key, index) { var line = {}; kit.List(msg.key, function(key, index) {
line[key] = msg.value[index] line[key] = msg.value[index]
}) })
can.base.isFunc(cb) && cb(line, 0, 1) typeof cb == "function" && cb(line, 0, 1)
return res.push(line), res return res.push(line), res
} }

View File

@ -106,7 +106,7 @@ Page({
case "刷新": // 执行命令 case "刷新": // 执行命令
case "list": page.run(event, data.order); break case "list": page.run(event, data.order); break
default: default:
var cb = page.plugin[input.name]; can.base.isFunc(cb)? cb(event, page, data.order, input.name): var cb = page.plugin[input.name]; typeof cb == "function"? cb(event, page, data.order, input.name):
page.run(event, data.order, ["action", input.name].concat(kit.List(field.inputs, function(input) { page.run(event, data.order, ["action", input.name].concat(kit.List(field.inputs, function(input) {
if (input.type != "button") { return input.value } if (input.type != "button") { return input.value }
}))) })))
@ -124,7 +124,7 @@ Page({
} }
event._option = option event._option = option
var cb = page.plugin[input.name]; can.base.isFunc(cb)? cb(event, page, data.order, input.name): var cb = page.plugin[input.name]; typeof cb == "function"? cb(event, page, data.order, input.name):
page.run(event, data.order, ["action", input.name]) page.run(event, data.order, ["action", input.name])
return return
} }

View File

@ -21,22 +21,24 @@
"checkSiteMap": true, "checkSiteMap": true,
"uploadWithSourceMap": true, "uploadWithSourceMap": true,
"compileHotReLoad": false, "compileHotReLoad": false,
"useMultiFrameRuntime": false, "lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true,
"useApiHook": true, "useApiHook": true,
"useApiHostProcess": true,
"babelSetting": { "babelSetting": {
"ignore": [], "ignore": [],
"disablePlugins": [], "disablePlugins": [],
"outputPath": "" "outputPath": ""
}, },
"enableEngineNative": false, "enableEngineNative": false,
"bundle": false,
"useIsolateContext": true, "useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false, "userConfirmedBundleSwitch": false,
"packNpmManually": false, "packNpmManually": false,
"packNpmRelationList": [], "packNpmRelationList": [],
"minifyWXSS": true "minifyWXSS": true,
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.15.0", "libVersion": "2.15.0",

View File

@ -1,16 +1,20 @@
const lang = {
STRING: "string", OBJECT: "object", FUNCTION: "function",
ENTER: "Enter",
}
function shy(help, meta, list, cb) { function shy(help, meta, list, cb) {
var index = 0, args = arguments; function next(check) { var index = 0, args = arguments; function next(type) {
if (index < args.length && (!check || check == typeof args[index])) { if (index < args.length && (!type || type == typeof args[index])) {
return args[index++] return args[index++]
} }
} }
cb = args[args.length-1]||function() {} cb = args[args.length-1]||function() {}
cb.help = next("string") || "" cb.help = next(lang.STRING)||""
cb.meta = next("object") || {} cb.meta = next(lang.OBJECT)|| {}
cb.list = next("object") || [] cb.list = next(lang.OBJECT)||[]
return cb return cb
}; var _can_name = "" }
module.exports = { module.exports = {
EQ: function(obj, other) { EQ: function(obj, other) {
if (typeof obj != typeof other) { return false } if (typeof obj != typeof other) { return false }
@ -51,9 +55,9 @@ module.exports = {
}, },
List: function(list, cb, cbs) {var res = [], val; List: function(list, cb, cbs) {var res = [], val;
for (var i = 0; i < list.length; i++) { for (var i = 0; i < list.length; i++) {
can.base.isFunc(cb)? (val = cb(list[i], i, list)) != undefined && res.push(val): res.push(list[i]) typeof cb == "function"? (val = cb(list[i], i, list)) != undefined && res.push(val): res.push(list[i])
} }
return can.base.isFunc(cbs) && cbs(res), res return typeof cbs == "function" && cbs(res), res
}, },
Item: function(list, cb, cbs) { Item: function(list, cb, cbs) {
for (var k in list) { cb(k, list[k]) } for (var k in list) { cb(k, list[k]) }
@ -93,10 +97,10 @@ module.exports = {
interval = typeof interval == "object"? interval || []: [interval] interval = typeof interval == "object"? interval || []: [interval]
var timer = {stop: false}; function loop(timer, i) { var timer = {stop: false}; function loop(timer, i) {
if (timer.stop || i >= interval.length && interval.length >= 0) { if (timer.stop || i >= interval.length && interval.length >= 0) {
return can.base.isFunc(cbs) && cbs(timer, interval) return typeof cbs == "function" && cbs(timer, interval)
} }
return can.base.isFunc(cb) && cb(timer, interval.interval||interval[i], i, interval)? return typeof cb == "function" && cb(timer, interval.interval||interval[i], i, interval)?
can.base.isFunc(cbs) && cbs(timer, interval): setTimeout(function() { loop(timer, i+1) }, interval.interval||interval[i+1]) typeof cbs == "function" && cbs(timer, interval): setTimeout(function() { loop(timer, i+1) }, interval.interval||interval[i+1])
} }
setTimeout(function() { loop(timer, 0) }, interval.interval||interval[0]) setTimeout(function() { loop(timer, 0) }, interval.interval||interval[0])
return timer return timer