1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 08:48:06 +08:00

add mp/theme.json

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-11-19 23:19:44 +08:00
parent 01839c4e74
commit e79536baae
17 changed files with 173 additions and 60 deletions

View File

@ -65,7 +65,7 @@ table.content.full { width:100%; }
table.content thead { position:sticky; top:2px; } table.content thead { position:sticky; top:2px; }
table.content tr.offline { color:var(--disable-fg-color); } table.content tr.offline { color:var(--disable-fg-color); }
table.content tr.offline a { color:var(--disable-fg-color); } table.content tr.offline a { color:var(--disable-fg-color); }
table.content th { padding:5px; box-shadow: var(--box-shadow); } table.content th { padding:5px; box-shadow:var(--box-shadow); }
table.content td { padding:5px; } table.content td { padding:5px; }
table.content.detail td:first-child { width:80px; } table.content.detail td:first-child { width:80px; }
table.content.action th:last-child { position:sticky; right:2px; } table.content.action th:last-child { position:sticky; right:2px; }

View File

@ -5,7 +5,7 @@ const page = require("utils/lib/page.js")
const user = require("utils/lib/user.js") const user = require("utils/lib/user.js")
App({ App({
data: {}, conf: {serve: "https://2021.shylinux.com"}, data: {}, conf: {serve: "https://2021.shylinux.com", appid: "wxf4e5104d83476ed6"},
base: base, core: core, misc: misc, page: page, user: user, base: base, core: core, misc: misc, page: page, user: user,
onLaunch: function() { console.log("app load", this.conf) }, onLaunch: function() { console.log("app load", this.conf) },
}) })

View File

@ -5,12 +5,15 @@
"pages/insert/insert" "pages/insert/insert"
], ],
"window": { "window": {
"backgroundColor": "#000", "navigationBarBackgroundColor": "@navBgColor",
"backgroundTextStyle": "dark", "navigationBarTextStyle": "@navTxtStyle",
"navigationBarBackgroundColor": "#000", "backgroundColor": "@bgColor",
"navigationBarTitleText": "终端工具链", "backgroundTextStyle": "@bgTxtStyle",
"navigationBarTextStyle": "white" "backgroundColorTop": "@bgColorTop",
"backgroundColorBottom": "@bgColorBottom"
}, },
"style": "v2", "style": "v2",
"darkmode": true,
"themeLocation": "theme.json",
"sitemapLocation": "sitemap.json" "sitemapLocation": "sitemap.json"
} }

View File

@ -1,11 +1,17 @@
<template name="action"> <template name="action">
<view class="action"> <view class="action">
<view class="item" wx:for="{{action}}" wx:key="index"> <view class="item button" wx:for="{{action}}" wx:key="index">
<button size="mini" bindtap="onaction" data-name="{{item}}">{{item}}</button> <button size="mini" bindtap="onaction" data-name="{{item}}">{{item}}</button>
</view> </view>
</view> </view>
</template> </template>
<template name="debug">
<view class="debug" wx:if="{{conf.debug == 'true'}}">
<view wx:for="{{conf}}" wx:key="index">{{index}}: {{item}}</view>
</view>
</template>
<template name="list"> <template name="list">
<view class="output"> <view class="output">
<view class="item" wx:for="{{list}}" wx:key="index"> <view class="item" wx:for="{{list}}" wx:key="index">
@ -27,11 +33,11 @@
<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.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.value||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>
@ -49,8 +55,8 @@
</template> </template>
<template name="table"> <template name="table">
<table wx:if="{{msg}}"> <table class="{{msg._style}}" wx:if="{{msg}}">
<tr><th wx:for="{{msg.append}}" wx:key="index">{{item}}</th></tr> <tr><th wx:for="{{msg._head}}" 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">

View File

