1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 08:48:06 +08:00
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 = {
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])) {

View File

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

View File

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

View File

@ -1,80 +1,82 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": false,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"useMultiFrameRuntime": false,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"bundle": false,
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "2.15.0",
"appid": "wxf4e5104d83476ed6",
"projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE",
"debugOptions": {
"hidedInDevtools": []
},
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"plugin": {
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": [
{
"id": 0,
"name": "pages/action/action",
"pathName": "pages/action/action",
"query": "river= e0a1eb&storm=c23ae3&title=hi.scan",
"scene": 1001
}
]
}
}
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"enhance": false,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"enableEngineNative": false,
"useIsolateContext": true,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false
},
"compileType": "miniprogram",
"libVersion": "2.15.0",
"appid": "wxf4e5104d83476ed6",
"projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE",
"debugOptions": {
"hidedInDevtools": []
},
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"plugin": {
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"list": [
{
"id": 0,
"name": "pages/action/action",
"pathName": "pages/action/action",
"query": "river= e0a1eb&storm=c23ae3&title=hi.scan",
"scene": 1001
}
]
}
}
}

View File

@ -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 = args[args.length-1]||function() {}
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