mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
add mp
This commit is contained in:
parent
8bad0dc706
commit
01839c4e74
3
frame.js
3
frame.js
@ -145,7 +145,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
|||||||
}); return sub
|
}); return sub
|
||||||
},
|
},
|
||||||
_option: function(can, meta, option, skip) { var index = -1, args = can.base.Obj(meta.args||meta.arg, []), opts = can.base.Obj(meta.opts, {})
|
_option: function(can, meta, option, skip) { var index = -1, args = can.base.Obj(meta.args||meta.arg, []), opts = can.base.Obj(meta.opts, {})
|
||||||
meta.inputs = can.base.Obj(meta.inputs, [{type: html.BUTTON, name: html.LIST, action: html.AUTO}])
|
meta.inputs = can.base.Obj(meta.inputs, []), meta.inputs.length == 0 && can.onmotion.delay(can, function() { can.Update() })
|
||||||
can.core.List([""].concat(meta.inputs), function(item) { if (item != "" && item.type != html.BUTTON) { return }
|
can.core.List([""].concat(meta.inputs), function(item) { if (item != "" && item.type != html.BUTTON) { return }
|
||||||
var icon = {
|
var icon = {
|
||||||
"": {name: mdb.DELETE, cb: function(event) { can.onaction.close(event, can) }},
|
"": {name: mdb.DELETE, cb: function(event) { can.onaction.close(event, can) }},
|
||||||
@ -355,6 +355,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
|||||||
if (key == nfs.IMAGE && value) { value = can.core.List(can.core.Split(data[key]), function(item) { return img(can.misc.ShareCache(can, item)) }).join("") }
|
if (key == nfs.IMAGE && value) { value = can.core.List(can.core.Split(data[key]), function(item) { return img(can.misc.ShareCache(can, item)) }).join("") }
|
||||||
if (key == mdb.ICONS && value) { value = img(can.misc.Resource(can, data[key])) }
|
if (key == mdb.ICONS && value) { value = img(can.misc.Resource(can, data[key])) }
|
||||||
if (key == mdb.NAME) { value = can.user.trans(can, value, null, html.INPUT) }
|
if (key == mdb.NAME) { value = can.user.trans(can, value, null, html.INPUT) }
|
||||||
|
if (key == aaa.PASSWORD) { value = "******" }
|
||||||
return {text: [msg.IsDetail() && key == mdb.KEY? can.user.trans(can, value, null, html.INPUT): can.user.trans(can, value, null, html.VALUE), html.TD], onclick: function(event) { var target = event.target
|
return {text: [msg.IsDetail() && key == mdb.KEY? can.user.trans(can, value, null, html.INPUT): can.user.trans(can, value, null, html.VALUE), html.TD], onclick: function(event) { var target = event.target
|
||||||
if (key == cli.QRCODE && can.page.tagis(event.target, html.IMG)) { can.user.opens(event.target.title) }
|
if (key == cli.QRCODE && can.page.tagis(event.target, html.IMG)) { can.user.opens(event.target.title) }
|
||||||
if (can.page.tagis(target, html.INPUT) && target.type == html.BUTTON) { can.requestAction(event, target.name)
|
if (can.page.tagis(target, html.INPUT) && target.type == html.BUTTON) { can.requestAction(event, target.name)
|
||||||
|
@ -494,6 +494,7 @@ body.mobile div.output.stats { justify-content:space-around; }
|
|||||||
div.output.stats>div.item { text-align:center; padding:10px; margin:10px; float:left; display:flex; flex-direction:column; justify-content:center; flex-grow:1; }
|
div.output.stats>div.item { text-align:center; padding:10px; margin:10px; float:left; display:flex; flex-direction:column; justify-content:center; flex-grow:1; }
|
||||||
div.output.stats>div.item>div.name { font-size:var(--status-font-size); font-style:italic; color:var(--disable-fg-color); }
|
div.output.stats>div.item>div.name { font-size:var(--status-font-size); font-style:italic; color:var(--disable-fg-color); }
|
||||||
div.output.stats>div.item>div.value { font-size:32px; }
|
div.output.stats>div.item>div.value { font-size:32px; }
|
||||||
|
div.output.stats>div.item>div.value span.units { color:var(--disable-fg-color); font-size:24px; font-style:italic; }
|
||||||
fieldset.input.icon div.output td { font-size:28px; padding:5px; }
|
fieldset.input.icon div.output td { font-size:28px; padding:5px; }
|
||||||
fieldset.Search div.story[data-type=spark] { margin:0; }
|
fieldset.Search div.story[data-type=spark] { margin:0; }
|
||||||
fieldset.Search>div.output>div.profile { border-left:none; width:unset; }
|
fieldset.Search>div.output>div.profile { border-left:none; width:unset; }
|
||||||
|
@ -95,7 +95,7 @@ Volcanos("misc", {
|
|||||||
},
|
},
|
||||||
POST: function(can, msg, url, form, cb, cbs) { var xhr = new XMLHttpRequest(), begin = new Date(); msg._xhr = xhr
|
POST: function(can, msg, url, form, cb, cbs) { var xhr = new XMLHttpRequest(), begin = new Date(); msg._xhr = xhr
|
||||||
var data = can.core.ItemForm(form, function(v, i, k) { return k+mdb.EQ+encodeURIComponent(v) }).join("&")
|
var data = can.core.ItemForm(form, function(v, i, k) { return k+mdb.EQ+encodeURIComponent(v) }).join("&")
|
||||||
if (can.base.isIn(msg._method, http.GET, http.DELETE)) { url += (url.indexOf("?") == -1? "?": "&")+data, data = "" }
|
if (data && can.base.isIn(msg._method, http.GET, http.DELETE)) { url += (url.indexOf("?") == -1? "?": "&")+data, data = "" }
|
||||||
xhr.open(msg._method||http.POST, url), xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return }
|
xhr.open(msg._method||http.POST, url), xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return }
|
||||||
try { var res = JSON.parse(xhr.responseText) } catch (e) {
|
try { var res = JSON.parse(xhr.responseText) } catch (e) {
|
||||||
if (xhr.responseText.indexOf("warn: ")) {
|
if (xhr.responseText.indexOf("warn: ")) {
|
||||||
|
@ -369,10 +369,14 @@ Volcanos(chat.ONSYNTAX, {_init: function(can, msg, cb) { if (!msg) { return }
|
|||||||
_split: function(can, msg, content, cb, key) {
|
_split: function(can, msg, content, cb, key) {
|
||||||
var path = msg.Option(nfs.PATH, can.Option(nfs.PATH)), file = msg.Option(nfs.FILE, can.Option(nfs.FILE))
|
var path = msg.Option(nfs.PATH, can.Option(nfs.PATH)), file = msg.Option(nfs.FILE, can.Option(nfs.FILE))
|
||||||
function show(p) {
|
function show(p) {
|
||||||
p && p.include && can.core.List(p.include, function(from) {
|
function include(list) { if (!list || list.length == 0) { return }
|
||||||
|
can.core.List(list, function(from) {
|
||||||
|
p.split = p.split|| can.onsyntax[from].split
|
||||||
|
include(can.onsyntax[from].include)
|
||||||
p.keyword = p.keyword||{}, can.core.Item(can.onsyntax[from].keyword, function(key, value) { p.keyword[key] = p.keyword[key] || value })
|
p.keyword = p.keyword||{}, can.core.Item(can.onsyntax[from].keyword, function(key, value) { p.keyword[key] = p.keyword[key] || value })
|
||||||
can.core.Item(can.onsyntax[from], function(key, value) { p[key] = p[key] || value })
|
can.core.Item(can.onsyntax[from], function(key, value) { p[key] = p[key] || value })
|
||||||
})
|
})
|
||||||
|
} p && include(p.include)
|
||||||
p && p.prepare && can.core.ItemForm(p.prepare, function(value, index, key) { p.keyword = p.keyword||{}, p.keyword[value] = key })
|
p && p.prepare && can.core.ItemForm(p.prepare, function(value, index, key) { p.keyword = p.keyword||{}, p.keyword[value] = key })
|
||||||
if (!content._root && can.db.history.length > 1) { content = can.ui.content = can.page.insertBefore(can, [{view: html.CONTENT, style: {width: can.ui.content.offsetWidth}}], can.ui._profile), content._cache_key = key }
|
if (!content._root && can.db.history.length > 1) { content = can.ui.content = can.page.insertBefore(can, [{view: html.CONTENT, style: {width: can.ui.content.offsetWidth}}], can.ui._profile), content._cache_key = key }
|
||||||
content._max = 0, content._msg = msg, msg.__content = content, can.page.Appends(can, content, [{view: ["tips", "", msg.Option(nfs.FILE)]}])
|
content._max = 0, content._msg = msg, msg.__content = content, can.page.Appends(can, content, [{view: ["tips", "", msg.Option(nfs.FILE)]}])
|
||||||
|
@ -231,8 +231,14 @@ Volcanos(chat.ONSYNTAX, {
|
|||||||
"length": code.FUNCTION, "split": code.FUNCTION, "trim": code.FUNCTION, "toLowerCase": code.FUNCTION, "indexOf": code.FUNCTION, "lastIndexOf": code.FUNCTION,
|
"length": code.FUNCTION, "split": code.FUNCTION, "trim": code.FUNCTION, "toLowerCase": code.FUNCTION, "indexOf": code.FUNCTION, "lastIndexOf": code.FUNCTION,
|
||||||
"concat": code.FUNCTION, "reverse": code.FUNCTION, "slice": code.FUNCTION, "join": code.FUNCTION, "sort": code.FUNCTION, "push": code.FUNCTION, "pop": code.FUNCTION,
|
"concat": code.FUNCTION, "reverse": code.FUNCTION, "slice": code.FUNCTION, "join": code.FUNCTION, "sort": code.FUNCTION, "push": code.FUNCTION, "pop": code.FUNCTION,
|
||||||
"stringify": code.FUNCTION, "parse": code.FUNCTION,
|
"stringify": code.FUNCTION, "parse": code.FUNCTION,
|
||||||
|
"require": code.FUNCTION,
|
||||||
|
|
||||||
|
"kit": code.CONSTANT, "ice": code.CONSTANT,
|
||||||
|
"ctx": code.CONSTANT, "mdb": code.CONSTANT, "web": code.CONSTANT, "aaa": code.CONSTANT,
|
||||||
|
"tcp": code.CONSTANT, "nfs": code.CONSTANT, "cli": code.CONSTANT, "log": code.CONSTANT,
|
||||||
|
"code": code.CONSTANT, "wiki": code.CONSTANT, "chat": code.CONSTANT, "team": code.CONSTANT, "mall": code.CONSTANT,
|
||||||
|
"http": code.CONSTANT, "html": code.CONSTANT, "icon": code.CONSTANT, "svg": code.CONSTANT,
|
||||||
|
|
||||||
"kit": code.PACKAGE, "ice": code.PACKAGE,
|
|
||||||
"can": code.OBJECT, "msg": code.OBJECT, "cb": code.FUNCTION, "target": code.OBJECT, "event": code.OBJECT,
|
"can": code.OBJECT, "msg": code.OBJECT, "cb": code.FUNCTION, "target": code.OBJECT, "event": code.OBJECT,
|
||||||
"Volcanos": code.FUNCTION, "shy": code.FUNCTION, "cbs": code.FUNCTION,
|
"Volcanos": code.FUNCTION, "shy": code.FUNCTION, "cbs": code.FUNCTION,
|
||||||
"res": code.OBJECT, "sub": code.OBJECT, "sup": code.OBJECT,
|
"res": code.OBJECT, "sub": code.OBJECT, "sup": code.OBJECT,
|
||||||
|
@ -7,11 +7,10 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
while (value > 0) { ls.push(value%1000)
|
while (value > 0) { ls.push(value%1000)
|
||||||
if (ls.length == 1) { ls[0] = ls[0].toFixed(2) }
|
if (ls.length == 1) { ls[0] = ls[0].toFixed(2) }
|
||||||
value = parseInt(value/1000)
|
value = parseInt(value/1000)
|
||||||
}
|
} return ls.reverse().join(", ")
|
||||||
return ls.reverse().join(", ")
|
|
||||||
}
|
}
|
||||||
can.core.Item(stats, function(name, value) { can.page.Append(can, can._output, [{view: [[html.ITEM, name]], list: [
|
can.core.Item(stats, function(name, value) { can.page.Append(can, can._output, [{view: [[html.ITEM, name]], list: [
|
||||||
{view: [mdb.VALUE, "", can.base.trimSuffix(fmts(parseFloat(value).toFixed(2))+"", ".00")+" "+units[name]]},
|
{view: mdb.VALUE, list: [{text: can.base.trimSuffix(fmts(parseFloat(value).toFixed(2))+"", ".00")}, {text: [units[name], "", "units"]}]},
|
||||||
{view: [mdb.NAME, "", can.user.trans(can, name, null, html.INPUT)]},
|
{view: [mdb.NAME, "", can.user.trans(can, name, null, html.INPUT)]},
|
||||||
]}]) }), can.isCmdMode() && can.onappend.table(can, msg)
|
]}]) }), can.isCmdMode() && can.onappend.table(can, msg)
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template name="action">
|
<template name="action">
|
||||||
<view class="action">
|
<view class="action">
|
||||||
<view class="item" wx:for="{{action}}" wx:key="index">
|
<view class="item" wx:for="{{action}}" wx:key="index">
|
||||||
<button bindtap="onaction" data-name="{{item}}" size="mini">{{item}}</button>
|
<button size="mini" bindtap="onaction" data-name="{{item}}">{{item}}</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@ -26,15 +26,12 @@
|
|||||||
<!-- 文本 -->
|
<!-- 文本 -->
|
||||||
<textarea wx:if="{{item.type == 'textarea'}}" placeholder="{{item.name}}" value="{{item.value}}"
|
<textarea wx:if="{{item.type == 'textarea'}}" placeholder="{{item.name}}" value="{{item.value}}"
|
||||||
bindinput="onInputs" data-index="{{index}}" data-order="{{order}}"></textarea>
|
bindinput="onInputs" data-index="{{index}}" data-order="{{order}}"></textarea>
|
||||||
|
|
||||||
<!-- 文本 -->
|
<!-- 文本 -->
|
||||||
<input wx:elif="{{item.type == 'text'}}" placeholder="{{item.name}}" value="{{item.value}}" type="text"
|
<input wx:elif="{{item.type == 'text'}}" placeholder="{{item.name}}" value="{{item.value}}" type="text"
|
||||||
bindinput="onInputs" data-index="{{index}}" data-order="{{order}}"/>
|
bindinput="onInputs" data-index="{{index}}" data-order="{{order}}"/>
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<picker wx:elif="{{item.type == 'select'}}" range="{{item.values}}" value="{{item.index||0}}"
|
<picker wx:elif="{{item.type == 'select'}}" range="{{item.values}}" value="{{item.index||0}}"
|
||||||
bindchange="onChange" data-index="{{index}}" data-order="{{order}}">{{item.values[item.index||0]}}</picker>
|
bindchange="onChange" data-index="{{index}}" data-order="{{order}}">{{item.values[item.index||0]}}</picker>
|
||||||
|
|
||||||
<!-- 按钮 -->
|
<!-- 按钮 -->
|
||||||
<button wx:elif="{{item.type == 'button'}}" size="mini"
|
<button wx:elif="{{item.type == 'button'}}" size="mini"
|
||||||
bindtap="onAction" data-index="{{index}}" data-order="{{order}}" data-name="{{item.name}}">{{item.value||item.name}}</button>
|
bindtap="onAction" data-index="{{index}}" data-order="{{order}}" data-name="{{item.name}}">{{item.value||item.name}}</button>
|
||||||
@ -44,7 +41,6 @@
|
|||||||
<view class="output"> <!-- 输出 -->
|
<view class="output"> <!-- 输出 -->
|
||||||
<!-- 表格 -->
|
<!-- 表格 -->
|
||||||
<template is="table" data="{{order: order, msg: field.msg}}"></template>
|
<template is="table" data="{{order: order, msg: field.msg}}"></template>
|
||||||
|
|
||||||
<!-- 文本 -->
|
<!-- 文本 -->
|
||||||
<view class="code"><rich-text wx:for="{{field.msg.result}}" wx:key="index" nodes="{{item}}"></rich-text></view>
|
<view class="code"><rich-text wx:for="{{field.msg.result}}" wx:key="index" nodes="{{item}}"></rich-text></view>
|
||||||
</view>
|
</view>
|
||||||
@ -57,12 +53,13 @@
|
|||||||
<tr><th wx:for="{{msg.append}}" wx:key="index">{{item}}</th></tr>
|
<tr><th wx:for="{{msg.append}}" wx:key="index">{{item}}</th></tr>
|
||||||
<tr wx:for="{{msg._index}}" wx:key="index">
|
<tr wx:for="{{msg._index}}" wx:key="index">
|
||||||
<td wx:for="{{msg.append}}" wx:for-index="i" wx:key="i">
|
<td wx:for="{{msg.append}}" wx:for-index="i" wx:key="i">
|
||||||
<view class="which" wx:for="{{msg._view[item][index]}}" wx:for-item="input" wx:for-index="i" wx:key="i"
|
<view class="which" wx:for="{{msg._view[item][index]}}" wx:for-item="input" wx:for-index="i" wx:key="i">
|
||||||
bindtap="onDetail" data-input="{{input}}" data-value="{{input._text}}" data-name="{{item}}" data-index="{{index}}" data-order="{{order}}">
|
<view wx:if="{{input._type == 'text'}}"
|
||||||
<view wx:if="{{input._type == 'text'}}">{{input._text}}</view>
|
bindtap="onDetail" data-input="{{input}}" data-value="{{input._text}}" data-name="{{item}}" data-index="{{index}}" data-order="{{order}}">{{input._text}}</view>
|
||||||
<rich-text wx:if="{{input._type == 'div'}}" nodes="{{input._text}}"></rich-text>
|
<rich-text wx:if="{{input._type == 'div'}}" nodes="{{input._text}}"></rich-text>
|
||||||
<image wx:if="{{input._type == 'img'}}" mode="aspectFit" src="{{input.src}}"></image>
|
<image wx:if="{{input._type == 'img'}}" mode="aspectFit" src="{{input.src}}"></image>
|
||||||
<button wx:if="{{input._type == 'input' && input.type == 'button'}}" size="mini">{{input.value||input.name}}</button>
|
<button wx:if="{{input._type == 'input' && input.type == 'button'}}" size="mini"
|
||||||
|
bindtap="onDetail" data-input="{{input}}" data-value="{{input._text}}" data-name="{{item}}" data-index="{{index}}" data-order="{{order}}">{{input.value||input.name}}</button>
|
||||||
</view>
|
</view>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -24,7 +24,7 @@ Volcanos(chat.ONIMPORT, {
|
|||||||
input.value = {"list": "查看", "back": "返回", "create": "创建"}[input.value||input.name]||input.value||input.name
|
input.value = {"list": "查看", "back": "返回", "create": "创建"}[input.value||input.name]||input.value||input.name
|
||||||
}
|
}
|
||||||
input.type == html.BUTTON && input.action == ice.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) {
|
can.run({}, [value.id||value.index], function(msg) {
|
||||||
value.msg = msg, can.page.setData(can)
|
value.msg = msg, can.page.setData(can)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -36,7 +36,19 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
|
|||||||
"刷新": function(event, can) { 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.agent.scanQRCode(can) },
|
||||||
"清屏": function(event, can) { can.core.List(can.ui.data.list, function(item) { delete(item.msg) }), can.page.setData(can) },
|
"清屏": 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) }) },
|
refresh: function(event, can) { can.onaction._cmds = [], can.onaction._space = ""
|
||||||
|
if (can.db.cmd||can.db.index) {
|
||||||
|
can.onaction._space = can.db.pod||can.db.space
|
||||||
|
can.onaction._serve = decodeURIComponent(can.db.serve)
|
||||||
|
can.user.title(can.core.Keys(can.onaction._space, can.db.cmd||can.db.index))
|
||||||
|
can.run(event, [ctx.ACTION, ctx.COMMAND, can.db.cmd||can.db.index], function(msg) {
|
||||||
|
can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onimport._init(can, msg)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
can.onaction._cmds = [can.db.river, can.db.storm]
|
||||||
|
can.run(event, [], function(msg) { can.onimport._init(can, msg) })
|
||||||
|
}
|
||||||
|
},
|
||||||
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)
|
(can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
|
||||||
},
|
},
|
||||||
@ -52,7 +64,7 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
|
|||||||
var field = can.ui.data.list[order||0]
|
var field = can.ui.data.list[order||0]
|
||||||
if (field.feature[name]) {
|
if (field.feature[name]) {
|
||||||
can.data.insert = {field: field, name: name, list: field.feature[name], cb: function(res) {
|
can.data.insert = {field: field, name: name, list: field.feature[name], cb: function(res) {
|
||||||
can.run(event, can.base.Simple([can.db.river, can.db.storm, field.id||field.index, ctx.ACTION, name], res), function(msg) {
|
can.run(event, can.base.Simple([field.id||field.index, ctx.ACTION, name], res), function(msg) {
|
||||||
can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST})
|
can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST})
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
@ -71,19 +83,28 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
|
|||||||
case "refresh": break
|
case "refresh": break
|
||||||
default: return
|
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 } })
|
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 }
|
function eq(to, from) { if (!to) { return false }
|
||||||
if (to.length != from.length) { return false }
|
if (to.length != from.length) { return false }
|
||||||
for (var i = 0; i < to.length; i++) { if (to[i] != from[i]) { return false } }
|
for (var i = 0; i < to.length; i++) { if (to[i] != from[i]) { return false } }
|
||||||
return true
|
return true
|
||||||
} eq(field._history[field._history.length-1], cmd) || field._history.push(cmd)
|
} eq(field._history[field._history.length-1], cmd) || field._history.push(cmd)
|
||||||
cmds = cmds.concat(cmd)
|
can.run(event, [field.id||field.index].concat(cmd), function(msg) { field.msg = msg, can.page.setData(can) })
|
||||||
for (var i = cmds.length-1; i > 0; i--) { if (cmds[i] === "") { cmds.pop() } else { break } }
|
|
||||||
can.run(event, cmds, function(msg) { field.msg = msg, can.page.setData(can) })
|
|
||||||
},
|
},
|
||||||
onDetail: function(event, can, button, data) { var order = data.order, name = data.name, value = data.value
|
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]
|
var field = can.ui.data.list[order||0]
|
||||||
|
if (input && input.type == html.BUTTON) {
|
||||||
|
can.request(event, field.msg.Table()[data.index])
|
||||||
|
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) {
|
||||||
|
// value.msg = msg, can.page.setData(can)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
can.core.List(field.inputs, function(input) {
|
can.core.List(field.inputs, function(input) {
|
||||||
if (input.name == name) { input.value = value, can.page.setData(can)
|
if (input.name == name) { input.value = value, can.page.setData(can)
|
||||||
can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST})
|
can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST})
|
||||||
|
@ -15,6 +15,8 @@ var ice = {
|
|||||||
MAIN: "main", AUTO: "auto",
|
MAIN: "main", AUTO: "auto",
|
||||||
LIST: "list", BACK: "back",
|
LIST: "list", BACK: "back",
|
||||||
|
|
||||||
|
CAN: "can", POD: "pod", CTX: "ctx", CMD: "cmd", ARG: "arg",
|
||||||
|
|
||||||
MSG_FIELDS: "fields", MSG_SESSID: "sessid",
|
MSG_FIELDS: "fields", MSG_SESSID: "sessid",
|
||||||
MSG_DETAIL: "detail", MSG_OPTION: "option", MSG_APPEND: "append", MSG_RESULT: "result",
|
MSG_DETAIL: "detail", MSG_OPTION: "option", MSG_APPEND: "append", MSG_RESULT: "result",
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ 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]]) }
|
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: "")
|
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 }
|
ParseJSON: function(str) { var res; if (typeof str == code.OBJECT) { return str }
|
||||||
if (str.indexOf(ice.HTTP) == 0) {
|
if (str.indexOf(ice.HTTP) == 0) {
|
||||||
var res = this._parse(str, {type: web.LINK, name: "", text: str})
|
var res = this._parse(str, {type: web.LINK, name: "", text: str})
|
||||||
|
@ -2,6 +2,14 @@ const {ice, mdb, nfs, code, http} = require("../const.js")
|
|||||||
const {shy, Volcanos} = require("../proto.js")
|
const {shy, Volcanos} = require("../proto.js")
|
||||||
module.exports =
|
module.exports =
|
||||||
Volcanos("core", {
|
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 }
|
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 (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)
|
if (value != undefined) { var _node = data, keys = key.split(nfs.PT)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {kit, ice, mdb, nfs, code, http} = require("../const.js")
|
const {kit, ice, mdb, nfs, code, chat, http} = require("../const.js")
|
||||||
const {Volcanos} = require("../proto.js")
|
const {Volcanos} = require("../proto.js")
|
||||||
module.exports =
|
module.exports =
|
||||||
Volcanos("misc", {
|
Volcanos("misc", {
|
||||||
@ -50,11 +50,19 @@ Volcanos("misc", {
|
|||||||
}); return msg },
|
}); return msg },
|
||||||
Echo: function(res) { msg.result = (msg.result||[]).concat(can.core.List(arguments)); return msg._hand = true, msg },
|
Echo: function(res) { msg.result = (msg.result||[]).concat(can.core.List(arguments)); return msg._hand = true, msg },
|
||||||
}); return msg },
|
}); return msg },
|
||||||
|
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
|
||||||
|
},
|
||||||
requests: function(can, msg, cmd, data, cb) {
|
requests: function(can, msg, cmd, data, cb) {
|
||||||
wx.showLoading(), can.misc.request(can, msg, cmd, data, function(msg) { wx.hideLoading(), cb && cb(msg) })
|
wx.showLoading(), can.misc.request(can, msg, cmd, data, function(msg) { wx.hideLoading(), cb && cb(msg) })
|
||||||
},
|
},
|
||||||
request: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid
|
request: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid
|
||||||
wx.request({method: http.POST, url: can.conf.serve+cmd, data: data, success: function(res) {
|
can.core.List(msg.option, function(key) { data[key] = data[key]||[msg.Option(key)] }), data.option = data.option||msg.option
|
||||||
|
wx.request({method: http.POST, url: (msg._serve||can.conf.serve)+cmd, data: data, success: function(res) {
|
||||||
if (res.statusCode == 401) {
|
if (res.statusCode == 401) {
|
||||||
can.user.info = {}, can.misc.localStorage(can, ice.MSG_SESSID, can.conf.sessid = "")
|
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) })
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {ice, ctx, mdb, chat} = require("../const.js")
|
const {ice, ctx, mdb, web, chat} = require("../const.js")
|
||||||
const {shy, Volcanos} = require("../proto.js")
|
const {shy, Volcanos} = require("../proto.js")
|
||||||
module.exports =
|
module.exports =
|
||||||
Volcanos("user", {
|
Volcanos("user", {
|
||||||
@ -19,18 +19,13 @@ Volcanos("user", {
|
|||||||
},
|
},
|
||||||
scanQRCode: function(can, cb) {
|
scanQRCode: function(can, cb) {
|
||||||
wx.scanCode({success: function(res) { var data = can.base.ParseJSON(res.result)
|
wx.scanCode({success: function(res) { var data = can.base.ParseJSON(res.result)
|
||||||
|
if (data.type == web.LINK, data._origin) { can.base.Copy(data, can.misc.ParseURL(can, res.result)) }
|
||||||
if (cb && cb(data)) { return }
|
if (cb && cb(data)) { return }
|
||||||
switch (data.type) {
|
if (data.cmd) { var serve = /(https?:\/\/[^/]+)([^?#])/.exec(data._origin)[1]; data.serve = serve
|
||||||
case "auth":
|
delete(data.type), delete(data.name), delete(data.text), delete(data._origin)
|
||||||
can.user.userinfo(can, function() {
|
can.user.jumps(can.base.MergeURL("/pages/action/action", data))
|
||||||
can.user.modal(can, "授权登录", data.name, function(res) {
|
} else {
|
||||||
res.confirm && can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data, function(msg) {
|
can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data)
|
||||||
can.user.toast(can, "授权成功")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
break
|
|
||||||
default: can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data)
|
|
||||||
}
|
}
|
||||||
}})
|
}})
|
||||||
},
|
},
|
||||||
|
@ -25,7 +25,8 @@ Volcanos._init = function() {
|
|||||||
}); return msg
|
}); return msg
|
||||||
},
|
},
|
||||||
run: function(event, cmds, cb) {
|
run: function(event, cmds, cb) {
|
||||||
can.misc.requests(can, can.request(event), can.onaction._name||nfs.CHAT_ACTION, {cmds: cmds}, function(msg) {
|
var msg = can.request(event); msg._serve = can.onaction._serve
|
||||||
|
can.misc.requests(can, can.request(event, {pod: can.onaction._space}), can.onaction._name||nfs.CHAT_ACTION, {cmds: (can.onaction._cmds||[]).concat(cmds)}, function(msg) {
|
||||||
msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg)
|
msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user