@ -1,17 +1,33 @@
view { box-sizing: border-box; } page {
page { background-color:black; color:white; } --box-border:lightblue solid 1px;
view.action view.item { padding:0; margin-right:10px; float:left; } --box-shadow:var(--body-fg-color) 2px 2px 8px;
view.output { max-width:-webkit-fill-available; overflow:auto; clear:both; } }
view.output view.item { font-size:18px; text-align:center; padding:10px; border:solid 1px green; } @media (prefers-color-scheme: light) {
view.output view.list view.item { background-color:darkgray; margin-left:20px; } page {
view.legend { font-size:18px; font-weight:bold; margin-top:20px; margin-bottom:10px; } --box-border:lightgreen solid 1px;
view.option view.item { padding:0; border:0; margin:2px; height:32px; float:left; } }
view.option view.item.textarea { border:solid 1px green; width:calc(100% - 2px); clear:both; } }
view.option view.item.select { border:solid 1px green; } page { padding:10px; }
view.option view.item input { border:solid 1px green; height:32px; width:80px; } page, view { box-sizing: border-box; }
view.debug { font-family:monospace; font-style:italic; padding:10px; clear:both; }
view.action view.item { float:left; }
view.action view.item.button { margin-right:5px; }
view.output { width:100%; overflow:auto; clear:both; }
view.output view.item { font-size:18px; text-align:center; padding:10px; border:var(--box-border); }
view.output view.list view.item { margin-left:20px; }
view.legend { font-size:18px; font-weight:bold; margin:10px 0; }
view.option view.item { padding:0; border:0; margin-right:5px; float:left; }
view.option view.item.textarea { border:var(--box-border); width:calc(100% - 2px); clear:both; }
view.option view.item.select { border:var(--box-border); }
view.option view.item picker { border:var(--box-border); height:30px; min-width:80px; }
view.option view.item input { border:var(--box-border); height:30px; min-width:80px; }
view.option view.item button { height:32px; } view.option view.item button { height:32px; }
view.output view.code { white-space:pre; padding:10px; border-left:solid 2px cyan; margin-left:10px; } view.output view.code { white-space:pre; padding:10px; border-left:cyan solid 2px; }
table { display:table; } table { display:table; border-collapse:collapse; }
tr { display:table-row; text-align:center; white-space:nowrap; } tr { display:table-row; }
th { display:table-cell; padding:5px; border:solid 1px red; } th { display:table-cell; padding:5px; border:var(--box-border); vertical-align:middle; text-align:center; }
td { display:table-cell; padding:5px; border:solid 1px green; vertical-align:middle; } td { display:table-cell; padding:5px; border:var(--box-border); vertical-align:middle; min-width:60px; }
td view.which { padding:0; order:0; }
table.content.action th:last-child { position:sticky; right:2px; text-align:center; min-width:60px; }
table.content.action td:last-child { position:sticky; right:2px; text-align:center; min-width:60px; }
picker { min-width:80px; }

View File

