mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
opt some
This commit is contained in:
parent
1711066127
commit
adc60fd88f
2
proto.js
2
proto.js
@ -143,10 +143,8 @@ const html = {
|
||||
}
|
||||
const lang = {
|
||||
STRING: "string", OBJECT: "object", FUNCTION: "function",
|
||||
|
||||
ENTER: "Enter",
|
||||
}
|
||||
|
||||
function shy(help, meta, list, cb) {
|
||||
var index = 0, args = arguments; function next(type) {
|
||||
if (index < args.length && (!type || type == typeof args[index])) {
|
||||
|
@ -3,7 +3,7 @@ const kit = require("utils/kit.js")
|
||||
App({
|
||||
data: {}, conf: {serve: "https://shylinux.com/chat", space: ""},
|
||||
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
|
||||
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) {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ Page({
|
||||
case "刷新": // 执行命令
|
||||
case "list": page.run(event, data.order); break
|
||||
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) {
|
||||
if (input.type != "button") { return input.value }
|
||||
})))
|
||||
@ -124,7 +124,7 @@ Page({
|
||||
}
|
||||
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])
|
||||
return
|
||||
}
|
||||
|
@ -21,22 +21,24 @@
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"compileHotReLoad": false,
|
||||
"useMultiFrameRuntime": false,
|
||||
"lazyloadPlaceholderEnable": false,
|
||||
"useMultiFrameRuntime": true,
|
||||
"useApiHook": true,
|
||||
"useApiHostProcess": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"enableEngineNative": false,
|
||||
"bundle": false,
|
||||
"useIsolateContext": true,
|
||||
"useCompilerModule": true,
|
||||
"userConfirmedUseCompilerModuleSwitch": false,
|
||||
"userConfirmedBundleSwitch": false,
|
||||
"packNpmManually": false,
|
||||
"packNpmRelationList": [],
|
||||
"minifyWXSS": true
|
||||
"minifyWXSS": true,
|
||||
"disableUseStrict": false,
|
||||
"showES6CompileOption": false,
|
||||
"useCompilerPlugins": false
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.15.0",
|
||||
|
@ -1,16 +1,20 @@
|
||||
const lang = {
|
||||
STRING: "string", OBJECT: "object", FUNCTION: "function",
|
||||
ENTER: "Enter",
|
||||
}
|
||||
function shy(help, meta, list, cb) {
|
||||
var index = 0, args = arguments; function next(check) {
|
||||
if (index < args.length && (!check || check == typeof args[index])) {
|
||||
var index = 0, args = arguments; function next(type) {
|
||||
if (index < args.length && (!type || type == typeof args[index])) {
|
||||
return args[index++]
|
||||
}
|
||||
}
|
||||
|
||||
cb = args[args.length-1]||function() {}
|
||||
cb.help = next("string") || ""
|
||||
cb.meta = next("object") || {}
|
||||
cb.list = next("object") || []
|
||||
cb.help = next(lang.STRING)||""
|
||||
cb.meta = next(lang.OBJECT)|| {}
|
||||
cb.list = next(lang.OBJECT)||[]
|
||||
return cb
|
||||
}; var _can_name = ""
|
||||
}
|
||||
module.exports = {
|
||||
EQ: function(obj, other) {
|
||||
if (typeof obj != typeof other) { return false }
|
||||
@ -51,9 +55,9 @@ module.exports = {
|
||||
},
|
||||
List: function(list, cb, cbs) {var res = [], val;
|
||||
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) {
|
||||
for (var k in list) { cb(k, list[k]) }
|
||||
@ -93,10 +97,10 @@ module.exports = {
|
||||
interval = typeof interval == "object"? interval || []: [interval]
|
||||
var timer = {stop: false}; function loop(timer, i) {
|
||||
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)?
|
||||
can.base.isFunc(cbs) && cbs(timer, interval): setTimeout(function() { loop(timer, i+1) }, interval.interval||interval[i+1])
|
||||
return typeof cb == "function" && cb(timer, interval.interval||interval[i], i, interval)?
|
||||
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])
|
||||
return timer
|
||||
|
Loading…
x
Reference in New Issue
Block a user