1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58: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 = { 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

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