@ -19,28 +19,25 @@ Volcanos(chat.ONIMPORT, {
if (input.type == html.SELECT) { if (input.type == html.SELECT) {
input.values = input.values || can.core.Split(input.value) input.values = input.values || can.core.Split(input.value)
} }
if (input.type == html.TEXT) {
input.placeholder = can.user.trans(can, input.placeholder||input.name, can.core.Value(value, "feature._trans"), html.INPUT)
}
if (input.type == html.BUTTON) { if (input.type == html.BUTTON) {
input.value = can.core.Value(value, "feature._trans."+(input.value||input.name)) input.value = can.user.trans(can, input.value||input.name, can.core.Value(value, "feature._trans"))
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({}, [value.id||value.index], function(msg) { can.onaction.onAction({}, can, ice.LIST, {order: index, name: ice.LIST})
value.msg = msg, can.page.setData(can)
})
}) })
}) })
}), can.page.setData(can) }), can.page.setData(can), can.user.toast(can, "加载成功")
}, },
}) })
Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"], 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.onaction._cmds = [], can.onaction._space = "" refresh: function(event, can) {
if (can.db.cmd||can.db.index) { if (can.db.cmd||can.db.index) { can.onaction._cmds = []
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.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) can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onimport._init(can, msg)
}) })
@ -59,6 +56,7 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
onChange: function(event, can, button, data) { var order = data.order, index = data.index onChange: function(event, can, button, data) { var order = data.order, index = data.index
var input = can.ui.data.list[order||0].inputs[index||0] var input = can.ui.data.list[order||0].inputs[index||0]
input.value = input.values[parseInt(event.detail.value)] input.value = input.values[parseInt(event.detail.value)]
can.onaction.onAction({}, can, ice.LIST, {order: index, name: ice.LIST})
}, },
onAction: function(event, can, button, data) { var order = data.order, name = data.name onAction: function(event, can, button, data) { var order = data.order, name = data.name
var field = can.ui.data.list[order||0] var field = can.ui.data.list[order||0]
@ -68,7 +66,7 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST}) can.onaction.onAction(event, can, ice.LIST, {order: order, name: ice.LIST})
}) })
}} }}
can.user.jumps(chat.PAGES_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, serve: can.db.serve, space: can.db.space})
return return
} }
field._history = field._history||[] field._history = field._history||[]
@ -90,20 +88,31 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
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)
can.run(event, [field.id||field.index].concat(cmd), function(msg) { field.msg = msg, can.page.setData(can) }) can.run(event, [field.id||field.index].concat(cmd), function(msg) {
msg._head = can.core.List(msg.append, function(item) {
return can.user.trans(can, item, can.core.Value(field, "feature._trans"), html.INPUT)
})
can.core.Item(msg._view, function(key, value) { can.core.List(value, function(value, index) { can.core.List(value, function(input, i) {
if (input.type == html.BUTTON) {
input.value = can.user.trans(can, input.value||input.name, can.core.Value(field, "feature._trans"))
}
if (input._type == html.TEXT) {
input._text = can.user.trans(can, input._text, can.core.Value(field, "feature._trans"), html.VALUE)
}
}) }) })
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 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) { if (input && input.type == html.BUTTON) { can.request(event, field.msg.Table()[data.index])
can.request(event, field.msg.Table()[data.index])
if (field.feature[input.name]) { if (field.feature[input.name]) {
can.onAction(event, can, input.name, {order: order, name: input.name}) can.onAction(event, can, input.name, {order: order, name: input.name})
} else { } else {
can.run(event, [field.id||field.index, ctx.ACTION, input.name], function(msg) { can.run(event, [field.id||field.index, ctx.ACTION, input.name], function(msg) {
// value.msg = msg, can.page.setData(can) // value.msg = msg, can.page.setData(can)
}) })
} } return
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)

View File

@ -1,4 +1,5 @@
<import src="../../app.wxml"/> <import src="../../app.wxml"/>
<template is="action" data="{{action}}"></template> <template is="action" data="{{action}}"></template>
<template is="debug" data="{{conf}}"></template>
<template is="field" data="{{list}}"></template> <template is="field" data="{{list}}"></template>

View File

@ -1,5 +1,6 @@
<import src="../../app.wxml"/> <import src="../../app.wxml"/>
<template is="action" data="{{action}}"></template> <template is="action" data="{{action}}"></template>
<template is="debug" data="{{conf}}"></template>
<view class="output"> <view class="output">
<view class="item" wx:for="{{list}}" wx:key="index"> <view class="item" wx:for="{{list}}" wx:key="index">
<!-- 文本 --> <!-- 文本 -->

View File

@ -2,7 +2,9 @@ const {ice, nfs, chat, html} = require("../../utils/const.js")
const {shy, Volcanos} = require("../../utils/proto.js") const {shy, Volcanos} = require("../../utils/proto.js")
Volcanos._page = {} Volcanos._page = {}
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { msg.Dump(can) }, _init: function(can, msg) {
msg.Dump(can), can.user.toast(can, "加载成功")
},
}) })
Volcanos("onaction", {list: ["刷新", "扫码", "登录"], Volcanos("onaction", {list: ["刷新", "扫码", "登录"],
"刷新": function(event, can) { can.onaction.refresh(event, can) }, "刷新": function(event, can) { can.onaction.refresh(event, can) },
@ -24,7 +26,7 @@ Volcanos("onaction", {list: ["刷新", "扫码", "登录"],
}, },
onchange: function(event, can, button, data) { var index = data.index, i = data.i onchange: function(event, can, button, data) { var index = data.index, i = data.i
var river = can.ui.data.list[index], storm = river.list[i] var river = can.ui.data.list[index], storm = river.list[i]
can.user.jumps(can.base.MergeURL(chat.PAGES_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, serve: can.db.serve, space: can.db.space}))
}, },
_name: nfs.CHAT_RIVER, _name: nfs.CHAT_RIVER,
}) })

View File

@ -1,3 +1,4 @@
<import src="../../app.wxml"/> <import src="../../app.wxml"/>
<template is="action" data="{{action}}"></template> <template is="action" data="{{action}}"></template>
<template is="debug" data="{{conf}}"></template>
<template is="list" data="{{list}}"></template> <template is="list" data="{{list}}"></template>

View File

