mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
add mp
This commit is contained in:
parent
ce82ffa815
commit
28895d9f77
19
const.js
19
const.js
@ -54,6 +54,7 @@ var ctx = {
|
||||
CONTEXT: "context", COMMAND: "command", CONFIG: "config", INPUTS: "inputs", FEATURE: "feature",
|
||||
CMDS: "cmds", INDEX: "index", ARGS: "args", STYLE: "style", DISPLAY: "display", ACTION: "action", RUN: "run",
|
||||
EXTRA_INDEX: "extra.index", EXTRA_ARGS: "extra.args",
|
||||
FEATURE_TRANS: "feature._trans",
|
||||
}
|
||||
var mdb = {FOREACH: "*", RANDOMS: "%",
|
||||
DICT: "dict", META: "meta", HASH: "hash", LIST: "list",
|
||||
@ -171,6 +172,9 @@ var nfs = {
|
||||
WIKI_PORTAL: "/wiki/portal/",
|
||||
CHAT_PORTAL: "/chat/portal/",
|
||||
DF: ice.DF, PS: ice.PS, PT: ice.PT,
|
||||
|
||||
CHAT_RIVER: "/chat/river/",
|
||||
CHAT_ACTION: "/chat/action/",
|
||||
}
|
||||
var cli = {
|
||||
RUNTIME: "runtime", SYSTEM: "system", DAEMON: "daemon", ORDER: "order", BUILD: "build", OPENS: "opens",
|
||||
@ -252,6 +256,13 @@ var chat = {
|
||||
|
||||
_INIT: "_init", _DELAY_INIT: "_delay_init",
|
||||
_TRANS: "_trans", _STYLE: "_style", _ENGINE: "_engine", _SEARCH: "_search", _NAMES: "_names", _TOAST: "_toast",
|
||||
|
||||
PAGES_RIVER: "/pages/river/river",
|
||||
PAGES_ACTION: "/pages/action/action",
|
||||
PAGES_INSERT: "/pages/insert/insert",
|
||||
WX_LOGIN_SESS: "/chat/wx/login/action/sess",
|
||||
WX_LOGIN_USER: "/chat/wx/login/action/user",
|
||||
WX_LOGIN_SCAN: "/chat/wx/login/action/scan",
|
||||
}
|
||||
var team = {
|
||||
TASK: "task", PLAN: "plan",
|
||||
@ -341,3 +352,11 @@ var svg = {
|
||||
M: "M", Q: "Q", T: "T",
|
||||
TEXT_LENGTH: "textLength",
|
||||
}
|
||||
try { module.exports = {
|
||||
kit, ice,
|
||||
ctx, mdb, web, aaa,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
} } catch {}
|
||||
|
@ -226,8 +226,8 @@ fieldset>legend>i { margin-right:var(--input-margin); }
|
||||
div.item>i:first-child { margin-right:var(--button-margin); height:var(--action-height); }
|
||||
form.option>div.item.icon { position:relative; height:var(--action-height); overflow:hidden; }
|
||||
form.option>div.item.icon { font-size:var(--icon-font-size); padding:0 var(--input-padding); }
|
||||
form.option>div.item.icon.refresh { font-size:28px; height:calc(var(--action-height) - 5px); }
|
||||
form.option>div.item.icon.goback { font-size:28px; height:calc(var(--action-height) - 5px); }
|
||||
form.option>div.item.icon.refresh { font-size:28px; line-height:28px; height:calc(var(--action-height) - 5px); }
|
||||
form.option>div.item.icon.goback { font-size:28px; line-height:28px; height:calc(var(--action-height) - 5px); }
|
||||
form.option>div.item.icon.play { font-size:16px; }
|
||||
body.mobile form.option>div.item.icon.prev { margin-top:4px; height:28px; }
|
||||
body.mobile form.option>div.item.icon.next { margin-top:4px; height:28px; }
|
||||
|
@ -119,7 +119,7 @@ Volcanos("base", {
|
||||
isFunc: function(val) { return typeof val == code.FUNCTION },
|
||||
isUndefined: function(val) { return val == undefined },
|
||||
isNull: function(val) { return val == null },
|
||||
toLast: function(list, value) {
|
||||
toLast: function(list, value) { if (!list) { return }
|
||||
for (var i = 0; i < list.length-1; i++) { if (list[i] == value) {
|
||||
for (i; i < list.length-1; i++) { list[i] = list[i+1] }
|
||||
list[list.length-1] = value
|
||||
|
@ -12,8 +12,7 @@ Volcanos("date", {
|
||||
for (var day = new Date(last); day.getDay() != 0 && day < end; day.setDate(day.getDate()+1)) { _cb(day, mdb.NEXT) }
|
||||
return list
|
||||
},
|
||||
})
|
||||
Volcanos("date", { // @1900-2100区间内的公历转农历
|
||||
// @1900-2100区间内的公历转农历
|
||||
solar2lunar: function(date) { var y = date.getFullYear(), m = date.getMonth()+1, d = date.getDate()
|
||||
var day = (Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()) - Date.UTC(1900,0,31))/86400000
|
||||
for (var year = 1900, days = 0; year < 2101 && day > 0; year++) { days = this.lYearDays(year), day -= days } if (day < 0) { day += days, year-- }
|
||||
|
@ -275,5 +275,5 @@ Volcanos("misc", {
|
||||
_args: function(level, arg) { var args = [this._time(), this.FileLine(this._skip+1, 3)].concat(level? [level]: [])
|
||||
for (var i in arg) { arg[i] != undefined && args.push(arg[i]) } return args
|
||||
},
|
||||
_signal: function(args) { this._list.push(args) }, _list: [], _skip: navigator.userAgent.indexOf("Chrome") > -1? 3: 3,
|
||||
_signal: function(args) { this._list.push(args) }, _list: [], _skip: navigator && navigator.userAgent.indexOf("Chrome") > -1? 3: 3,
|
||||
})
|
||||
|
@ -3,12 +3,18 @@ const core = require("utils/lib/core.js")
|
||||
const misc = require("utils/lib/misc.js")
|
||||
const page = require("utils/lib/page.js")
|
||||
const user = require("utils/lib/user.js")
|
||||
const misc_wx = require("utils/lib/misc-wx.js")
|
||||
const page_wx = require("utils/lib/page-wx.js")
|
||||
const user_wx = require("utils/lib/user-wx.js")
|
||||
const zh_cn = require("utils/lib/zh-cn.js")
|
||||
const conf = require("conf.js")
|
||||
|
||||
App({
|
||||
data: {}, conf: conf, base: base, core: core, misc: misc, page: page, user: user,
|
||||
onLaunch: function() {
|
||||
const res = wx.getSystemInfoSync()
|
||||
App({conf: conf,
|
||||
base: base, core: core,
|
||||
misc: base.Copy(misc, misc_wx),
|
||||
page: base.Copy(page, page_wx),
|
||||
user: base.Copy(user, base.Copy(user_wx, zh_cn)),
|
||||
onLaunch: function() { const res = wx.getSystemInfoSync()
|
||||
this.conf.platform = res.platform
|
||||
this.conf.brand = res.brand
|
||||
this.conf.model = res.model
|
||||
|
@ -1,6 +0,0 @@
|
||||
module.exports = {
|
||||
appid: "wxf4e5104d83476ed6",
|
||||
serve: "https://2021.shylinux.com",
|
||||
module: "shylinux.com/x/volcanos",
|
||||
version: "v0.3.1",
|
||||
}
|
@ -1,9 +1,5 @@
|
||||
const {ice, ctx, mdb, web, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
|
||||
"刷新": function(event, can) { can.onaction.refresh(event, can) },
|
||||
"扫码": function(event, can) { can.user.agent.scanQRCode(can) },
|
||||
"清屏": function(event, can) { can.core.List(can.ui.data.list, function(item) { delete(item.msg) }), can.page.setData(can) },
|
||||
})
|
||||
Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"]})
|
||||
Volcanos._init()
|
||||
|
@ -17,7 +17,7 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码"],
|
||||
if (input.type == html.SELECT) {
|
||||
input.values = input.values || can.core.Split(input.value)
|
||||
}
|
||||
}), can.page.setData(can, can.data.insert.list)
|
||||
}), can.misc.setData(can, can.data.insert.list)
|
||||
},
|
||||
onaction: function(event, can, button, data) { var name = data.name;
|
||||
(can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
|
||||
|
@ -7,21 +7,21 @@ Volcanos(chat.ONIMPORT, {
|
||||
},
|
||||
})
|
||||
Volcanos("onaction", {list: ["刷新", "扫码", "登录"],
|
||||
"刷新": function(event, can) { can.onaction.refresh(event, can) },
|
||||
"扫码": function(event, can) { can.user.agent.scanQRCode(can) },
|
||||
"登录": function(event, can) {
|
||||
can.user.info = {}, can.misc.localStorage(can, ice.MSG_SESSID, can.conf.sessid = "")
|
||||
can.user.userinfo(can, function() { can.onaction.refresh(event, can) })
|
||||
},
|
||||
// "刷新": function(event, can) { can.onaction.refresh(event, can) },
|
||||
// "扫码": function(event, can) { can.user.agent.scanQRCode(can) },
|
||||
// "登录": function(event, can) {
|
||||
// can.user.info = {}, can.misc.localStorage(can, ice.MSG_SESSID, can.conf.sessid = "")
|
||||
// can.user.userinfo(can, function() { can.onaction.refresh(event, can) })
|
||||
// },
|
||||
refresh: function(event, can) { can.run(event, [], function(msg) { can.onimport._init(can, msg) }) },
|
||||
onaction: function(event, can, button, data) { var name = data.name;
|
||||
(can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
|
||||
},
|
||||
ondetail: function(event, can, button, data) { var index = data.index
|
||||
var item = can.ui.data.list[index]; item._show = !item._show
|
||||
if (item.list) { return can.page.setData(can) }
|
||||
if (item.list) { return can.misc.setData(can) }
|
||||
can.run(event, [item.hash, chat.STORM], function(msg) {
|
||||
item.list = msg.Table(), can.page.setData(can)
|
||||
item.list = msg.Table(), can.misc.setData(can)
|
||||
})
|
||||
},
|
||||
onchange: function(event, can, button, data) { var index = data.index, i = data.i
|
||||
|
@ -1,64 +0,0 @@
|
||||
{
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"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,
|
||||
"showES6CompileOption": 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",
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"editorSetting": {
|
||||
"tabIndent": "insertSpaces",
|
||||
"tabSize": 2
|
||||
},
|
||||
"condition": {
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "pages/action/action",
|
||||
"pathName": "pages/action/action",
|
||||
"query": "river= e0a1eb&storm=c23ae3&title=hi.scan",
|
||||
"scene": 1001
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
{
|
||||
"projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE",
|
||||
"setting": {
|
||||
"compileHotReLoad": true
|
||||
},
|
||||
"condition": {
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "",
|
||||
"pathName": "pages/action/action",
|
||||
"query": "index=web.chat.wx.ide",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"name": "web.dream",
|
||||
"pathName": "pages/action/action",
|
||||
"query": "index=web.dream&debug=true",
|
||||
"launchMode": "default",
|
||||
"scene": 1001
|
||||
},
|
||||
{
|
||||
"name": "cli.qrcode",
|
||||
"pathName": "pages/action/action",
|
||||
"query": "index=cli.qrcode",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"name": "cli.runtime",
|
||||
"pathName": "pages/action/action",
|
||||
"query": "index=cli.runtime&serve=http%3A%2F%2F192.168.10.12%3A9020&debug=true",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
{
|
||||
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||
"rules": [{
|
||||
"action": "allow",
|
||||
"page": "*"
|
||||
}]
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
var kit = {proto: function(sub, sup) { return sub.__proto__ = sup, sub },
|
||||
Dict: function() { var res = {}, arg = arguments; for (var i = 0; i < arg.length; i += 2) { var key = arg[i]
|
||||
if (typeof key == "object") { i--
|
||||
if (key.length == undefined) {
|
||||
for (var k in key) { res[k] = key[k] }
|
||||
} else {
|
||||
for (var j = 0; j < key.length; j += 2) { res[key[j]] = key[j+1] }
|
||||
}
|
||||
} else if (typeof key == "string" && key) { res[key] = arg[i+1] }
|
||||
} return res },
|
||||
}
|
||||
var ice = {
|
||||
TB: "\t", SP: " ", DF: ":", EQ: "=", AT: "@", QS: "?", PS: "/", PT: ".", FS: ",", NL: "\n", LT: "<", GT: ">",
|
||||
OK: "ok", TRUE: "true", FALSE: "false", SUCCESS: "success", FAILURE: "failure", PROCESS: "process",
|
||||
|
||||
HTTP: "http", HELP: "help",
|
||||
MAIN: "main", AUTO: "auto",
|
||||
LIST: "list", BACK: "back",
|
||||
|
||||
CAN: "can", POD: "pod", CTX: "ctx", CMD: "cmd", ARG: "arg",
|
||||
|
||||
MSG_FIELDS: "fields", MSG_SESSID: "sessid",
|
||||
MSG_DETAIL: "detail", MSG_OPTION: "option", MSG_APPEND: "append", MSG_RESULT: "result",
|
||||
MSG_ACTION: "_action", MSG_STATUS: "_status",
|
||||
MSG_THEME: "sess.theme",
|
||||
MSG_DEBUG: "debug",
|
||||
}
|
||||
var ctx = {
|
||||
CONTEXT: "context", COMMAND: "command", CONFIG: "config", INPUTS: "inputs", FEATURE: "feature", FEATURE_TRANS: "feature._trans",
|
||||
CMDS: "cmds", INDEX: "index", ARGS: "args", STYLE: "style", DISPLAY: "display", ACTION: "action", RUN: "run",
|
||||
EXTRA_INDEX: "extra.index", EXTRA_ARGS: "extra.args",
|
||||
}
|
||||
var mdb = {
|
||||
EQ: ice.EQ, FS: ice.FS,
|
||||
TIME: "time", ZONE: "zone", ID: "id",
|
||||
TYPE: "type", NAME: "name", TEXT: "text", ICON: "icon", ICONS: "icons",
|
||||
KEY: "key", VALUE: "value", STATUS: "status", EXPIRE: "expire", EXTRA: "extra",
|
||||
DATA: "data", VIEW: "view", ORDER: "order",
|
||||
}
|
||||
var web = {
|
||||
OPEN: "open", LINK: "link", HTTP: "http", DOMAIN: "domain", URL: "url",
|
||||
DRAW: "draw", PLAY: "play", CLEAR: "clear", REFRESH: "refresh", RESIZE: "resize", FILTER: "filter",
|
||||
}
|
||||
var aaa = {
|
||||
}
|
||||
var lex = {
|
||||
NL: "\n",
|
||||
}
|
||||
var tcp = {
|
||||
}
|
||||
var nfs = {
|
||||
DF: ice.DF, PS: ice.PS, PT: ice.PT,
|
||||
CHAT_RIVER: "/chat/river/",
|
||||
CHAT_ACTION: "/chat/action/",
|
||||
PATH: "path",
|
||||
}
|
||||
var cli = {
|
||||
}
|
||||
var log = {
|
||||
INFO: "info",
|
||||
}
|
||||
var code = {
|
||||
COMMENT: "comment", KEYWORD: "keyword",
|
||||
PACKAGE: "package", DATATYPE: "datatype", FUNCTION: "function", CONSTANT: "constant",
|
||||
STRING: "string", NUMBER: "number", BOOLEAN: "boolean", OBJECT: "object", ARRAY: "array", UNDEFINED: "undefined",
|
||||
META: "Meta", ALT: "Alt", CONTROL: "Control", SHIFT: "Shift", TAB: "Tab", ESCAPE: "Escape", ENTER: "Enter",
|
||||
CMD: "Cmd", CTRL: "Ctrl", SPACE: "Space", BACKSPACE: "Backspace", ESC: "Esc", PS: "/",
|
||||
}
|
||||
var wiki = {
|
||||
}
|
||||
var chat = {
|
||||
SHARE: "share", RIVER: "river", STORM: "storm", FIELD: "field", TOOL: "tool",
|
||||
|
||||
ONENGINE: "onengine", ONDAEMON: "ondaemon", ONAPPEND: "onappend", ONLAYOUT: "onlayout", ONMOTION: "onmotion", ONKEYMAP: "onkeymap",
|
||||
ONIMPORT: "onimport", ONACTION: "onaction", ONDETAIL: "ondetail", ONEXPORT: "onexport",
|
||||
ONSYNTAX: "onsyntax", ONFIGURE: "onfigure", ONPLUGIN: "onplugin",
|
||||
|
||||
PAGES_RIVER: "/pages/river/river",
|
||||
PAGES_ACTION: "/pages/action/action",
|
||||
PAGES_INSERT: "/pages/insert/insert",
|
||||
WX_LOGIN_SESS: "/chat/wx/login/action/sess",
|
||||
WX_LOGIN_USER: "/chat/wx/login/action/user",
|
||||
WX_LOGIN_SCAN: "/chat/wx/login/action/scan",
|
||||
}
|
||||
var team = {
|
||||
}
|
||||
var mall = {
|
||||
}
|
||||
var http = {
|
||||
GET: "GET", PUT: "PUT", POST: "POST", DELETE: "DELETE",
|
||||
Accept: "Accept", ContentType: "Content-Type", ApplicationJSON: "application/json", ApplicationFORM: "application/x-www-form-urlencoded",
|
||||
}
|
||||
var html = {
|
||||
SELECT: "select", INPUT: "input", TEXT: "text", FILE: "file", TEXTAREA: "textarea", BUTTON: "button",
|
||||
VALUE: "value",
|
||||
}
|
||||
module.exports = {
|
||||
kit, ice,
|
||||
ctx, mdb, web, aaa,
|
||||
lex,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html,
|
||||
}
|
106
publish/client/mp/utils/frame.js
Normal file
106
publish/client/mp/utils/frame.js
Normal file
@ -0,0 +1,106 @@
|
||||
const {kit, ice,
|
||||
ctx, mdb, web, aaa,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
} = require("const.js")
|
||||
const {shy, Volcanos} = require("proto.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONIMPORT, {})
|
||||
Volcanos(chat.ONACTION, {
|
||||
"刷新": function(event, can) { can.onaction.refresh(event, can) },
|
||||
"扫码": function(event, can) { can.user.agent.scanQRCode(can) },
|
||||
"清屏": function(event, can) { can.core.List(can.ui.data.list, function(item) { delete(item.msg) }), can.misc.setData(can) },
|
||||
"登录": function(event, can) {
|
||||
can.user.info = {}, can.misc.localStorage(can, ice.MSG_SESSID, can.conf.sessid = "")
|
||||
can.user.userinfo(can, function() { can.onaction.refresh(event, can) })
|
||||
},
|
||||
_refresh: function(event, can, order) { can.misc.setData(can)
|
||||
can.onaction.onAction({}, can, ice.LIST, {order: order, name: ice.LIST})
|
||||
},
|
||||
_reload: function(can, msg) {
|
||||
can.misc.ParseCmd(can, msg)
|
||||
},
|
||||
refresh: function(event, can) {
|
||||
can.onaction._apis = "", can.onaction._cmds = []
|
||||
if (can.db.share) { can.onaction._apis = "/share/"+can.db.share
|
||||
can.run(event, [ctx.ACTION, ctx.COMMAND], function(msg) {
|
||||
can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onaction._reload(can, msg)
|
||||
})
|
||||
} else if (can.db.river && can.db.storm) {
|
||||
can.onaction._cmds = [can.db.river, can.db.storm]
|
||||
can.run(event, [], function(msg) { can.onaction._reload(can, msg) })
|
||||
} else {
|
||||
can.run(event, [ctx.ACTION, ctx.COMMAND, can.db.cmd||can.db.index||"cli.qrcode"], function(msg) {
|
||||
can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onaction._reload(can, msg)
|
||||
})
|
||||
}
|
||||
},
|
||||
onaction: function(event, can, button, data) { var name = data.name;
|
||||
(can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
|
||||
},
|
||||
onInputs: function(event, can, button, data) { var order = data.order, index = data.index
|
||||
var input = can.ui.data.list[order||0].inputs[index||0]
|
||||
input.value = event.detail.value
|
||||
},
|
||||
onChange: function(event, can, button, data) { var order = data.order, index = data.index
|
||||
var input = can.ui.data.list[order||0].inputs[index||0]
|
||||
input.value = input.values[parseInt(event.detail.value)]
|
||||
can.onaction._refresh(event, can, order)
|
||||
},
|
||||
onAction: function(event, can, button, data) { var order = data.order, name = data.name
|
||||
var field = can.ui.data.list[order||0], msg = can.request(event)
|
||||
if (field.feature[name]) { if (can.base.isIn(name, mdb.CREATE, mdb.INSERT)) { msg._method = http.PUT }
|
||||
return can.data.insert = {field: field, name: name, list: field.feature[name], cb: function(res) {
|
||||
can.run(event, can.base.Simple([field.id||field.index, ctx.ACTION, name], res), function(msg) {
|
||||
can.onaction._refresh(event, can, order)
|
||||
})
|
||||
}}, can.user.jumps(chat.PAGES_INSERT)
|
||||
} field._history = field._history||[]
|
||||
switch (name) {
|
||||
case ice.BACK: field._history.pop(); var ls = field._history.pop()||[], i = 0
|
||||
can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { input.value = ls[i++]||"" } })
|
||||
can.onaction._refresh(event, can, order); break
|
||||
case ctx.RUN: break
|
||||
case ice.LIST:
|
||||
case web.REFRESH: msg._method = http.GET; break
|
||||
default: msg.Option(ctx.ACTION, name)
|
||||
}
|
||||
var cmd = can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { return input.value } })
|
||||
for (var i = cmd.length-1; i > 0; i--) { if (cmd[i] === "") { cmd.pop() } else { break } }
|
||||
function eq(to, from) { if (!to) { return false } if (to.length != from.length) { return false }
|
||||
for (var i = 0; i < to.length; i++) { if (to[i] != from[i]) { return false } } return true
|
||||
} eq(field._history[field._history.length-1], cmd) || field._history.push(cmd)
|
||||
can.run(event, [field.id||field.index].concat(cmd), function(msg) { can.onimport._init && can.onimport._init(can, msg)
|
||||
msg._head = can.core.List(msg.append, function(item) { return can.user.trans(can, item, field, html.INPUT) })
|
||||
can.core.Item(msg._view, function(key, value) { can.core.List(value, function(value) { can.core.List(value, function(input, i) {
|
||||
if (input.type == html.BUTTON) { input.value = can.user.trans(can, input.value||input.name, field) }
|
||||
if (input._type == html.TEXT) { input._text = can.user.trans(can, input._text, field, html.VALUE) }
|
||||
}) }) })
|
||||
msg._status = can.core.List(can.base.Obj(msg.Option(ice.MSG_STATUS)), function(item) { return item })
|
||||
msg._action = can.core.List(can.base.Obj(msg.Option(ice.MSG_ACTION)), function(item) {
|
||||
if (typeof item == code.STRING) { return {type: html.BUTTON, name: item, value: can.user.trans(can, item)} }
|
||||
return item.value = can.user.trans(can, item.value||item.name), item
|
||||
}), field.msg = msg, can.misc.setData(can)
|
||||
})
|
||||
},
|
||||
onDetail: function(event, can, button, data) { var order = data.order, name = data.name, value = data.value, input = data.input
|
||||
var field = can.ui.data.list[order||0]
|
||||
if (input && input.type == html.BUTTON) { var msg = can.request(event, field.msg.Table()[data.index])
|
||||
if (can.base.isIn(name, mdb.REMOVE, mdb.DELETE)) { msg._method = http.DELETE }
|
||||
var _input = {}; can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { _input[input.name] = input.value } }), can.request(event, _input)
|
||||
if (field.feature[input.name]) {
|
||||
can.onAction(event, can, input.name, {order: order, name: input.name})
|
||||
} else {
|
||||
can.run(event, [field.id||field.index, ctx.ACTION, input.name], function(msg) {
|
||||
can.onaction._refresh(event, can, order)
|
||||
})
|
||||
} return
|
||||
}
|
||||
can.core.List(field.inputs, function(input) {
|
||||
if (input.name == name) { input.value = value, can.onaction._refresh(event, can, order) }
|
||||
})
|
||||
},
|
||||
})
|
||||
module.exports = Volcanos._page
|
@ -1,70 +0,0 @@
|
||||
const {ice, mdb, web, nfs, code, http} = require("../const.js")
|
||||
const {Volcanos} = require("../proto.js")
|
||||
module.exports =
|
||||
Volcanos("base", {
|
||||
Obj: function(val, def) {
|
||||
try {
|
||||
if (typeof val == code.STRING) { if (val == "") { return def } val = JSON.parse(val) }
|
||||
if (typeof val == code.NUMBER) { return [val] }
|
||||
if (val.length > 0) { return val } for (var k in val) { return val } return def
|
||||
} catch (e) { return typeof val == code.STRING && val.split(mdb.FS) || def }
|
||||
},
|
||||
Copy: function(to, from, merge) { if (!from) { return to }
|
||||
if (arguments.length == 2 || typeof merge == code.BOOLEAN) { for (var k in from) { if (k == undefined) { continue }
|
||||
if (merge && to.hasOwnProperty(k) && to[k] != undefined && to[k] != "") { continue }
|
||||
if (from[k] === "") { delete(to[k]) } else { to[k] = from[k] }
|
||||
} return to } for (var i = 2; i < arguments.length; i++) { var k = arguments[i]; to[k] = from[k] } return to
|
||||
},
|
||||
Args: function() { var res = [], arg = arguments; function encode(k, v) { k && v != undefined && v != null && res.push(encodeURIComponent(k)+mdb.EQ+encodeURIComponent(v)) }
|
||||
for (var i = 0; i < arg.length; i += 2) { if (typeof arg[i] == code.OBJECT) {
|
||||
if (arg[i].length > 0) { for (var j = 0; j < arg[i].length; j += 2) { encode(arg[i][j], arg[i][j+1]) } } else { for (var k in arg[i]) { encode(k, arg[i][k]) } } i--
|
||||
} else { encode(arg[i], arg[i+1]) } } return res.join("&")
|
||||
},
|
||||
_parse: function(url, res) { var list = url.split("#")[0].split(ice.QS); res = res||{}, res._origin = list[0]
|
||||
list[1] && list[1].split("&").forEach(function(item) { var ls = item.split(mdb.EQ); res[decodeURIComponent(ls[0])] = decodeURIComponent(ls[1]) })
|
||||
return res
|
||||
},
|
||||
MergeURL: function(url) { var arg = this._parse(url); delete(arg._origin); for (var i = 1; i < arguments.length; i += 2) { delete(arg[arguments[i]]) }
|
||||
var arg = this.Args.apply(this, [arg].concat(Array.prototype.slice.call(arguments, 1))); return url.split(ice.QS)[0]+(arg? ice.QS+arg: "")
|
||||
},
|
||||
ParseURL: function(url) { var res = this._parse(url); res.link = url, res.origin = res._origin; return res },
|
||||
ParseJSON: function(str) {
|
||||
var res; if (typeof str == code.OBJECT) { return str }
|
||||
if (str.indexOf(ice.HTTP) == 0) {
|
||||
var res = this._parse(str, {type: web.LINK, name: "", text: str})
|
||||
return res.name = res._origin.split("://").pop().split(nfs.PS)[0], res
|
||||
}
|
||||
try { res = JSON.parse(str), res.text = res.text||str, res.type = res.type||nfs.JSON } catch (e) { res = {type: mdb.TEXT, text: str} } return res
|
||||
},
|
||||
Simple: function() { var res = []; for (var i = 0; i < arguments.length; i++) { var val = arguments[i]; switch (typeof val) {
|
||||
case code.OBJECT: if (val.length > 0) { res = res.concat(val); break }
|
||||
for (var k in val) { k && val[k] && res.push(k, val[k]) } break
|
||||
default: res.push(val)
|
||||
} } return res },
|
||||
AddUniq: function(list, value) { list = list||[], list.indexOf(value) == -1 && list.push(value); return list },
|
||||
isIn: function(item) { var arg = arguments; for (var i = 1; i < arg.length; i++) {
|
||||
if (typeof arg[i] == code.OBJECT && arg[i].length > 0 && arg[i].indexOf(item) > -1) { return true }
|
||||
if (item == arg[i]) { return true }
|
||||
} },
|
||||
isString: function(val) { return typeof val == code.STRING },
|
||||
isObject: function(val) { return typeof val == code.OBJECT },
|
||||
isArray: function(val) { return Array.isArray(val) },
|
||||
isFunc: function(val) { return typeof val == code.FUNCTION },
|
||||
toLast: function(list, value) { if (!list || list.length == 0) { return }
|
||||
for (var i = 0; i < list.length-1; i++) { if (list[i] == value) {
|
||||
for (i; i < list.length-1; i++) { list[i] = list[i+1] }
|
||||
list[list.length-1] = value
|
||||
} }
|
||||
},
|
||||
trimPrefix: function(str, pre) { if (typeof str != code.STRING) { return str } var arg = arguments, callee = arg.callee
|
||||
if (arg.length > 2) { for (var i = 1; i < arg.length; i++) { str = callee(str, arg[i]) } return str }
|
||||
if (str.indexOf(pre) == -1) { return str } return str.slice(pre.length)
|
||||
},
|
||||
trimSuffix: function(str, end) { while (str) { var index = str.lastIndexOf(end)
|
||||
if (index == -1 || index+end.length != str.length) { break } str = str.slice(0, index)
|
||||
} return str },
|
||||
trim: function(arg) { if (this.isString(arg)) { return arg.trim() }
|
||||
if (this.isArray(arg)) { for (var i = arg.length-1; i >= 0; i--) { if (!arg[i]) { arg.pop() } else { break } } } return arg
|
||||
},
|
||||
random: function(max, min) { return min = min||0, parseInt(Math.random()*(max-min))+min },
|
||||
})
|
@ -1,89 +0,0 @@
|
||||
const {ice, mdb, nfs, code, http} = require("../const.js")
|
||||
const {shy, Volcanos} = require("../proto.js")
|
||||
module.exports =
|
||||
Volcanos("core", {
|
||||
Keys: function() { var list = []
|
||||
for (var i = 0; i < arguments.length; i++) { var v = arguments[i]; switch (typeof v) {
|
||||
case code.OBJECT: for (var j = 0; j < v.length; j++) { list.push(v[j]) } break
|
||||
case code.NUMBER: list.push(v+""); break
|
||||
case code.FUNCTION: v = v()
|
||||
default: v && list.push(v+"")
|
||||
} } return list.join(nfs.PT)
|
||||
},
|
||||
Value: function(data, key, value) { if (data == undefined) { return } if (key == undefined) { return data }
|
||||
if (typeof key == code.OBJECT) { if (key.length != undefined) { key = key.join(nfs.PT) } else { for (var k in key) { arguments.callee.call(this, data, k, key[k]) } return data } }
|
||||
if (value != undefined) { var _node = data, keys = key.split(nfs.PT)
|
||||
for (var i = 0; i < keys.length; i++) { var _next = _node[keys[i]]||{}; _node[keys[i]] = _next
|
||||
if (i < keys.length - 1) { _node = _next } else { _node[keys[i]] = value }
|
||||
}
|
||||
}
|
||||
var node = data, keys = key.split(nfs.PT); while (node && keys.length > 0) {
|
||||
if (keys[0] == "-1") { keys[0] = node.length-1 } node = node[keys[0]], keys = keys.slice(1)
|
||||
} return node == undefined? data[key]: node
|
||||
},
|
||||
Split: function(str) { if (!str || !str.length) { return [] }
|
||||
var opt = {detail: false}, arg = []; for (var i = 1; i < arguments.length; i++) { var v = arguments[i]; typeof v == code.OBJECT? opt = v: arg.push(v) }
|
||||
function _list(str) { var res = {}; for (var i = 0; i < str.length; i++) { res[str[i]] = true }; return res }
|
||||
var space = _list(arg[0]||"\t ,;\n") // 空白符
|
||||
var block = _list(arg[1]||"{[()]}") // 分隔符
|
||||
var quote = _list(arg[2]||"'\"`") // 引用符
|
||||
var trans = _list(arg[3]||"\\") // 转义符
|
||||
var res = [], begin = 0; function push(obj) { obj && res.push(typeof obj == code.STRING || opt.detail? obj: obj.text), begin = -1 }
|
||||
for (var s = "", i = 0; i < str.length; i++) {
|
||||
if (space[str[i]]) { if (s) { continue }
|
||||
begin > -1 && push(str.slice(begin, i)), opt.detail && push({type: code.SPACE, text: str.slice(i, i+1)})
|
||||
} else if (block[str[i]]) { if (s) { continue }
|
||||
begin > -1 && push(str.slice(begin, i)), push(str.slice(i, i+1))
|
||||
} else if (quote[str[i]]) {
|
||||
if (s == "") {
|
||||
begin > -1 && push(str.slice(begin, i)), s = str[i], begin = i+1
|
||||
} else if (s == str[i]) {
|
||||
push({type: code.STRING, text: str.slice(begin, i), left: s, right: str[i]}), s = "", begin = -1
|
||||
}
|
||||
} else if (trans[str[i]]) { begin == -1 && (begin = i), i++
|
||||
} else { begin == -1 && (begin = i) }
|
||||
} return begin > -1 && (s? push({type: code.STRING, text: str.slice(begin), left: s, right: ""}): push(str.slice(begin))), res
|
||||
},
|
||||
CallFunc: function(func, args, mod) { args = args||{}; var can = args["can"]||args[0], msg = args["msg"]||args[1], cb = args["cb"]
|
||||
if (Array.isArray(args)) { this.List(args, function(arg) { if (!arg) { return } if (arg.request && arg.run) { can = arg } else if (arg.Append && arg.Result) { msg = arg } else if (typeof arg == code.FUNCTION) { cb = arg } }) }
|
||||
func = typeof func == code.FUNCTION? func: typeof func == code.OBJECT && func.length > 0? this.Value(func[0], this.Keys(func.slice(1))): typeof func == code.STRING? this.Value(mod||can, func): null
|
||||
if (typeof func != code.FUNCTION) { if (typeof cb == code.FUNCTION) { cb() } return }
|
||||
var list = [], echo = false; args.length > 0? list = args: this.List(func.toString().split(")")[0].split("(")[1].split(mdb.FS), function(item, index) { item = item.trim(); if (item == "") { return }
|
||||
list.push(args[item] || msg&&msg.Option&&msg.Option(item) || can&&can.Conf&&can.Conf(item) || null); if (item == "cb") { echo = true }
|
||||
}); var res = func.apply(mod||can, list); if (msg && msg.Defer) { msg.Defer() }
|
||||
if (!echo && typeof cb == code.FUNCTION) { res && msg&&msg.Echo&&msg.Echo(res), arguments.callee.apply(this, [cb, {msg: msg, res: res}]) } return res
|
||||
},
|
||||
List: function(list, cb, interval, cbs) {
|
||||
if (typeof list == code.STRING) { list = [list] } else if (typeof list == code.NUMBER) { // [end cb interval]|[begin end interval]
|
||||
var begin = 0, end = list, step = typeof interval == code.NUMBER? interval: 1; if (typeof cb == code.NUMBER) { begin = list, end = cb, cb = null }
|
||||
list = []; for (var i = begin; i < end; i += step) { list.push(i) }
|
||||
} list = list||[]
|
||||
if (interval > 0) {
|
||||
function loop(i) { i >= list.length? typeof cbs == code.FUNCTION && cbs(list): cb(list[i], i, list), setTimeout(function() { loop(i+1) }, interval) }
|
||||
typeof cb == code.FUNCTION && list.length > 0 && setTimeout(function() { loop(0) }, interval/4)
|
||||
} else { var res = []
|
||||
for (var i = 0; i < list.length; i++) { var _res = typeof cb == code.FUNCTION? cb(list[i], i, list): list[i]; _res != undefined && res.push(_res) }
|
||||
list = res
|
||||
} return list
|
||||
},
|
||||
Item: function(obj, cb) { var list = []
|
||||
for (var k in obj) { var res = typeof cb == code.FUNCTION? cb(k, obj[k], list): k; res != undefined && list.push(res) }
|
||||
return list
|
||||
},
|
||||
ItemCB: function(meta, cb, can, item) { var list = []
|
||||
for (var k in meta) { if (k.indexOf("on") == 0 && typeof meta[k] == code.FUNCTION) { (function(k) { list.push(k)
|
||||
if (typeof cb == code.FUNCTION) {
|
||||
cb(k, meta[k])
|
||||
} else { cb[k] = function(event) { can.misc.Event(event, can, function(msg) {
|
||||
meta[k](event, can, item)
|
||||
}) } }
|
||||
})(k) } } return list
|
||||
},
|
||||
Timer: shy("定时器, value, [1,2,3,4], {delay, interval, length}", function(interval, cb, cbs) { var timer = {stop: false}
|
||||
function loop(i) { timer.stop || i >= interval.length && interval.length >= 0 || cb(timer, interval.interval||interval[i], i, interval)?
|
||||
typeof cbs == code.FUNCTION && cbs(timer, interval): setTimeout(function() { loop(i+1) }, interval.interval||interval[i+1])
|
||||
} interval = typeof interval == code.OBJECT? interval: [interval]; if (interval.interval == 0) { return cb(), timer }
|
||||
var delay = interval.delay||interval.interval/2||interval[0]
|
||||
return typeof cb == code.FUNCTION && (timer._timer = setTimeout(function() { loop(0) }, delay)), timer
|
||||
}),
|
||||
})
|
114
publish/client/mp/utils/lib/misc-wx.js
Normal file
114
publish/client/mp/utils/lib/misc-wx.js
Normal file
@ -0,0 +1,114 @@
|
||||
const {kit, ice,
|
||||
ctx, mdb, web, aaa,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
} = require("../const.js")
|
||||
const {shy, Volcanos} = require("../proto.js")
|
||||
module.exports =
|
||||
Volcanos("misc", {
|
||||
ParseCmd: function(can, msg) { can.ui.data.list = []
|
||||
msg.Table(function(field, order) { can.ui.data.list.push(field)
|
||||
field.feature = can.base.Obj(field.meta, {})
|
||||
field.inputs = can.base.Obj(field.list, [])
|
||||
field.name = can.core.Split(field.name)[0]
|
||||
if (!field.inputs || field.inputs.length === 0) {
|
||||
return can.core.Timer(30, function() {
|
||||
can.onaction._refresh({}, can, order)
|
||||
})
|
||||
}
|
||||
can.core.List(field.inputs, function(input) {
|
||||
input.action = input.action || input.value
|
||||
input.value == ice.AUTO && (input.value = "")
|
||||
if (input.value && input.value.indexOf("@") == 0) {
|
||||
input.action = input.value.slice(1), input.value = ""
|
||||
}
|
||||
if (input.type == html.SELECT) {
|
||||
input.values = input.values || can.core.Split(input.value)
|
||||
}
|
||||
if (can.base.isIn(input.type, html.TEXT, html.TEXTAREA)) {
|
||||
input.placeholder = can.user.trans(can, input.placeholder||input.name, field, html.INPUT)
|
||||
}
|
||||
if (input.type == html.BUTTON) {
|
||||
input.value = can.user.trans(can, input.value||input.name, field)
|
||||
} else {
|
||||
if (can.db.cmd||can.db.index) { input.value = input.value||can.db[input.name] }
|
||||
}
|
||||
input.type == html.BUTTON && input.action == ice.AUTO && can.core.Timer(30, function() {
|
||||
can.onaction._refresh({}, can, order)
|
||||
})
|
||||
})
|
||||
}), can.misc.setData(can), can.user.toast(can, "加载成功")
|
||||
},
|
||||
WSS: function(can) { if (can.conf.platform == "devtools" && can.db.serve != can.conf.serve) { return }
|
||||
var url = can.base.MergeURL(can.db.serve.replace("http", "ws")+"/space/", mdb.TYPE, "weixin", mdb.NAME, "weixin", mdb.TEXT, can.base.MergeURL(nfs.PS+can.ui.route, can.db), can.conf)
|
||||
var socket = wx.connectSocket({url: url, header:{"content-type": "application/json"}}); can.misc.Info("wss connect", url, socket)
|
||||
socket.onOpen(function(res) { can.misc.Info("wss open", res) })
|
||||
socket.onClose(function(res) { can.misc.Info("wss close", res), can._socket && can.core.Timer(can.base.random(30000, 3000), function() { can.misc.WSS(can) }) })
|
||||
socket.onMessage(function(res) { var msg = can.request(), data = can.base.Obj(res.data); msg.Copy(data), msg.detail = data.detail, can.misc.Info("wss recv", msg.detail, msg)
|
||||
switch (msg.detail[0]) {
|
||||
case "pwd": can._daemon = msg.detail[1]; break
|
||||
case "parse": can.core.Timer(30, function() { can.user.parse(can, data.detail[1]) }); break
|
||||
case "info": break
|
||||
} delete(msg._hand), delete(msg.detail), msg.Option("_handle", ice.TRUE)
|
||||
msg._target = (msg._source||[]).reverse(), msg._source = (msg._target||[]).reverse().slice(1)||[]
|
||||
can.misc.Info("wss send", msg.result, msg), socket.send({data: JSON.stringify(msg)})
|
||||
}); return can._socket = socket
|
||||
},
|
||||
request: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid, data.appid = data.appid||can.conf.appid
|
||||
can.core.List(msg.option, function(key) { data[key] = data[key]||[msg.Option(key)] }), data.option = data.option||msg.option
|
||||
var url = (msg._serve||can.db.serve||can.conf.serve)+cmd
|
||||
if (data && can.base.isIn(msg._method, http.GET, http.DELETE)) { url = can.base.MergeURL(url, data), data = {} }
|
||||
wx.request({method: msg._method||http.POST, url: url, data: data, success: function(res) {
|
||||
if (res.statusCode == 401) {
|
||||
can.user.info = {}, can.misc.localStorage(can, ice.MSG_SESSID, can.conf.sessid = "")
|
||||
return can.user.login(can, function() { can.misc.request(can, msg, cmd, data, cb) })
|
||||
}
|
||||
if (res.statusCode == 403) { msg.result = [res.data] }
|
||||
msg.Copy(res.data), can.misc.Info("request", cmd, data.cmds||data, msg)
|
||||
can.base.toLast(msg.append, mdb.TIME), can.base.toLast(msg.append, web.LINK), can.base.toLast(msg.append, ctx.ACTION)
|
||||
if (msg.append && msg.append.indexOf(ctx.ACTION) > 0) {
|
||||
msg._style = "content action"
|
||||
} else if (msg.IsDetail()) {
|
||||
msg._style = "content detail"
|
||||
} else {
|
||||
msg._style = "content"
|
||||
}
|
||||
msg.Data = function(item, index) {
|
||||
var text = msg[item]&&msg[item][index]||""
|
||||
var data = {_type: html.TEXT, _text: text}
|
||||
if (text.indexOf("<") != 0) { return [data] }
|
||||
var res = [], list = can.core.Split(text, " ", "<=/>")
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i] == "<") { data = {}
|
||||
if (list[i] == "/") { i++ } else { res.push(data) }
|
||||
data._type = list[i+1], data._text = text, i++
|
||||
continue
|
||||
} else if (list[i] == ">") {
|
||||
continue
|
||||
} else if (list[i+1] == "=") {
|
||||
data[list[i]] = list[i+2], i += 2
|
||||
} else {
|
||||
data[list[i]] = list[i]
|
||||
}
|
||||
}
|
||||
return res.length == 0? [data]: res
|
||||
}
|
||||
msg._index = []; for (var i = 0; i < msg.Length(); i++) { msg._index.push(i) }
|
||||
msg._view = {}, msg[ice.MSG_APPEND] && can.core.List(msg[ice.MSG_APPEND], function(k) { msg._view[k] = []
|
||||
for (var i in msg[k]) { msg._view[k][i] = msg.Data(k, i) }
|
||||
}), cb && cb(msg)
|
||||
}})
|
||||
},
|
||||
download: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid
|
||||
wx.downloadFile({url: can.conf.serve+nfs.PS+cmd, data: data, success: cb})
|
||||
},
|
||||
localStorage: function(can, key, value) {
|
||||
value != undefined && wx.setStorageSync(key, value)
|
||||
return wx.getStorageSync(key)
|
||||
},
|
||||
setData: function(can, list) {
|
||||
can.ui.setData({list: list||can.ui.data.list})
|
||||
},
|
||||
})
|
@ -1,195 +0,0 @@
|
||||
const {kit, ice, ctx, mdb, web, lex, nfs, log, code, chat, http, html} = require("../const.js")
|
||||
const {Volcanos} = require("../proto.js")
|
||||
module.exports =
|
||||
Volcanos("misc", {
|
||||
Message: function(event, can) { var msg = kit.proto({}, {_event: event, _can: can, _target: can._target,
|
||||
OptionDefault(key, val) { var arg = arguments; for (var i = 0; i < arg.length; i += 2) { msg.Option(arg[i]) || msg.Option(arg[i], arg[i+1]) } return msg.Option(key) },
|
||||
Option: function(key, val) { if (key == undefined) { return msg.option || [] }
|
||||
if (can.base.isObject(key)) { return can.core.Item(key, msg.Option) }
|
||||
if (val == undefined) { return can.base.isIn(key, msg.option) && msg[key] && msg[key][0] || "" }
|
||||
return msg.option = can.base.AddUniq(msg.option, key), msg[key] = can.core.List(arguments).slice(1), val
|
||||
},
|
||||
Append: function(key, val) { if (key == undefined) { return msg.append || [] }
|
||||
if (can.base.isObject(key)) { return can.core.Item(key, msg.Append) }
|
||||
if (val == undefined) { return can.base.isIn(key, msg.append) && msg[key] && msg[key][0] || "" }
|
||||
return msg.append = can.base.AddUniq(msg.append, key), msg[key] = can.core.List(arguments).slice(1), val
|
||||
},
|
||||
Result: function() { if (!msg.result) { return "" } return msg.result[0] == ice.ErrWarn? msg.result.join(lex.SP): msg.result.join("") },
|
||||
Results: function() { return msg.result && msg.result[0] == ice.ErrWarn? "": msg.Result() },
|
||||
TableDetail: function() { var item = can.Option(); return msg.Table(function(value) { can.core.Value(item, value.key, value.value) }), item },
|
||||
IsDetail: function() { return msg.Option(ice.MSG_FIELDS) == "detail" || msg.append && msg.append.length == 2 && msg.append[0] == mdb.KEY && msg.append[1] == mdb.VALUE },
|
||||
Table: function(cb) { return can.core.List(msg.Length(), function(index) { var item = {}
|
||||
can.core.List(msg.append, function(k) { item[k] = msg[k]&&msg[k][index]||"" })
|
||||
return can.base.isFunc(cb)? cb(item, index): item
|
||||
}) },
|
||||
Length: function() { var max = 0; can.core.List(msg.append, function(k) { if (msg[k] && msg[k].length > max) { max = msg[k].length } }); return max },
|
||||
Clear: function(key) { switch (key||ice.MSG_APPEND) {
|
||||
case ice.MSG_OPTION:
|
||||
case ice.MSG_APPEND: can.core.List(msg[key], function(key) { delete(msg[key]) })
|
||||
default: delete(msg[key])
|
||||
} },
|
||||
Copy: function(res) { if (!res) { return msg }
|
||||
res.append && res.append.length > 0 && (msg.append = res.append) && res.append.forEach(function(key) {
|
||||
var i = msg.option && msg.option.indexOf(key); if (i > -1) { msg.option[i] = "", delete(msg[key]) }
|
||||
res[key] && (msg[key] = (msg[key]||[]).concat(res[key]))
|
||||
}), res.result && res.result.length > 0 && (msg.result = (msg.result||[]).concat(res.result))
|
||||
res.option && res.option.length > 0 && (msg.option = res.option) && res.option.forEach(function(key) { res[key] && (msg[key] = res[key]) })
|
||||
res._option && (msg._option = res._option) && res._option.forEach(function(key) { res[key] && (msg[key] = res[key]) })
|
||||
return msg
|
||||
},
|
||||
Push: function(key, value, detail) {
|
||||
if (can.base.isObject(key)) { can.core.List(value||msg.append||can.base.Obj(msg.Option(ice.MSG_FIELDS))||can.core.Item(key), function(item) {
|
||||
detail? msg.Push(mdb.KEY, item).Push(mdb.VALUE, key[item]||""): msg.Push(item, key[item]||"")
|
||||
}); return msg }
|
||||
var i = msg.option && msg.option.indexOf(key); if (i > -1) { msg.option[i] = "", msg[key] = [] }
|
||||
msg.append = can.base.AddUniq(msg.append, key), msg[key] = msg[key]||[]
|
||||
msg[key].push(can.base.isString(value)||can.base.isFunc(value)? value: JSON.stringify(value)); return msg
|
||||
},
|
||||
PushAction: function(button) { can.core.List(msg.Length(), function() {
|
||||
msg.Push(ctx.ACTION, can.page.Format(html.INPUT, "", mdb.TYPE, html.BUTTON, mdb.NAME, button, mdb.VALUE, can.user.trans(can, button)))
|
||||
}); return msg },
|
||||
Echo: function(res) { msg.result = (msg.result||[]).concat(can.core.List(arguments)); return msg._hand = true, msg },
|
||||
}); return msg },
|
||||
ParseCmd: function(can, msg) { can.ui.data.list = []
|
||||
msg.Table(function(field, order) { can.ui.data.list.push(field)
|
||||
field.feature = can.base.Obj(field.meta, {})
|
||||
field.inputs = can.base.Obj(field.list, [])
|
||||
field.name = can.core.Split(field.name)[0]
|
||||
if (!field.inputs || field.inputs.length === 0) {
|
||||
return can.core.Timer(30, function() {
|
||||
can.onaction._refresh({}, can, order)
|
||||
})
|
||||
}
|
||||
can.core.List(field.inputs, function(input) {
|
||||
input.action = input.action || input.value
|
||||
input.value == ice.AUTO && (input.value = "")
|
||||
if (input.value && input.value.indexOf("@") == 0) {
|
||||
input.action = input.value.slice(1), input.value = ""
|
||||
}
|
||||
if (input.type == html.SELECT) {
|
||||
input.values = input.values || can.core.Split(input.value)
|
||||
}
|
||||
if (can.base.isIn(input.type, html.TEXT, html.TEXTAREA)) {
|
||||
input.placeholder = can.user.trans(can, input.placeholder||input.name, field, html.INPUT)
|
||||
}
|
||||
if (input.type == html.BUTTON) {
|
||||
input.value = can.user.trans(can, input.value||input.name, field)
|
||||
} else {
|
||||
if (can.db.cmd||can.db.index) { input.value = input.value||can.db[input.name] }
|
||||
}
|
||||
input.type == html.BUTTON && input.action == ice.AUTO && can.core.Timer(30, function() {
|
||||
can.onaction._refresh({}, can, order)
|
||||
})
|
||||
})
|
||||
}), can.page.setData(can), can.user.toast(can, "加载成功")
|
||||
},
|
||||
ParseURL: function(can, url) { url = url||location&&location.href; var args = can.base.ParseURL(url)
|
||||
delete(args.link), delete(args.origin), delete(args._origin)
|
||||
var ls = can.core.Split(url.split("://")[1].split("?")[0].split("#")[0], nfs.PS).slice(1)
|
||||
if (ls[0] == chat.SHARE) { args[chat.SHARE] = ls[1] }
|
||||
for (var i = 1; i < ls.length; i += 2) { if (can.base.isIn(ls[i], [ice.POD, ice.CMD])) { args[ls[i]] = ls[i+1] } }
|
||||
return args
|
||||
},
|
||||
WSS: function(can) { if (can.conf.platform == "devtools" && can.db.serve != can.conf.serve) { return }
|
||||
var url = can.base.MergeURL(can.db.serve.replace("http", "ws")+"/space/", mdb.TYPE, "weixin", mdb.NAME, "weixin", mdb.TEXT, can.base.MergeURL(nfs.PS+can.ui.route, can.db), can.conf)
|
||||
var socket = wx.connectSocket({url: url, header:{"content-type": "application/json"}}); can.misc.Info("wss connect", url, socket)
|
||||
socket.onOpen(function(res) { can.misc.Info("wss open", res) })
|
||||
socket.onClose(function(res) { can.misc.Info("wss close", res), can._socket && can.core.Timer(can.base.random(30000, 3000), function() { can.misc.WSS(can) }) })
|
||||
socket.onMessage(function(res) { var msg = can.request(), data = can.base.Obj(res.data); msg.Copy(data), msg.detail = data.detail, can.misc.Info("wss recv", msg.detail, msg)
|
||||
switch (msg.detail[0]) {
|
||||
case "pwd": can._daemon = msg.detail[1]; break
|
||||
case "parse": can.core.Timer(30, function() { can.user.parse(can, data.detail[1]) }); break
|
||||
case "info": break
|
||||
} delete(msg._hand), delete(msg.detail), msg.Option("_handle", ice.TRUE)
|
||||
msg._target = (msg._source||[]).reverse(), msg._source = (msg._target||[]).reverse().slice(1)||[]
|
||||
can.misc.Info("wss send", msg.result, msg), socket.send({data: JSON.stringify(msg)})
|
||||
}); return can._socket = socket
|
||||
},
|
||||
request: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid, data.appid = data.appid||can.conf.appid
|
||||
can.core.List(msg.option, function(key) { data[key] = data[key]||[msg.Option(key)] }), data.option = data.option||msg.option
|
||||
var url = (msg._serve||can.db.serve||can.conf.serve)+cmd
|
||||
if (data && can.base.isIn(msg._method, http.GET, http.DELETE)) { url = can.base.MergeURL(url, data), data = {} }
|
||||
wx.request({method: msg._method||http.POST, url: url, data: data, success: function(res) {
|
||||
if (res.statusCode == 401) {
|
||||
can.user.info = {}, can.misc.localStorage(can, ice.MSG_SESSID, can.conf.sessid = "")
|
||||
return can.user.login(can, function() { can.misc.request(can, msg, cmd, data, cb) })
|
||||
}
|
||||
if (res.statusCode == 403) { msg.result = [res.data] }
|
||||
msg.Copy(res.data), can.misc.Info("request", cmd, data.cmds||data, msg)
|
||||
can.base.toLast(msg.append, mdb.TIME), can.base.toLast(msg.append, web.LINK), can.base.toLast(msg.append, ctx.ACTION)
|
||||
if (msg.append && msg.append.indexOf(ctx.ACTION) > 0) {
|
||||
msg._style = "content action"
|
||||
} else if (msg.IsDetail()) {
|
||||
msg._style = "content detail"
|
||||
} else {
|
||||
msg._style = "content"
|
||||
}
|
||||
msg.Data = function(item, index) {
|
||||
var text = msg[item]&&msg[item][index]||""
|
||||
var data = {_type: html.TEXT, _text: text}
|
||||
if (text.indexOf("<") != 0) { return [data] }
|
||||
var res = [], list = can.core.Split(text, " ", "<=/>")
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
if (list[i] == "<") { data = {}
|
||||
if (list[i] == "/") { i++ } else { res.push(data) }
|
||||
data._type = list[i+1], data._text = text, i++
|
||||
continue
|
||||
} else if (list[i] == ">") {
|
||||
continue
|
||||
} else if (list[i+1] == "=") {
|
||||
data[list[i]] = list[i+2], i += 2
|
||||
} else {
|
||||
data[list[i]] = list[i]
|
||||
}
|
||||
}
|
||||
return res.length == 0? [data]: res
|
||||
}
|
||||
msg._index = []; for (var i = 0; i < msg.Length(); i++) { msg._index.push(i) }
|
||||
msg._view = {}, msg[ice.MSG_APPEND] && can.core.List(msg[ice.MSG_APPEND], function(k) { msg._view[k] = []
|
||||
for (var i in msg[k]) { msg._view[k][i] = msg.Data(k, i) }
|
||||
}), cb && cb(msg)
|
||||
}})
|
||||
},
|
||||
download: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid
|
||||
wx.downloadFile({url: can.conf.serve+nfs.PS+cmd, data: data, success: cb})
|
||||
},
|
||||
localStorage: function(can, key, value) {
|
||||
value != undefined && wx.setStorageSync(key, value)
|
||||
return wx.getStorageSync(key)
|
||||
},
|
||||
Log: function() { var args = this._args("", arguments); console.log.apply(console, args), this._signal(args) },
|
||||
Info: function() { var args = this._args("", arguments); console.log.apply(console, args), this._signal(args) },
|
||||
Warn: function() { var args = this._args(log.WARN, arguments); console.warn.apply(console, args), this._signal(args); debugger },
|
||||
Error: function() { var args = this._args(log.ERROR, arguments); args.push(lex.NL, this._stacks().slice(1).join(lex.NL)), console.error.apply(console, args), this._signal(args); debugger },
|
||||
FileLine: function(depth, length) { var file = this.fileLine(depth+1, length||9); return file.link },
|
||||
fileLine: function(depth, length) { var list = this._stacks()
|
||||
function split(i) { if (!list[i]) { return {} }
|
||||
var ls = new RegExp("(https?://[^/]+)?([^:]+):([0-9]+):([0-9]+)").exec(list[i]); if (!ls) { return {} }
|
||||
var name = ""; list[i].lastIndexOf(lex.TB) > 0 && (name = list[i].split(lex.TB).pop())
|
||||
if (ls[0].indexOf(ice.QS) > -1) { ls[0] = ls[0].split(ice.QS)[0]+nfs.DF+ls[3]+nfs.DF+ls[4] }
|
||||
return {_path: ls[2]+":"+ls[3], name: name, link: ls[0], path: ls[2], file: ls[2].split(nfs.PS).slice(-length).join(nfs.PS), line: ls[3], cols: ls[4]}
|
||||
}
|
||||
if (depth < 0) { var current = split(-depth)
|
||||
for (var i = -depth+1; i < list.length; i++) { var pos = split(i); if (pos.path != current.path) { return pos } }
|
||||
} return split(depth)||{}
|
||||
},
|
||||
_stacks: function(n, s) { var list = ((s||(new Error())).stack||"").split(lex.NL).slice(typeof n == "undefined"? 2: n)
|
||||
for (var i = 0; i < list.length; i++) { var ls = list[i].trim().split(lex.SP)
|
||||
list[i] = ls.pop().trim(); if (list[i][0] == "(") { list[i] = list[i].slice(1, -1) }
|
||||
list[i] = " "+list[i]; if (ls.length > 1) { list[i] += " "+ls.pop() }
|
||||
list[i] = list[i].replace(/\?[^:]+/, "")
|
||||
} return list
|
||||
}, _stack: function() { return ((new Error()).stack||"").split(lex.NL).slice(2) },
|
||||
_time: function() { var now = new Date()
|
||||
var hour = now.getHours(); hour < 10 && (hour = "0"+hour)
|
||||
var minute = now.getMinutes(); minute < 10 && (minute = "0"+minute)
|
||||
var second = now.getSeconds(); second < 10 && (second = "0"+second)
|
||||
var mill = now.getMilliseconds(); mill < 10 && (mill = "00"+mill) || mill < 100 && (mill = "0"+mill)
|
||||
return [hour, minute, second].join(nfs.DF)+nfs.PT+mill
|
||||
},
|
||||
_args: function(level, arg) { var app = getApp()
|
||||
var args = [this._time(), app && app.conf.platform == "devtools"? this.FileLine(this._skip+1, 3)||"": ""].concat(level? [level]: [])
|
||||
for (var i in arg) { arg[i] != undefined && args.push(arg[i]) } return args
|
||||
},
|
||||
_signal: function(args) { this._list.push(args) }, _list: [], _skip: 2,
|
||||
})
|
11
publish/client/mp/utils/lib/page-wx.js
Normal file
11
publish/client/mp/utils/lib/page-wx.js
Normal file
@ -0,0 +1,11 @@
|
||||
const {kit, ice,
|
||||
ctx, mdb, web, aaa,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
} = require("../const.js")
|
||||
const {shy, Volcanos} = require("../proto.js")
|
||||
module.exports =
|
||||
Volcanos("page", {
|
||||
})
|
@ -1,7 +0,0 @@
|
||||
const {shy, Volcanos} = require("../proto.js")
|
||||
module.exports =
|
||||
Volcanos("page", {
|
||||
setData: function(can, list) {
|
||||
can.ui.setData({list: list||can.ui.data.list})
|
||||
}
|
||||
})
|
@ -1,4 +1,10 @@
|
||||
const {ice, ctx, mdb, web, chat} = require("../const.js")
|
||||
const {kit, ice,
|
||||
ctx, mdb, web, aaa,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
} = require("../const.js")
|
||||
const {shy, Volcanos} = require("../proto.js")
|
||||
module.exports =
|
||||
Volcanos("user", {
|
||||
@ -64,7 +70,11 @@ Volcanos("user", {
|
||||
can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data)
|
||||
}
|
||||
},
|
||||
jumps: function(url, cb) { wx.navigateTo({url: url, success: cb}) },
|
||||
jumps: function(url, cb) {
|
||||
wx.navigateTo({url: url, success: cb, fail: function(res) {
|
||||
console.log(res)
|
||||
}})
|
||||
},
|
||||
title: function(text, cb) { text && wx.setNavigationBarTitle({title: text, success: cb}) },
|
||||
toast: function(can, title) { wx.showToast({title: title||""}) },
|
||||
modal: function(can, content, title, cb) { wx.showModal({title: title||"", content: content||"", success: cb}) },
|
||||
@ -87,22 +97,6 @@ Volcanos("user", {
|
||||
}}) })
|
||||
},
|
||||
trans: function(can, text, list, zone) { if (!text) { return text }
|
||||
return can.core.Value(can.core.Value(list, ctx.FEATURE_TRANS), can.core.Keys(zone, text))||can.core.Value({
|
||||
"run": "执行", "list": "查看", "back": "返回",
|
||||
"create": "创建", "remove": "删除",
|
||||
"prunes": "清理",
|
||||
"start": "启动", "stop": "停止", "open": "打开",
|
||||
"trash": "清理",
|
||||
input: {
|
||||
"hash": "索引",
|
||||
"time": "时间", "link": "链接", "status": "状态", "action": "操作",
|
||||
"type": "类型", "name": "名称", "text": "内容", "icon": "图标",
|
||||
"repos": "仓库", "binary": "程序", "script": "脚本", "template": "仓库", "version": "版本",
|
||||
"path": "路径", "size": "大小",
|
||||
},
|
||||
value: {
|
||||
"start": "启动", "stop": "停止",
|
||||
},
|
||||
}, can.core.Keys(zone, text))||text
|
||||
},
|
||||
return can.core.Value(can.core.Value(list, ctx.FEATURE_TRANS), can.core.Keys(zone, text))||can.core.Value(can.user._trans, can.core.Keys(zone, text))||text
|
||||
}, _trans: {},
|
||||
})
|
@ -1,10 +1,17 @@
|
||||
const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("const.js")
|
||||
const {kit, ice,
|
||||
ctx, mdb, web, aaa,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
} = require("const.js")
|
||||
function shy(help, meta, list, cb) { var arg = arguments, i = 0; function next(type) {
|
||||
if (type == code.OBJECT) { if (typeof arg[i] == code.OBJECT && arg[i].length == undefined) { return arg[i++] }
|
||||
} else if (type == code.ARRAY) { if (typeof arg[i] == code.OBJECT && arg[i].length != undefined) { return arg[i++] }
|
||||
} else if (i < arg.length && (!type || type == typeof arg[i])) { return arg[i++] }
|
||||
} return cb = typeof arg[arg.length-1] == code.FUNCTION? arg[arg.length-1]: function() {}, cb.help = next(code.STRING)||"", cb.meta = next(code.OBJECT)||{}, cb.list = next(code.ARRAY)||[], cb }
|
||||
function Volcanos(name, list) { if (Volcanos._page) { Volcanos._page[name] = list } return list }
|
||||
|
||||
Volcanos._init = function() {
|
||||
var can = {__proto__: Volcanos._page,
|
||||
request: function(event) { event = event||{}, event = event._event||event
|
||||
@ -26,94 +33,7 @@ Volcanos._init = function() {
|
||||
})
|
||||
},
|
||||
}; Volcanos._page.__proto__ = getApp()
|
||||
Volcanos._page.onimport = Volcanos._page.onimport||{}
|
||||
Volcanos._page.onaction = can.base.Copy({
|
||||
_refresh: function(event, can, order) { can.page.setData(can)
|
||||
can.onaction.onAction({}, can, ice.LIST, {order: order, name: ice.LIST})
|
||||
},
|
||||
_reload: function(can, msg) {
|
||||
can.misc.ParseCmd(can, msg)
|
||||
},
|
||||
refresh: function(event, can) {
|
||||
can.onaction._apis = "", can.onaction._cmds = []
|
||||
if (can.db.share) { can.onaction._apis = "/share/"+can.db.share
|
||||
can.run(event, [ctx.ACTION, ctx.COMMAND], function(msg) {
|
||||
can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onaction._reload(can, msg)
|
||||
})
|
||||
} else if (can.db.river && can.db.storm) {
|
||||
can.onaction._cmds = [can.db.river, can.db.storm]
|
||||
can.run(event, [], function(msg) { can.onaction._reload(can, msg) })
|
||||
} else {
|
||||
can.run(event, [ctx.ACTION, ctx.COMMAND, can.db.cmd||can.db.index||"cli.qrcode"], function(msg) {
|
||||
can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onaction._reload(can, msg)
|
||||
})
|
||||
}
|
||||
},
|
||||
onaction: function(event, can, button, data) { var name = data.name;
|
||||
(can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
|
||||
},
|
||||
onInputs: function(event, can, button, data) { var order = data.order, index = data.index
|
||||
var input = can.ui.data.list[order||0].inputs[index||0]
|
||||
input.value = event.detail.value
|
||||
},
|
||||
onChange: function(event, can, button, data) { var order = data.order, index = data.index
|
||||
var input = can.ui.data.list[order||0].inputs[index||0]
|
||||
input.value = input.values[parseInt(event.detail.value)]
|
||||
can.onaction._refresh(event, can, order)
|
||||
},
|
||||
onAction: function(event, can, button, data) { var order = data.order, name = data.name
|
||||
var field = can.ui.data.list[order||0], msg = can.request(event)
|
||||
if (field.feature[name]) { if (can.base.isIn(name, mdb.CREATE, mdb.INSERT)) { msg._method = http.PUT }
|
||||
return can.data.insert = {field: field, name: name, list: field.feature[name], cb: function(res) {
|
||||
can.run(event, can.base.Simple([field.id||field.index, ctx.ACTION, name], res), function(msg) {
|
||||
can.onaction._refresh(event, can, order)
|
||||
})
|
||||
}}, can.user.jumps(chat.PAGES_INSERT)
|
||||
} field._history = field._history||[]
|
||||
switch (name) {
|
||||
case ice.BACK: field._history.pop(); var ls = field._history.pop()||[], i = 0
|
||||
can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { input.value = ls[i++]||"" } })
|
||||
can.onaction._refresh(event, can, order); break
|
||||
case ctx.RUN: break
|
||||
case ice.LIST:
|
||||
case web.REFRESH: msg._method = http.GET; break
|
||||
default: msg.Option(ctx.ACTION, name)
|
||||
}
|
||||
var cmd = can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { return input.value } })
|
||||
for (var i = cmd.length-1; i > 0; i--) { if (cmd[i] === "") { cmd.pop() } else { break } }
|
||||
function eq(to, from) { if (!to) { return false } if (to.length != from.length) { return false }
|
||||
for (var i = 0; i < to.length; i++) { if (to[i] != from[i]) { return false } } return true
|
||||
} eq(field._history[field._history.length-1], cmd) || field._history.push(cmd)
|
||||
can.run(event, [field.id||field.index].concat(cmd), function(msg) { can.onimport._init && can.onimport._init(can, msg)
|
||||
msg._head = can.core.List(msg.append, function(item) { return can.user.trans(can, item, field, html.INPUT) })
|
||||
can.core.Item(msg._view, function(key, value) { can.core.List(value, function(value) { can.core.List(value, function(input, i) {
|
||||
if (input.type == html.BUTTON) { input.value = can.user.trans(can, input.value||input.name, field) }
|
||||
if (input._type == html.TEXT) { input._text = can.user.trans(can, input._text, field, html.VALUE) }
|
||||
}) }) })
|
||||
msg._status = can.core.List(can.base.Obj(msg.Option(ice.MSG_STATUS)), function(item) { return item })
|
||||
msg._action = can.core.List(can.base.Obj(msg.Option(ice.MSG_ACTION)), function(item) {
|
||||
if (typeof item == code.STRING) { return {type: html.BUTTON, name: item, value: can.user.trans(can, item)} }
|
||||
return item.value = can.user.trans(can, item.value||item.name), item
|
||||
}), field.msg = msg, can.page.setData(can)
|
||||
})
|
||||
},
|
||||
onDetail: function(event, can, button, data) { var order = data.order, name = data.name, value = data.value, input = data.input
|
||||
var field = can.ui.data.list[order||0]
|
||||
if (input && input.type == html.BUTTON) { var msg = can.request(event, field.msg.Table()[data.index])
|
||||
if (can.base.isIn(name, mdb.REMOVE, mdb.DELETE)) { msg._method = http.DELETE }
|
||||
var _input = {}; can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { _input[input.name] = input.value } }), can.request(event, _input)
|
||||
if (field.feature[input.name]) {
|
||||
can.onAction(event, can, input.name, {order: order, name: input.name})
|
||||
} else {
|
||||
can.run(event, [field.id||field.index, ctx.ACTION, input.name], function(msg) {
|
||||
can.onaction._refresh(event, can, order)
|
||||
})
|
||||
} return
|
||||
}
|
||||
can.core.List(field.inputs, function(input) {
|
||||
if (input.name == name) { input.value = value, can.onaction._refresh(event, can, order) }
|
||||
})
|
||||
}}, Volcanos._page.onaction||{})
|
||||
can.core.Item(require("frame.js"), function(key, mod) { Volcanos._page[key] = can.base.Copy(Volcanos._page[key]||{}, mod, true) })
|
||||
delete(Volcanos._page)
|
||||
var page = {data: {action: can.onaction.list, list: []},
|
||||
onLoad: function(options) { can.ui = this, can.db = options, can.db.serve = can.db.serve||can.conf.serve
|
||||
|
Loading…
x
Reference in New Issue
Block a user