diff --git a/plugin/local/team/plan.js b/plugin/local/team/plan.js index 7434aec0..10fa011e 100644 --- a/plugin/local/team/plan.js +++ b/plugin/local/team/plan.js @@ -102,20 +102,10 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( function set(begin_time, col, row) { return begin+col-1+"-"+can.base.Number(row, 2) } can.onimport._content(can, msg, head, list, key, get, set) }, - layout: function(can) { - can.ui.layout(can.ConfHeight(), can.ConfWidth()) - can.user.isMobile && can.page.style(can, can.ui.content, html.HEIGHT, "") + layout: function(can) { can.ui.layout(can.ConfHeight(), can.ConfWidth()); + (can.Conf("_auto") || can.user.isMobile) && can.page.style(can, can.ui.content, html.HEIGHT, "") var sub = can._plugin_display; sub && sub.onimport.display_size(can, sub) can.ui.toggle && can.ui.toggle.layout() - return - can.page.styleHeight(can, can._output, can.ConfHeight()), can.page.styleHeight(can, can.ui.project, can.ConfHeight()) - var height = can._display_heights[can.sup.task? [can.sup.task.zone, can.sup.task.id].join(mdb.FS): ""]||html.ACTION_HEIGHT - if (!can.ui.display.innerHTML || can.ui.display.style.display == html.NONE) { height = 0 } - can.page.style(can, can.ui.table, html.HEIGHT, can.ConfHeight()-height, html.WIDTH, can.ConfWidth()-can.ui.project.offsetWidth-can.ui.profile.offsetWidth) - can.page.style(can, can.ui.content, html.HEIGHT, can.ConfHeight()-height, html.WIDTH, can.ConfWidth()-can.ui.project.offsetWidth-can.ui.profile.offsetWidth) - can.page.styleHeight(can, can.ui.profile, can.ConfHeight()-height), height == 0 || can.core.List(can._plugins_display, function(sub) { - sub.onimport.size(sub, height-html.ACTION_HEIGHT-sub.onexport.statusHeight(sub), sub.ConfWidth(can.ConfWidth()-can.ui.project.offsetWidth), true) - }) } }, [""]) Volcanos(chat.ONACTION, {list: [ diff --git a/publish/client/mp/pages/action/action.js b/publish/client/mp/pages/action/action.js index add7e495..902fb11e 100644 --- a/publish/client/mp/pages/action/action.js +++ b/publish/client/mp/pages/action/action.js @@ -1,50 +1,43 @@ +const {ice, ctx, mdb, chat, html} = require("../../utils/const.js") const {shy, Volcanos} = require("../../utils/proto.js") -const {ice, ctx, mdb, html} = require("../../utils/const.js") Volcanos._page = {} -Volcanos("onimport", { - _init: function(can, msg) { can.db.list = [] - msg.Table(function(value, index) { can.db.list.push(value) +Volcanos(chat.ONIMPORT, { + _init: function(can, msg) { can.ui.data.list = [] + msg.Table(function(value, index) { can.ui.data.list.push(value) value.feature = can.base.Obj(value.meta, {}) value.inputs = can.base.Obj(value.list, []) value.name = can.core.Split(value.name)[0] if (!value.inputs || value.inputs.length === 0) { - value.inputs = [{type: html.TEXT}, {type: html.BUTTON, value: "执行"}] + value.inputs = [{type: html.TEXT}, {type: html.BUTTON, name: ctx.RUN}] } can.core.List(value.inputs, function(input) { input.action = input.action || input.value - input.value = can.core.Value(value, "feature._trans."+input.name) || input.value - input.value == "auto" && (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 == "select") { + if (input.type == html.SELECT) { input.values = input.values || can.core.Split(input.value) } - if (input.type == "button") { + if (input.type == html.BUTTON) { + input.value = can.core.Value(value, "feature._trans."+(input.value||input.name)) input.value = {"list": "查看", "back": "返回", "create": "创建"}[input.value||input.name]||input.value||input.name } - input.type == "button" && input.action == "auto" && can.core.Timer(100, function() { + input.type == html.BUTTON && input.action == ice.AUTO && can.core.Timer(100, function() { can.run({}, [can.db.river, can.db.storm, value.id||value.index], function(msg) { - value.msg = msg, can.page.setData(can, can.db.list) + value.msg = msg, can.page.setData(can) }) }) }) - }), can.page.setData(can, can.db.list) + }), can.page.setData(can) }, }) -Volcanos("onaction", {list: ["刷新", "扫码", "清屏"], +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.db.list, function(item) { delete(item.msg) }) - can.page.setData(can, can.db.list) - }, - refresh: function(event, can) { - can.run(event, [can.db.river, can.db.storm], function(msg) { - can.onimport._init(can, msg) - }) - }, - onaction: function(event, can, button, data) { var name = data.name + "清屏": function(event, can) { can.core.List(can.ui.data.list, function(item) { delete(item.msg) }), can.page.setData(can) }, + refresh: function(event, can) { can.run(event, [can.db.river, can.db.storm], 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) }, onInputs: function(event, can, button, data) { var order = data.order, index = data.index @@ -59,38 +52,31 @@ Volcanos("onaction", {list: ["刷新", "扫码", "清屏"], var field = can.ui.data.list[order||0] if (field.feature[name]) { can.data.insert = {field: field, name: name, list: field.feature[name], cb: function(res) { - debugger can.run(event, can.base.Simple([can.db.river, can.db.storm, field.id||field.index, ctx.ACTION, name], res), function(msg) { can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST}) }) }} - can.user.jumps("/pages/insert/insert", {river: can.db.river, storm: can.db.storm, index: field.id||field.index, title: field.name}) + can.user.jumps(chat.PAGES_INSERT, {river: can.db.river, storm: can.db.storm, index: field.id||field.index, title: field.name}) return } 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, index) { - if (input.type != html.BUTTON) { input.value = ls[i++]||"" } - }) - can.page.setData(can) - can.onaction.onAction(event, can, order, ice.LIST) + can.core.List(field.inputs, function(input, index) { if (input.type != html.BUTTON) { input.value = ls[i++]||"" } }) + can.page.setData(can), can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST}) break - case "run": + case ctx.RUN: case ice.LIST: - case "refresh": - break - default: - return + case "refresh": break + default: return } var cmds = [can.db.river, can.db.storm, field.id||field.index] var cmd = can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { return input.value } }) 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 + 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) cmds = cmds.concat(cmd) for (var i = cmds.length-1; i > 0; i--) { if (cmds[i] === "") { cmds.pop() } else { break } } @@ -99,9 +85,8 @@ Volcanos("onaction", {list: ["刷新", "扫码", "清屏"], onDetail: function(event, can, button, data) { var order = data.order, name = data.name, value = data.value var field = can.ui.data.list[order||0] can.core.List(field.inputs, function(input) { - if (input.name == name) { - input.value = value, can.page.setData(can) - can.onaction.onAction(event, can, order, ice.LIST) + if (input.name == name) { input.value = value, can.page.setData(can) + can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST}) } }) }, diff --git a/publish/client/mp/pages/insert/insert.js b/publish/client/mp/pages/insert/insert.js index dcd2faaf..a625c918 100644 --- a/publish/client/mp/pages/insert/insert.js +++ b/publish/client/mp/pages/insert/insert.js @@ -1,24 +1,25 @@ +const {ice, mdb, chat, html} = require("../../utils/const.js") const {shy, Volcanos} = require("../../utils/proto.js") -const {mdb, html} = require("../../utils/const.js") Volcanos._page = {} -Volcanos("onimport", { +Volcanos(chat.ONIMPORT, { _init: function(can, msg) {}, }) - -Volcanos("onaction", {list: ["刷新", "扫码"], +Volcanos(chat.ONACTION, {list: ["刷新", "扫码"], "刷新": function(event, can) { can.onaction.refresh(event, can) }, "扫码": function(event, can) { can.user.agent.scanQRCode(can) }, refresh: function(event, can) { can.core.List(can.data.insert.list, function(input) { input.action = input.action || input.value - input.value == "auto" && (input.value = "") + input.value == ice.AUTO && (input.value = "") if (input.value && input.value.indexOf("@") == 0) { input.action = input.value.slice(1), input.value = "" } - }) - can.page.setData(can, can.data.insert.list) + if (input.type == html.SELECT) { + input.values = input.values || can.core.Split(input.value) + } + }), can.page.setData(can, can.data.insert.list) }, - onaction: function(event, can, button, data) { var name = data.name + 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 index = data.index diff --git a/publish/client/mp/pages/insert/insert.wxml b/publish/client/mp/pages/insert/insert.wxml index 7d8b23dd..0b8d3fd7 100644 --- a/publish/client/mp/pages/insert/insert.wxml +++ b/publish/client/mp/pages/insert/insert.wxml @@ -10,8 +10,6 @@ {{item.values[item.index||0]}} - - diff --git a/publish/client/mp/pages/river/river.js b/publish/client/mp/pages/river/river.js index 08e4ce98..328b4be1 100644 --- a/publish/client/mp/pages/river/river.js +++ b/publish/client/mp/pages/river/river.js @@ -1,7 +1,7 @@ +const {ice, nfs, chat, html} = require("../../utils/const.js") const {shy, Volcanos} = require("../../utils/proto.js") -const {ice, chat, html} = require("../../utils/const.js") Volcanos._page = {} -Volcanos("onimport", { +Volcanos(chat.ONIMPORT, { _init: function(can, msg) { msg.Dump(can) }, }) Volcanos("onaction", {list: ["刷新", "扫码", "登录"], @@ -24,8 +24,8 @@ Volcanos("onaction", {list: ["刷新", "扫码", "登录"], }, onchange: function(event, can, button, data) { var index = data.index, i = data.i var river = can.ui.data.list[index], storm = river.list[i] - can.user.jumps(can.base.MergeURL("/pages/action/action", {river: river.hash, storm: storm.hash, title: river.name+"."+storm.name})) + can.user.jumps(can.base.MergeURL(chat.PAGES_ACTION, {river: river.hash, storm: storm.hash, title: river.name+"."+storm.name})) }, - _name: "/chat/river/", + _name: nfs.CHAT_RIVER, }) Volcanos._init() diff --git a/publish/client/mp/project.config.json b/publish/client/mp/project.config.json index fe0feb3e..7dc31c42 100644 --- a/publish/client/mp/project.config.json +++ b/publish/client/mp/project.config.json @@ -23,9 +23,9 @@ "uploadWithSourceMap": true, "compileHotReLoad": false, "lazyloadPlaceholderEnable": false, - "useMultiFrameRuntime": false, - "useApiHook": false, - "useApiHostProcess": false, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": true, "babelSetting": { "ignore": [], "disablePlugins": [], @@ -37,10 +37,7 @@ "packNpmManually": false, "packNpmRelationList": [], "minifyWXSS": true, - "disableUseStrict": false, - "minifyWXML": true, - "showES6CompileOption": false, - "useCompilerPlugins": false + "showES6CompileOption": false }, "compileType": "miniprogram", "libVersion": "2.15.0", @@ -48,6 +45,10 @@ "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": [ @@ -59,9 +60,5 @@ } ] } - }, - "editorSetting": { - "tabIndent": "insertSpaces", - "tabSize": 2 } } \ No newline at end of file diff --git a/publish/client/mp/project.private.config.json b/publish/client/mp/project.private.config.json index 05f1ccf4..70b67c9b 100644 --- a/publish/client/mp/project.private.config.json +++ b/publish/client/mp/project.private.config.json @@ -1,6 +1,6 @@ { "projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE", "setting": { - "compileHotReLoad": true + "compileHotReLoad": false } } \ No newline at end of file diff --git a/publish/client/mp/utils/const.js b/publish/client/mp/utils/const.js index 4089fdb0..afacc3b8 100644 --- a/publish/client/mp/utils/const.js +++ b/publish/client/mp/utils/const.js @@ -11,6 +11,8 @@ var kit = {proto: function(sub, sup) { return sub.__proto__ = sup, sub }, } var ice = { TB: "\t", SP: " ", DF: ":", EQ: "=", AT: "@", QS: "?", PS: "/", PT: ".", FS: ",", NL: "\n", LT: "<", GT: ">", + HTTP: "http", HELP: "help", + MAIN: "main", AUTO: "auto", LIST: "list", BACK: "back", MSG_FIELDS: "fields", MSG_SESSID: "sessid", @@ -27,8 +29,21 @@ var mdb = { 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", +} +var aaa = { +} +var tcp = { +} var nfs = { DF: ice.DF, PS: ice.PS, PT: ice.PT, + CHAT_RIVER: "/chat/river/", + CHAT_ACTION: "/chat/action/", +} +var cli = { +} +var log = { } var code = { COMMENT: "comment", KEYWORD: "keyword", @@ -37,8 +52,24 @@ var code = { 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", + + WX_LOGIN_SESS: "/chat/wx/login/action/sess", + WX_LOGIN_USER: "/chat/wx/login/action/user", + WX_LOGIN_SCAN: "/chat/wx/login/action/scan", + PAGES_ACTION: "/pages/action/action", + PAGES_INSERT: "/pages/insert/insert", +} +var team = { +} +var mall = { } var http = { GET: "GET", PUT: "PUT", POST: "POST", DELETE: "DELETE", @@ -49,8 +80,8 @@ var html = { } module.exports = { kit, ice, - ctx, mdb, - nfs, - code, chat, + ctx, mdb, web, aaa, + tcp, nfs, cli, log, + code, wiki, chat, team, mall, http, html, } diff --git a/publish/client/mp/utils/lib/base.js b/publish/client/mp/utils/lib/base.js index 68b3ca44..62978f18 100644 --- a/publish/client/mp/utils/lib/base.js +++ b/publish/client/mp/utils/lib/base.js @@ -1,4 +1,4 @@ -const {ice, mdb, nfs, code, http} = require("../const.js") +const {ice, mdb, web, nfs, code, http} = require("../const.js") const {Volcanos} = require("../proto.js") module.exports = Volcanos("base", { @@ -15,12 +15,6 @@ Volcanos("base", { 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 }, - Eq: function(to, from, skip) { var call = arguments.callee; if (typeof to != typeof from) { return false } - if (typeof to == code.OBJECT) { if (to.length != from.length) { return false } - for (var i = 0; i < to.length; i++) { if (!call(to[i], from[i])) { return false } } - for (var k in to) { if (k != skip && !call(to[k], from[k])) { return false } } return true - } return to === from - }, 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-- @@ -33,9 +27,12 @@ Volcanos("base", { 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: "") }, - Number: function(d, n) { var res = [] - while (d > 0) { res.push(d%10); d = parseInt(d/10); n-- } while (n > 0) { res.push("0"); n-- } - return res.reverse(), res.join("") + 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 } @@ -47,21 +44,6 @@ Volcanos("base", { if (typeof arg[i] == code.OBJECT && arg[i].length > 0 && arg[i].indexOf(item) > -1) { return true } if (item == arg[i]) { return true } } }, - Time: function(t, fmt) {var now = t? new Date(t): new Date(); - fmt = fmt || "%y-%m-%d %H:%M:%S"; - fmt = fmt.replace("%y", now.getFullYear()) - fmt = fmt.replace("%m", Number(now.getMonth()+1, 2)) - fmt = fmt.replace("%d", Number(now.getDate(), 2)) - fmt = fmt.replace("%H", Number(now.getHours(), 2)) - fmt = fmt.replace("%M", Number(now.getMinutes(), 2)) - fmt = fmt.replace("%S", Number(now.getSeconds(), 2)) - return fmt - }, - 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 - }, - isNumber: function(val) { return typeof val == code.NUMBER }, isString: function(val) { return typeof val == code.STRING }, isObject: function(val) { return typeof val == code.OBJECT }, isArray: function(val) { return Array.isArray(val) }, diff --git a/publish/client/mp/utils/lib/misc.js b/publish/client/mp/utils/lib/misc.js index a8747a1e..36b7ea62 100644 --- a/publish/client/mp/utils/lib/misc.js +++ b/publish/client/mp/utils/lib/misc.js @@ -3,13 +3,6 @@ const {Volcanos} = require("../proto.js") module.exports = Volcanos("misc", { Message: function(event, can) { var msg = kit.proto({}, {_event: event, _can: can, _target: can._target, - Display: function(file) { return msg.Option(ice.MSG_DISPLAY, file) }, - DisplayStory: function(file) { return msg.Option(ice.MSG_DISPLAY, chat.PLUGIN_STORY+file) }, - SearchOrOption: function(key) { return can.misc.Search(can, key)||msg.Option(key) }, - OptionProcess: function() { return msg.Option(ice.MSG_PROCESS) }, - OptionStatus: function() { return msg.Option(ice.MSG_STATUS) }, - StatusTimeCount: function(obj) { msg.append && msg.Status(can.base.Copy(kit.Dict(mdb.TIME, can.base.Time(), mdb.COUNT, msg.Length()+"x"+msg.append.length), obj)) }, - Status: function(obj) { return msg.Option(ice.MSG_STATUS, JSON.stringify(can.core.Item(obj, function(key, value) { return {name: key, value: value} }))) }, 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) } @@ -24,9 +17,7 @@ Volcanos("misc", { 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("fields") == "detail" || msg.append && msg.append.length == 2 && msg.append[0] == "key" && msg.append[1] == "value" - }, + 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 @@ -58,17 +49,6 @@ Volcanos("misc", { 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 }, - Dump: function(can) { can = can||msg._can; if (can.user.isNodejs) { return } - can.onmotion.clear(can), can.onappend.table(can, msg), can.onappend.board(can, msg), can.onmotion.story.auto(can) - }, - Defer: function(cb) { msg._defer = msg._defer||[] - if (arguments.length == 0) { msg._defer = can.core.List(msg._defer.reverse(), function(cb) { can.base.isFunc(cb) && cb() }) } else { msg._defer.push(cb) } - }, - IsErr: function() { - return msg.result && msg.result[0] == "warn: " - }, - _caller: function(skip) { msg.Option("log.caller") || msg.Option("log.caller", can.misc.fileLine((skip||2)+3).link); return msg }, - isDebug: function() { return msg.Option(log.DEBUG) == ice.TRUE }, }); return msg }, requests: function(can, msg, cmd, data, cb) { wx.showLoading(), can.misc.request(can, msg, cmd, data, function(msg) { wx.hideLoading(), cb && cb(msg) }) @@ -77,7 +57,8 @@ Volcanos("misc", { wx.request({method: http.POST, url: can.conf.serve+cmd, 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) }) } + return can.user.login(can, function() { can.misc.request(can, msg, cmd, data, cb) }) + } msg.Copy(res.data), console.log("request", cmd, data.cmds||data, msg) msg.Data = function(item, index) { var text = msg[item]&&msg[item][index]||"" diff --git a/publish/client/mp/utils/lib/page.js b/publish/client/mp/utils/lib/page.js index 0b0fe167..204bffc1 100644 --- a/publish/client/mp/utils/lib/page.js +++ b/publish/client/mp/utils/lib/page.js @@ -1,5 +1,4 @@ -const {ice, mdb, nfs, code, http} = require("../const.js") -const {Volcanos} = require("../proto.js") +const {shy, Volcanos} = require("../proto.js") module.exports = Volcanos("page", { setData: function(can, list) { diff --git a/publish/client/mp/utils/lib/user.js b/publish/client/mp/utils/lib/user.js index 0022c950..e7bb1020 100644 --- a/publish/client/mp/utils/lib/user.js +++ b/publish/client/mp/utils/lib/user.js @@ -1,5 +1,5 @@ -const {ice, mdb, nfs, code, http} = require("../const.js") -const {Volcanos} = require("../proto.js") +const {ice, ctx, mdb, chat} = require("../const.js") +const {shy, Volcanos} = require("../proto.js") module.exports = Volcanos("user", { agent: { @@ -24,42 +24,34 @@ Volcanos("user", { case "auth": can.user.userinfo(can, function() { can.user.modal(can, "授权登录", data.name, function(res) { - res.confirm && can.misc.request(can, can.request(), "/chat/wx/login/action/scan", data, function(msg) { + res.confirm && can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data, function(msg) { can.user.toast(can, "授权成功") }) }) }) break - default: can.misc.request(can, can.request(), "/chat/wx/login/action/scan", data) + default: can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data) } }}) }, }, info: {}, - jumps: function(url, cb) { - wx.navigateTo({url: url, success: cb}) - }, - title: function(text, cb) { - text && wx.setNavigationBarTitle({title: text, success: cb}) - }, - toast: function(can, content, title) { - wx.showToast({title: title, content: content||""}) - }, - modal: function(can, content, title, cb) { - wx.showModal({title: title||"", content: content||"", success: cb}) - }, + jumps: function(url, cb) { wx.navigateTo({url: url, success: cb}) }, + title: function(text, cb) { text && wx.setNavigationBarTitle({title: text, success: cb}) }, + toast: function(can, content, title) { wx.showToast({title: title, content: content||""}) }, + modal: function(can, content, title, cb) { wx.showModal({title: title||"", content: content||"", success: cb}) }, login: function(can, cb) { can.conf.sessid = can.conf.sessid||can.misc.localStorage(can, ice.MSG_SESSID) if (can.conf.sessid) { return cb && cb() } - wx.login({success: function(res) { can.misc.request(can, can.request(), "/chat/wx/login/action/sess", {code: res.code}, function(msg) { + wx.login({success: function(res) { can.misc.request(can, can.request(), chat.WX_LOGIN_SESS, {code: res.code}, function(msg) { wx.setStorage({key: ice.MSG_SESSID, data: can.conf.sessid = msg.Result()}), cb && cb() }) }}) }, userinfo: function(can, cb) { - can.user.info.userNick? can.misc.request(can, can.request(), "/chat/wx/login/action/user", {}, function(msg) { + can.user.info.userNick? can.misc.request(can, can.request(), chat.WX_LOGIN_USER, {}, function(msg) { cb && cb(can.user.info) }): can.user.login(can, function() { wx.getSetting({success: function(res) { res.authSetting['scope.userInfo'] && wx.getUserInfo({success: function(res) { - can.misc.request(can, can.request(), "/chat/wx/login/action/user", can.user.info = res.userInfo, function(msg) { + can.misc.request(can, can.request(), chat.WX_LOGIN_USER, can.user.info = res.userInfo, function(msg) { cb && cb(can.user.info) }) }}) diff --git a/publish/client/mp/utils/proto.js b/publish/client/mp/utils/proto.js index 27984169..5a20c8ce 100644 --- a/publish/client/mp/utils/proto.js +++ b/publish/client/mp/utils/proto.js @@ -1,4 +1,4 @@ -const {ctx, code, chat} = require("const.js") +const {ctx, nfs, code, chat} = 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++] } @@ -25,14 +25,14 @@ Volcanos._init = function() { }); return msg }, run: function(event, cmds, cb) { - can.misc.requests(can, can.request(event), can.onaction._name||"/chat/action/", {cmds: cmds}, function(msg) { + can.misc.requests(can, can.request(event), can.onaction._name||nfs.CHAT_ACTION, {cmds: cmds}, function(msg) { msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg) }) }, }; Volcanos._page.__proto__ = getApp(), delete(Volcanos._page) var page = {data: {action: can.onaction.list, list: []}, onLoad: function(options) { can.ui = this, can.db = options - console.log(can.ui.route, options) + console.log("app show", can.ui.route, options) can.user.title(decodeURIComponent(options.title||"")) can.user.login(can, function() { if (can.onaction.refresh) { @@ -51,7 +51,6 @@ Volcanos._init = function() { onShareAppMessage: function() {} } can.core.ItemCB(can.onaction, function(key, cb) { page[key] = function(event) { - // can.core.CallFunc(cb, {event: event, can: can, msg: can.request(event, event.target.dataset)}) can.core.CallFunc(cb, [event, can, key, event.target.dataset]) } }), Page(page) }