@ -0,0 +1,27 @@
{
"light": {
"navBgColor": "#f6f6f6",
"navTxtStyle": "black",
"bgColor": "#f6f6f6",
"bgTxtStyle": "light",
"bgColorTop": "#f6f6f6",
"bgColorBottom": "#efefef",
"tabBgColor": "#ffffff",
"tabSelectedColor": "#3cc51f",
"tabFontColor": "#000000",
"tabBorderStyle": "black"
},
"dark": {
"navBgColor": "#191919",
"navTxtStyle": "white",
"bgColor": "#191919",
"bgTxtStyle": "dark",
"bgColorTop": "#191919",
"bgColorBottom": "#1f1f1f",
"tabBgColor": "#191919",
"tabSelectedColor": "#51a937",
"tabFontColor": "#ffffff",
"tabBorderStyle": "white"
}
}

View File

@ -27,6 +27,7 @@ var ctx = {
} }
var mdb = { var mdb = {
EQ: ice.EQ, FS: ice.FS, EQ: ice.EQ, FS: ice.FS,
TIME: "time", ZONE: "zone", ID: "id",
TYPE: "type", NAME: "name", TEXT: "text", ICON: "icon", ICONS: "icons", TYPE: "type", NAME: "name", TEXT: "text", ICON: "icon", ICONS: "icons",
KEY: "key", VALUE: "value", STATUS: "status", EXPIRE: "expire", EXTRA: "extra", KEY: "key", VALUE: "value", STATUS: "status", EXPIRE: "expire", EXTRA: "extra",
DATA: "data", VIEW: "view", ORDER: "order", DATA: "data", VIEW: "view", ORDER: "order",
@ -79,6 +80,7 @@ var http = {
} }
var html = { var html = {
SELECT: "select", INPUT: "input", TEXT: "text", FILE: "file", TEXTAREA: "textarea", BUTTON: "button", SELECT: "select", INPUT: "input", TEXT: "text", FILE: "file", TEXTAREA: "textarea", BUTTON: "button",
VALUE: "value",
} }
module.exports = { module.exports = {
kit, ice, kit, ice,

View File

@ -49,4 +49,10 @@ Volcanos("base", {
isObject: function(val) { return typeof val == code.OBJECT }, isObject: function(val) { return typeof val == code.OBJECT },
isArray: function(val) { return Array.isArray(val) }, isArray: function(val) { return Array.isArray(val) },
isFunc: function(val) { return typeof val == code.FUNCTION }, 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
} }
},
}) })

View File

@ -1,4 +1,4 @@
const {kit, ice, mdb, nfs, code, chat, http} = require("../const.js") const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("../const.js")
const {Volcanos} = require("../proto.js") const {Volcanos} = require("../proto.js")
module.exports = module.exports =
Volcanos("misc", { Volcanos("misc", {
@ -58,19 +58,28 @@ Volcanos("misc", {
return args 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) }) can.misc.request(can, msg, cmd, data, function(msg) { 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, 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 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) { wx.request({method: http.POST, url: (msg._serve||can.db.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) })
} }
wx.hideLoading()
msg.Copy(res.data), console.log("request", cmd, data.cmds||data, msg) msg.Copy(res.data), console.log("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) { msg.Data = function(item, index) {
var text = msg[item]&&msg[item][index]||"" var text = msg[item]&&msg[item][index]||""
var data = {_type: "text", _text: text} var data = {_type: html.TEXT, _text: text}
if (text.indexOf("<") != 0) { return [data] } if (text.indexOf("<") != 0) { return [data] }
var res = [], list = can.core.Split(text, " ", "<=/>") var res = [], list = can.core.Split(text, " ", "<=/>")
for (var i = 0; i < list.length; i++) { for (var i = 0; i < list.length; i++) {
@ -89,7 +98,7 @@ Volcanos("misc", {
return res.length == 0? [data]: res return res.length == 0? [data]: res
} }
msg._index = []; for (var i = 0; i < msg.Length(); i++) { msg._index.push(i) } 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] = {} 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) } for (var i in msg[k]) { msg._view[k][i] = msg.Data(k, i) }
}), cb && cb(msg) }), cb && cb(msg)
}}) }})

View File

@ -3,5 +3,6 @@ module.exports =
Volcanos("page", { Volcanos("page", {
setData: function(can, list) { setData: function(can, list) {
can.ui.setData({list: list||can.ui.data.list}) can.ui.setData({list: list||can.ui.data.list})
wx.hideLoading()
} }
}) })

View File

@ -19,12 +19,21 @@ 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 (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 }
if (data.cmd) { var serve = /(https?:\/\/[^/]+)([^?#])/.exec(data._origin)[1]; data.serve = serve if (data.cmd||data.index) {
delete(data.type), delete(data.name), delete(data.text), delete(data._origin) if (data.type == web.LINK && data._origin) {
var serve = /(https?:\/\/[^/]+)([^?#])*/.exec(data._origin)[1]; data.serve = serve, delete(data._origin)
delete(data.type), delete(data.name), delete(data.text)
}
can.user.jumps(can.base.MergeURL("/pages/action/action", data)) can.user.jumps(can.base.MergeURL("/pages/action/action", data))
} else { } else {
if (data.type == web.LINK && data._origin) {
var serve = /(https?:\/\/[^/]+)([^?#])*/.exec(data._origin)[1]; data.serve = serve, delete(data._origin)
delete(data.type), delete(data.name), delete(data.text)
can.user.jumps(can.base.MergeURL("/pages/river/river", data))
return
}
can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data) can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data)
} }
}}) }})
@ -32,7 +41,7 @@ Volcanos("user", {
}, info: {}, }, info: {},
jumps: function(url, cb) { wx.navigateTo({url: url, success: cb}) }, jumps: function(url, cb) { wx.navigateTo({url: url, success: cb}) },
title: function(text, cb) { text && wx.setNavigationBarTitle({title: text, success: cb}) }, title: function(text, cb) { text && wx.setNavigationBarTitle({title: text, success: cb}) },
toast: function(can, content, title) { wx.showToast({title: title, content: content||""}) }, toast: function(can, title) { wx.showToast({title: title||""}) },
modal: function(can, content, title, cb) { wx.showModal({title: title||"", content: content||"", success: cb}) }, modal: function(can, content, title, cb) { wx.showModal({title: title||"", content: content||"", success: cb}) },
login: function(can, cb) { login: function(can, cb) {
can.conf.sessid = can.conf.sessid||can.misc.localStorage(can, ice.MSG_SESSID) can.conf.sessid = can.conf.sessid||can.misc.localStorage(can, ice.MSG_SESSID)
@ -52,4 +61,20 @@ Volcanos("user", {
}}) }})
}}) }) }}) })
}, },
trans: function(can, text, list, zone) { if (!text) { return text }
return can.core.Value(list, can.core.Keys(zone, text))||can.core.Value({
"list": "查看", "back": "返回", "create": "创建",
"start": "启动", "stop": "停止", "open": "打开",
"trash": "清理",
input: {
"time": "时间", "link": "链接", "status": "状态", "action": "操作",
"type": "类型", "name": "名称", "text": "内容", "icon": "图标",
"repos": "仓库", "binary": "程序", "script": "脚本", "template": "仓库", "version": "版本",
"path": "路径", "size": "大小",
},
value: {
"start": "启动", "stop": "停止",
},
}, can.core.Keys(zone, text))||text
},
}) })

View File

@ -25,16 +25,20 @@ Volcanos._init = function() {
}); return msg }); return msg
}, },
run: function(event, cmds, cb) { run: function(event, cmds, cb) {
var msg = can.request(event); msg._serve = can.onaction._serve wx.showLoading()
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) { var msg = can.request(event); msg._serve = can.db.serve
can.misc.requests(can, can.request(event, {pod: can.db.pod||can.db.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)
}) })
}, },
}; Volcanos._page.__proto__ = getApp(), delete(Volcanos._page) }; Volcanos._page.__proto__ = getApp(), delete(Volcanos._page)
var page = {data: {action: can.onaction.list, list: []}, var page = {data: {action: can.onaction.list, list: []},
onLoad: function(options) { can.ui = this, can.db = options onLoad: function(options) { can.ui = this, can.db = options
can.db.serve = can.db.serve||can.conf.serve
can.core.Item(can.db, function(key, value) { can.db[key] = decodeURIComponent(value) })
can.user.title(can.db.title||can.db.pod||can.db.space||(can.db.serve||can.conf.serve).split("://")[1])
console.log("app show", can.ui.route, options) console.log("app show", can.ui.route, options)
can.user.title(decodeURIComponent(options.title||"")) can.ui.setData({conf: can.db})
can.user.login(can, function() { can.user.login(can, function() {
if (can.onaction.refresh) { if (can.onaction.refresh) {
can.onaction.refresh({}, can) can.onaction.refresh({}, can)