opt some
11
const.js
@ -89,7 +89,7 @@ var web = {
|
||||
SERVE: "serve", SPACE: "space", DREAM: "dream", ROUTE: "route",
|
||||
SHARE: "share", TOKEN: "token", STATS: "stats", COUNT: "count",
|
||||
SPIDE: "spide", STORE: "store", ADMIN: "admin", MATRIX: "matrix",
|
||||
GRANT: "grant",
|
||||
GRANT: "grant", CHAT_GRANT: "web.chat.grant",
|
||||
|
||||
WORKER: "worker", SERVER: "server", ORIGIN: "origin", VENDOR: "vendor",
|
||||
GATEWAY: "gateway", ONLINE: "online", OFFLINE: "offline",
|
||||
@ -314,12 +314,19 @@ 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_HOME: "/pages/action/home",
|
||||
PAGES_DREAM: "/pages/action/dream",
|
||||
PAGES_DESKTOP: "/pages/action/desktop",
|
||||
PAGES_MY: "/pages/action/my",
|
||||
PAGES_ACTION: "/pages/action/action",
|
||||
PAGES_INSERT: "/pages/insert/insert",
|
||||
PAGES_RIVER: "/pages/river/river",
|
||||
PAGES_GRANT: "/pages/web-chat/grant",
|
||||
|
||||
WX_LOGIN_SESS: "/chat/wx/login/action/sess",
|
||||
WX_LOGIN_USER: "/chat/wx/login/action/user",
|
||||
WX_LOGIN_SCAN: "/chat/wx/login/action/scan",
|
||||
API_HEADER: "/chat/header/",
|
||||
}
|
||||
var team = {
|
||||
TASK: "task", PLAN: "plan", ASSET: "asset",
|
||||
|
@ -1,2 +1,4 @@
|
||||
all:
|
||||
@echo
|
||||
@date +"%Y-%m-%d %H:%M:%S"
|
||||
${CTX_ROOT}/bin/ice.bin web.admin web.chat.wx.ide make
|
||||
|
@ -8,7 +8,8 @@ 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")
|
||||
|
||||
App({conf: conf,
|
||||
App({
|
||||
conf: conf,
|
||||
base: base, core: core,
|
||||
misc: base.Copy(misc, misc_wx),
|
||||
page: base.Copy(page, page_wx),
|
||||
@ -16,12 +17,9 @@ App({conf: conf,
|
||||
onLaunch: function() { const info = wx.getSystemInfoSync()
|
||||
switch (info.language.toLowerCase().replaceAll("_", "-")) {
|
||||
case "zh-cn": base.Copy(user, require("utils/lib/zh-cn.js")); break
|
||||
default: base.Copy(user, require("utils/lib/en-us.js"))
|
||||
user.trans = function(can, text, list, zone) { return text }
|
||||
default: base.Copy(user, require("utils/lib/en-us.js")), user.trans = function(can, text, list, zone) { return text }
|
||||
}
|
||||
this.conf.platform = info.platform
|
||||
this.conf.brand = info.brand
|
||||
this.conf.model = info.model
|
||||
this.conf.platform = info.platform, this.conf.brand = info.brand, this.conf.model = info.model
|
||||
this.misc.Info("app load", this.conf, info)
|
||||
},
|
||||
})
|
||||
|
@ -1,19 +1,52 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/river/river",
|
||||
"pages/action/action",
|
||||
"pages/insert/insert"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarBackgroundColor": "@navBgColor",
|
||||
"navigationBarTextStyle": "@navTxtStyle",
|
||||
"backgroundColor": "@bgColor",
|
||||
"backgroundTextStyle": "@bgTxtStyle",
|
||||
"backgroundColorTop": "@bgColorTop",
|
||||
"backgroundColorBottom": "@bgColorBottom"
|
||||
},
|
||||
"style": "v2",
|
||||
"darkmode": true,
|
||||
"themeLocation": "theme.json",
|
||||
"sitemapLocation": "sitemap.json"
|
||||
}
|
||||
"darkmode": true,
|
||||
"pages": [
|
||||
"pages/action/home",
|
||||
"pages/action/dream",
|
||||
"pages/action/desktop",
|
||||
"pages/action/my",
|
||||
"pages/action/grant",
|
||||
"pages/action/action",
|
||||
"pages/insert/insert",
|
||||
"pages/web-chat/favor"
|
||||
],
|
||||
"style": "v2",
|
||||
"tabBar": {
|
||||
"backgroundColor": "@tabBgColor",
|
||||
"borderStyle": "@tabBorderStyle",
|
||||
"color": "@tabFontColor",
|
||||
"list": [
|
||||
{
|
||||
"iconPath": "@homeIcon",
|
||||
"pagePath": "pages/action/home",
|
||||
"text": "首页"
|
||||
},
|
||||
{
|
||||
"iconPath": "@dreamIcon",
|
||||
"pagePath": "pages/action/dream",
|
||||
"text": "空间"
|
||||
},
|
||||
{
|
||||
"iconPath": "@desktopIcon",
|
||||
"pagePath": "pages/action/desktop",
|
||||
"text": "桌面"
|
||||
},
|
||||
{
|
||||
"iconPath": "@myIcon",
|
||||
"pagePath": "pages/action/my",
|
||||
"text": "我的"
|
||||
}
|
||||
],
|
||||
"selectedColor": "@tabSelectedColor"
|
||||
},
|
||||
"themeLocation": "theme.json",
|
||||
"window": {
|
||||
"backgroundColor": "@bgColor",
|
||||
"backgroundColorBottom": "@bgColorBottom",
|
||||
"backgroundColorTop": "@bgColorTop",
|
||||
"backgroundTextStyle": "@bgTxtStyle",
|
||||
"enablePullDownRefresh": true,
|
||||
"navigationBarBackgroundColor": "@navBgColor",
|
||||
"navigationBarTextStyle": "@navTxtStyle"
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<template name="action">
|
||||
<view class="action">
|
||||
<template name="header">
|
||||
<view class="header">
|
||||
<view class="item button" wx:for="{{action}}" wx:key="index">
|
||||
<button size="mini" bindtap="onaction" data-name="{{item}}">{{item}}</button>
|
||||
<button size="mini" bindtap="onButton" data-name="{{item}}">{{item}}</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
<template name="field">
|
||||
<view class="page action">
|
||||
<template is="action" data="{{action}}"></template>
|
||||
<template is="header" data="{{action}}"></template>
|
||||
<template is="debug" data="{{conf}}"></template>
|
||||
<view class="output">
|
||||
<view class="field {{field.index}}" wx:for="{{list}}" wx:for-index="order" wx:for-item="field" wx:key="index">
|
||||
|
@ -1,42 +1,22 @@
|
||||
page {
|
||||
--box-border:lightblue solid 1px;
|
||||
--box-shadow:var(--body-fg-color) 2px 2px 8px;
|
||||
--disable-fg-color:gray; --notice-bg-color:blue; --danger-bg-color:red;
|
||||
--box-border:var(--body-bg-color) solid 1px;
|
||||
--item-bg-color:white; --body-bg-color:#f6f6f6;
|
||||
--item-padding:10px; --item-icons-size:48px;
|
||||
--action-height:32px; --action-margin:5px;
|
||||
}
|
||||
@media (prefers-color-scheme: light) {
|
||||
@media (prefers-color-scheme: dark) {
|
||||
page {
|
||||
--box-border:lightgreen solid 1px;
|
||||
--notice-bg-color:lightgreen; --danger-bg-color:red;
|
||||
--item-bg-color:black; --body-bg-color:#191919;
|
||||
}
|
||||
}
|
||||
page { padding:10px; }
|
||||
page, view { box-sizing: border-box; }
|
||||
view.output { width:100%; overflow-x:hidden; }
|
||||
view.output textarea { text-align:left; padding:10px; width:100%; }
|
||||
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.field>view.output { overflow:auto; }
|
||||
view.legend { font-size:20px; font-weight:bold; font-style:italic; margin:10px 0; }
|
||||
view.action view.item { padding:0; border:0; margin-right:5px; float:left; }
|
||||
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; width:80px; }
|
||||
view.option view.item input { border:var(--box-border); height:30px; width:80px; }
|
||||
view.option view.item button { height:32px; }
|
||||
view.output view.code { white-space:pre; border-left:cyan solid 1px; }
|
||||
view.status view.item { font-size:12px; font-style:italic; padding:5px; border:none; margin:0; float:left; }
|
||||
view.status view.item text.name { font-size:10px; }
|
||||
view.action.submit view.item { margin-right:0; }
|
||||
view.field.cli.qrcode view.option view.item input { width:70px; }
|
||||
|
||||
table { display:table; border-collapse:collapse; width:100%; }
|
||||
table.debug { font-family:monospace; font-style:italic; }
|
||||
table.debug th { font-weight:bold; }
|
||||
tr { display:table-row; }
|
||||
th { display:table-cell; padding:5px; vertical-align:middle; }
|
||||
td { display:table-cell; padding:5px; vertical-align:middle; }
|
||||
td view.which { padding:0; order:0; }
|
||||
table.content th { border:var(--box-border); text-align:center; }
|
||||
table.content td { border:var(--box-border); min-width:60px; }
|
||||
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; }
|
||||
page { background-color:var(--body-bg-color); }
|
||||
view.item { background-color:var(--item-bg-color); }
|
||||
page, view { box-sizing:border-box; }
|
||||
page { padding-top:var(--action-height); height:100%; width:100%; }
|
||||
view.header { border-bottom:var(--box-border); background-color:var(--item-bg-color); }
|
||||
view.header { width:100%; display:flex; position:fixed; top:0; }
|
||||
view.header view.item { height:var(--action-height); margin-right:var(--action-margin); }
|
||||
view.header view.item button { height:var(--action-height); }
|
||||
view.output { width:100%; overflow:auto; }
|
||||
|
@ -1,5 +1,102 @@
|
||||
const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"]})
|
||||
Volcanos(chat.ONACTION, {
|
||||
list: ["刷新", "扫码", "清屏"],
|
||||
"清屏": 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._apis = "", can.onaction._cmds = []
|
||||
if (can.db.index == "web.chat.grant") {
|
||||
wx.reLaunch({url: can.base.MergeURL("grant", ctx.INDEX, "web.chat.grant", web.SPACE, can.db.space, web.SERVE, can.db.serve)})
|
||||
return
|
||||
}
|
||||
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.index], function(msg) {
|
||||
can.onaction._reload(can, msg)
|
||||
})
|
||||
}
|
||||
},
|
||||
_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.ui.data.list = can.misc.ParseCmd(can, msg, function(field, order) {
|
||||
can.onaction._refresh({}, can, order)
|
||||
}, function(input, index, field, order) {
|
||||
if (can.db.cmd||can.db.index) { input.value = input.value||can.db[input.name] }
|
||||
}), can.page.setData(can), can.user.toast(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) {
|
||||
switch (msg.Option(ice.MSG_PROCESS)) {
|
||||
case "_location":
|
||||
can.user.parse(can, msg.Option("_arg"))
|
||||
}
|
||||
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._init()
|
||||
|
30
publish/client/mp/pages/action/action.wxss
Normal file
@ -0,0 +1,30 @@
|
||||
view.output textarea { text-align:left; padding:10px; width:100%; }
|
||||
view.output view.item { font-size:18px; text-align:center; padding:10px; }
|
||||
view.output view.list view.item { margin-left:20px; }
|
||||
|
||||
view.field>view.output { overflow:auto; }
|
||||
view.legend { font-size:20px; font-weight:bold; font-style:italic; margin:10px 0; }
|
||||
view.action view.item { padding:0; border:0; margin-right:5px; float:left; }
|
||||
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; width:80px; }
|
||||
view.option view.item input { border:var(--box-border); height:30px; width:80px; }
|
||||
view.option view.item button { height:32px; }
|
||||
view.output view.code { white-space:pre; border-left:cyan solid 1px; }
|
||||
view.status view.item { font-size:12px; font-style:italic; padding:5px; border:none; margin:0; float:left; }
|
||||
view.status view.item text.name { font-size:10px; }
|
||||
view.action.submit view.item { margin-right:0; }
|
||||
view.field.cli.qrcode view.option view.item input { width:70px; }
|
||||
|
||||
table { display:table; border-collapse:collapse; width:100%; }
|
||||
table.debug { font-family:monospace; font-style:italic; }
|
||||
table.debug th { font-weight:bold; }
|
||||
tr { display:table-row; }
|
||||
th { display:table-cell; padding:5px; vertical-align:middle; }
|
||||
td { display:table-cell; padding:5px; vertical-align:middle; }
|
||||
td view.which { padding:0; order:0; }
|
||||
table.content th { border:var(--box-border); text-align:center; }
|
||||
table.content td { border:var(--box-border); min-width:60px; }
|
||||
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; }
|
BIN
publish/client/mp/pages/action/desktop-dark.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
publish/client/mp/pages/action/desktop-light.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
9
publish/client/mp/pages/action/desktop.js
Normal file
@ -0,0 +1,9 @@
|
||||
const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONACTION, {
|
||||
onSelect: function(event, can, button, data) {
|
||||
can.user.jumps(can.base.MergeURL("action", ctx.INDEX, data.item.index, web.SPACE, data.item.space, web.SERVE, can.db.serve))
|
||||
},
|
||||
})
|
||||
Volcanos._init()
|
8
publish/client/mp/pages/action/desktop.wxml
Normal file
@ -0,0 +1,8 @@
|
||||
<import src="../../app.wxml"/>
|
||||
<template is="header" data="{{action}}"></template>
|
||||
<view class="output">
|
||||
<view class="item" wx:for="{{list}}" wx:key="name" bindtap="onSelect" data-name="{{item.name}}" data-item="{{item}}">
|
||||
<image class="icon" src="{{item.icon}}"/>
|
||||
<text class="name">{{item.name}}</text>
|
||||
</view>
|
||||
</view>
|
3
publish/client/mp/pages/action/desktop.wxss
Normal file
@ -0,0 +1,3 @@
|
||||
view.output>view.item { width:25%; padding:10px 0; display:flex; flex-direction:column; align-items:center; float:left; }
|
||||
view.output>view.item image.icon { height:64px; width:64px; }
|
||||
view.output>view.item text.name { white-space:pre; }
|
BIN
publish/client/mp/pages/action/dream-dark.png
Normal file
After Width: | Height: | Size: 5.1 KiB |
BIN
publish/client/mp/pages/action/dream-light.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
9
publish/client/mp/pages/action/dream.js
Normal file
@ -0,0 +1,9 @@
|
||||
const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONACTION, {
|
||||
onSelect: function(event, can, button, data) {
|
||||
can.user.switchTab(can, "desktop")
|
||||
},
|
||||
})
|
||||
Volcanos._init()
|
17
publish/client/mp/pages/action/dream.wxml
Normal file
@ -0,0 +1,17 @@
|
||||
<import src="../../app.wxml"/>
|
||||
<template is="header" data="{{action}}"></template>
|
||||
<view class="output">
|
||||
<view class="item {{item.type}}" wx:for="{{list}}" wx:key="name" bindtap="onSelect" data-name="{{item.name}}" data-item="{{item}}">
|
||||
<image class="icons" src="{{item.icons}}"/>
|
||||
<view class="info">
|
||||
<view class="title">
|
||||
<text class="name">{{item.name}}</text>
|
||||
<text class="tags restart" wx:if="{{item.restart}}">{{item.restart}}</text>
|
||||
<text class="tags access" wx:if="{{item.access}}">{{item.access}}</text>
|
||||
<text class="tags {{item.type}}">{{item.type}}</text>
|
||||
</view>
|
||||
<view class="label">{{item.module}}</view>
|
||||
<view class="label">{{item.time}} {{item.version}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
11
publish/client/mp/pages/action/dream.wxss
Normal file
@ -0,0 +1,11 @@
|
||||
view.output>view.item { border-bottom:var(--box-border); padding:var(--item-padding); display:flex; }
|
||||
view.output>view.item image.icons { height:var(--item-icons-size); width:var(--item-icons-size); margin-right:var(--item-padding); }
|
||||
view.output>view.item view.info { text-align:left; flex-grow:1; }
|
||||
view.output>view.item view.info text.name { font-size:18px; }
|
||||
view.output>view.item view.info text.tags { font-size:12px; padding:0 5px; margin-left:5px; }
|
||||
view.output>view.item view.info text.tags.restart { border:var(--notice-bg-color) solid 1px; color:var(--notice-bg-color); }
|
||||
view.output>view.item view.info text.tags.access { border:var(--danger-bg-color) solid 1px; color:var(--danger-bg-color); }
|
||||
view.output>view.item view.info text.tags.worker { display:none; }
|
||||
view.output>view.item view.info text.tags.server { border:var(--notice-bg-color) solid 1px; color:var(--notice-bg-color); }
|
||||
view.output>view.item view.info text.tags.origin { border:var(--danger-bg-color) solid 1px; color:var(--danger-bg-color); }
|
||||
view.output>view.item view.label { color:var(--disable-fg-color); font-size:12px; }
|
21
publish/client/mp/pages/action/grant.js
Normal file
@ -0,0 +1,21 @@
|
||||
const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
can.page.setData(can, msg.TableDetail())
|
||||
},
|
||||
})
|
||||
Volcanos(chat.ONACTION, {
|
||||
refresh: function(event, can) {
|
||||
can.run(event, [can.db.space], function(msg) {
|
||||
can.onimport._init(can, msg)
|
||||
})
|
||||
},
|
||||
onConfirm: function(event, can) {
|
||||
can.run(can.request(event, {space: can.db.space}), [ctx.ACTION, "confirm"], function(msg) {
|
||||
can.user.switchTab(can, web.DREAM)
|
||||
})
|
||||
},
|
||||
})
|
||||
Volcanos._init()
|
7
publish/client/mp/pages/action/grant.wxml
Normal file
@ -0,0 +1,7 @@
|
||||
<view class="output">
|
||||
<view class="info">
|
||||
<view>ip: {{list.ip}}</view>
|
||||
<view>ua: {{list.ua}}</view>
|
||||
</view>
|
||||
<button type="primary" bindtap="onConfirm">请授权登录</button>
|
||||
</view>
|
2
publish/client/mp/pages/action/grant.wxss
Normal file
@ -0,0 +1,2 @@
|
||||
view.output { display:flex; flex-direction:column; justify-content:center; align-items:center; }
|
||||
view.output view.info { margin:40px 0; }
|
BIN
publish/client/mp/pages/action/home-dark.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
publish/client/mp/pages/action/home-light.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
24
publish/client/mp/pages/action/home.js
Normal file
@ -0,0 +1,24 @@
|
||||
const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, list) { var _list = []
|
||||
can.core.List(list, function(msg) { _list = _list.concat(can.misc.table(can, msg)) }), can.page.setData(can, _list)
|
||||
},
|
||||
})
|
||||
Volcanos(chat.ONACTION, {list: ["刷新", "扫码"],
|
||||
refresh: function(event, can) { can.onaction._cmds = []
|
||||
var list = [], _list = can.misc.serveList(can)
|
||||
can.core.Next(_list, function(serve, next) { var msg = can.request(); msg._serve = serve.serve, msg._sessid = serve.sessid; var done = false
|
||||
can.run(msg._event, [ctx.ACTION, ctx.RUN, web.SPACE, ctx.ACTION, "info"], function(msg) {
|
||||
msg.Push("title", serve.serve.split("://")[1]), msg.Push("sessid", serve.sessid)
|
||||
msg.Push(ctx.STYLE, msg._serve == can.db.serve? "current": "")
|
||||
msg.Push(web.SERVE, msg._serve), list.push(msg), can.onimport._init(can, list), done || next(), done = true
|
||||
}), can.onmotion.delay(can, function() { done || next(), done = true }, 3000)
|
||||
})
|
||||
},
|
||||
onSelect: function(event, can, button, data) {
|
||||
can.user.switchTab(can, web.DREAM, data.item, true)
|
||||
},
|
||||
})
|
||||
Volcanos._init()
|
18
publish/client/mp/pages/action/home.wxml
Normal file
@ -0,0 +1,18 @@
|
||||
<import src="../../app.wxml"/>
|
||||
<template is="header" data="{{action}}"></template>
|
||||
<view class="output">
|
||||
<view class="serve">
|
||||
<view class="item {{item.style}}" wx:for="{{list}}" wx:key="name" bindtap="onSelect" data-name="{{item.name}}" data-item="{{item}}">
|
||||
<image class="icons" src="{{item.icons}}"></image>
|
||||
<view class="info">
|
||||
<view class="title">
|
||||
<text class="name">{{item.title}}</text>
|
||||
<text class="tags sessid" wx:if="{{item.sessid}}">已登录</text>
|
||||
<text class="tags style" wx:if="{{item.style}}">当前</text>
|
||||
</view>
|
||||
<view class="label">{{item.module}}</view>
|
||||
<view class="label">{{item.time}} {{item.version}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
11
publish/client/mp/pages/action/home.wxss
Normal file
@ -0,0 +1,11 @@
|
||||
view.output>view.serve>view.item { border-bottom:var(--box-border); padding:var(--item-padding); display:flex; }
|
||||
view.output>view.serve>view.item image.icons { height:var(--item-icons-size); width:var(--item-icons-size); margin-right:var(--item-padding); }
|
||||
view.output>view.serve>view.item view.title { display:flex; align-items:center; }
|
||||
view.output>view.serve>view.item view.info { text-align:left; flex-grow:1; }
|
||||
view.output>view.serve>view.item view.info text.name { font-size:18px; }
|
||||
view.output>view.serve>view.item view.info text.tags { font-size:12px; padding:0 5px; margin-left:5px; }
|
||||
view.output>view.serve>view.item view.info text.tags.sessid { border:var(--notice-bg-color) solid 1px; color:var(--notice-bg-color); }
|
||||
view.output>view.serve>view.item view.info text.tags.style { border:var(--danger-bg-color) solid 1px; color:var(--danger-bg-color); }
|
||||
view.output>view.serve>view.item view.label { color:var(--disable-fg-color); font-size:12px; }
|
||||
view.output>view.serve>view.item.current text.name { font-weight:bold; }
|
||||
|
BIN
publish/client/mp/pages/action/my-dark.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
publish/client/mp/pages/action/my-light.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
51
publish/client/mp/pages/action/my.js
Normal file
@ -0,0 +1,51 @@
|
||||
const {kit, ice, ctx, mdb, web, aaa, nfs, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can) {
|
||||
can.ui.setData({info: can.user.info, action: can.onaction.list})
|
||||
},
|
||||
})
|
||||
Volcanos(chat.ONACTION, {list: ["扫码", "登录", "清空"],
|
||||
"登录": function(event, can) {
|
||||
can.onaction.onLogin(event, can)
|
||||
},
|
||||
"清空": function(event, can) {
|
||||
can.misc.serveList(can, "")
|
||||
},
|
||||
refresh: function(event, can) {
|
||||
can.onaction.onLogin(event, can)
|
||||
},
|
||||
onLogin: function(event, can) {
|
||||
can.user.login(can, function() {
|
||||
can.misc.POST(can, can.request(), "/chat/header/", {}, function(msg) {
|
||||
can.user.info.username = msg.Option(ice.MSG_USERNAME)
|
||||
can.user.info.usernick = msg.Option(aaa.USERNICK)
|
||||
can.user.info.avatar = msg.Option(aaa.AVATAR)
|
||||
can.misc.serveList(can, {serve: can.db.serve, username: msg.Option(ice.MSG_USERNAME), usernick: msg.Option(aaa.USERNICK), avatar: msg.Option(aaa.AVATAR)})
|
||||
wx.getUserInfo({success: function(res) { var userInfo = res.userInfo
|
||||
can.user.info.avatar = can.user.info.avatar||userInfo.avatarUrl
|
||||
can.user.info.gender = userInfo.gender
|
||||
can.user.info.city = userInfo.city
|
||||
can.user.info.country = userInfo.country
|
||||
can.user.info.province = userInfo.province
|
||||
can.onimport._init(can), wx.stopPullDownRefresh()
|
||||
}})
|
||||
})
|
||||
})
|
||||
},
|
||||
onChooseAvatar(event, can, button, data) {
|
||||
can.user.info.avatar = event.detail.avatarUrl
|
||||
can.onimport._init(can), can.onexport.info(can)
|
||||
},
|
||||
onBlur: function(event, can) {
|
||||
can.user.info.usernick = event.detail.value
|
||||
can.onimport._init(can), can.onexport.info(can)
|
||||
},
|
||||
})
|
||||
Volcanos(chat.ONEXPORT, {
|
||||
info: function(can) {
|
||||
can.misc.POST(can, can.request(), "/chat/wx/login/action/user", can.user.info, function(msg) {})
|
||||
},
|
||||
})
|
||||
Volcanos._init()
|
22
publish/client/mp/pages/action/my.wxml
Normal file
@ -0,0 +1,22 @@
|
||||
<view class="output">
|
||||
<view class="user">
|
||||
<view class="item">
|
||||
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
|
||||
<image class="avatar" src="{{info.avatar}}"></image>
|
||||
</button>
|
||||
<view class="title">
|
||||
<view wx:if="{{info.usernick}}">
|
||||
<view class="name">{{info.usernick}}</view>
|
||||
</view>
|
||||
<view wx:else>
|
||||
<input class="weui-input" type="nickname" placeholder="请输入昵称" onblur="onBlur"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="conf">
|
||||
<view class="item" wx:for="{{action}}" bindtap="onButton" data-name="{{item}}">
|
||||
<text>{{item}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
9
publish/client/mp/pages/action/my.wxss
Normal file
@ -0,0 +1,9 @@
|
||||
page { padding-top:0; }
|
||||
view.output>view.user>view.item { padding:20px; display:flex; }
|
||||
view.output>view.user>view.item button { height:var(--item-icons-size); width:var(--item-icons-size); padding:0; margin:0; margin-right:var(--item-padding); }
|
||||
view.output>view.user>view.item image { height:var(--item-icons-size); width:var(--item-icons-size); }
|
||||
view.output>view.user>view.item input { text-align:left; margin:0 var(--action-margin); }
|
||||
view.output>view.user>view.item view.title { flex-grow:1; }
|
||||
view.output>view.user>view.item view.name { text-align:left; margin-left:var(--action-margin); }
|
||||
view.output>view.conf { margin-top:20px; }
|
||||
view.output>view.conf>view.item { text-align:center; padding:10px; margin-top:var(--action-margin); display:flex; justify-content:center; }
|
@ -1,5 +1,5 @@
|
||||
const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONACTION, {list: ["刷新", "扫码"],
|
||||
refresh: function(event, can) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "登录"], _apis: nfs.CHAT_RIVER,
|
||||
refresh: function(event, can) { can.run(event, [], function(msg) { msg.Dump(can), can.user.toast(can, "加载成功") }) },
|
||||
|
19
publish/client/mp/pages/web-chat/favor.js
Normal file
@ -0,0 +1,19 @@
|
||||
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("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
msg.Echo("hello world")
|
||||
},
|
||||
})
|
||||
Volcanos(chat.ONACTION, {
|
||||
list: ["刷新", "扫码", "清屏", "登录"],
|
||||
})
|
||||
Volcanos._init()
|
2
publish/client/mp/pages/web-chat/favor.wxml
Normal file
@ -0,0 +1,2 @@
|
||||
<import src="../../app.wxml"/>
|
||||
<template is="field" data="{{action, conf, list}}"></template>
|
@ -1,27 +1,41 @@
|
||||
{
|
||||
"light": {
|
||||
"navBgColor": "#f6f6f6",
|
||||
"homeIcon": "pages/action/home-light.png",
|
||||
"dreamIcon": "pages/action/dream-light.png",
|
||||
"desktopIcon": "pages/action/desktop-light.png",
|
||||
"myIcon": "pages/action/my-light.png",
|
||||
|
||||
"navBgColor": "#ffffff",
|
||||
"navTxtStyle": "black",
|
||||
|
||||
"bgColor": "#f6f6f6",
|
||||
"bgTxtStyle": "light",
|
||||
"bgColorTop": "#f6f6f6",
|
||||
"bgColorBottom": "#efefef",
|
||||
"bgTxtStyle": "light",
|
||||
|
||||
"tabBorderStyle": "black",
|
||||
"tabBgColor": "#ffffff",
|
||||
"tabSelectedColor": "#3cc51f",
|
||||
"tabFontColor": "#000000",
|
||||
"tabBorderStyle": "black"
|
||||
"tabSelectedColor": "#3cc51f"
|
||||
},
|
||||
"dark": {
|
||||
"navBgColor": "#191919",
|
||||
"homeIcon": "pages/action/home-dark.png",
|
||||
"dreamIcon": "pages/action/dream-dark.png",
|
||||
"desktopIcon": "pages/action/desktop-dark.png",
|
||||
"myIcon": "pages/action/my-dark.png",
|
||||
|
||||
"navBgColor": "#000000",
|
||||
"navTxtStyle": "white",
|
||||
|
||||
"bgColor": "#191919",
|
||||
"bgTxtStyle": "dark",
|
||||
"bgColorTop": "#191919",
|
||||
"bgColorBottom": "#1f1f1f",
|
||||
"tabBgColor": "#191919",
|
||||
"tabSelectedColor": "#51a937",
|
||||
"bgTxtStyle": "dark",
|
||||
|
||||
"tabBorderStyle": "white",
|
||||
"tabBgColor": "#000000",
|
||||
"tabFontColor": "#ffffff",
|
||||
"tabBorderStyle": "white"
|
||||
"tabSelectedColor": "#51a937"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,111 +3,23 @@ const {kit, ice,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
http, html,
|
||||
} = require("const.js")
|
||||
const {shy, Volcanos} = require("proto.js")
|
||||
const {shy, Volcanos} = require("proto-wx.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONIMPORT, {})
|
||||
Volcanos(chat.ONACTION, {
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) {
|
||||
can.page.setData(can, can.misc.table(can, msg))
|
||||
},
|
||||
})
|
||||
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) },
|
||||
_refresh: function(event, can, order) { can.page.setData(can)
|
||||
can.onaction.onAction({}, can, ice.LIST, {order: order, name: ice.LIST})
|
||||
refresh: function(event, can) {
|
||||
can.run(event, [], function(msg) { can.onimport._init(can, msg) })
|
||||
},
|
||||
_reload: function(can, msg) {
|
||||
can.ui.data.list = can.misc.ParseCmd(can, msg, function(field, order) {
|
||||
can.onaction._refresh({}, can, order)
|
||||
}, function(input, index, field, order) {
|
||||
if (can.db.cmd||can.db.index) { input.value = input.value||can.db[input.name] }
|
||||
}), can.page.setData(can), can.user.toast(can, "加载成功")
|
||||
},
|
||||
refresh: function(event, can) { can.onaction._apis = "", can.onaction._cmds = []
|
||||
if (can.db.index == "web.chat.grant") {
|
||||
wx.redirectTo({url: can.base.MergeURL("grant", {serve: can.db.serve, space: can.db.space})})
|
||||
return
|
||||
}
|
||||
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;
|
||||
onButton: 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) {
|
||||
switch (msg.Option(ice.MSG_PROCESS)) {
|
||||
case "_location":
|
||||
can.user.parse(can, msg.Option("_arg"))
|
||||
}
|
||||
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
|
||||
|
@ -3,18 +3,19 @@ const {kit, ice,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
http, html,
|
||||
} = require("../const.js")
|
||||
const {shy, Volcanos} = require("../proto.js")
|
||||
const {shy, Volcanos} = require("../proto-wx.js")
|
||||
module.exports =
|
||||
Volcanos("misc", {
|
||||
POST: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid, data.appid = data.appid||can.conf.appid
|
||||
POST: function(can, msg, cmd, data, cb) {
|
||||
var serve = msg._serve||can.db.serve||can.conf.serve, url = serve+cmd
|
||||
data.sessid = msg._sessid||can.misc.serveList(can, {serve: can.db.serve}).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 = "")
|
||||
can.misc.serveList(can, {serve: serve, sessid: "", userinfo: {}})
|
||||
return can.user.login(can, function() { can.misc.POST(can, msg, cmd, data, cb) })
|
||||
}
|
||||
if (res.statusCode == 403) { msg.result = [res.data] }
|
||||
@ -69,4 +70,40 @@ Volcanos("misc", {
|
||||
}); return can._socket = socket
|
||||
},
|
||||
localStorage: function(can, key, value) { value != undefined && wx.setStorageSync(key, value); return wx.getStorageSync(key) },
|
||||
serveList: function(can, data, current) { var serveList = can.base.Obj(can.misc.localStorage(can, "serveList"), [{serve: can.conf.serve}])
|
||||
if (data === "") {
|
||||
can.misc.localStorage(can, "serveList", "")
|
||||
can.misc.localStorage(can, "serve", "")
|
||||
can.user.switchTab(can, "home", {})
|
||||
}
|
||||
if (!data) { return serveList }
|
||||
current && can.misc.localStorage(can, web.SERVE, data.serve)
|
||||
for (var i = 0; i < serveList.length; i++) {
|
||||
if (serveList[i].serve == data.serve) {
|
||||
can.base.Copy(serveList[i], data), can.misc.localStorage(can, "serveList", JSON.stringify(serveList))
|
||||
return serveList[i]
|
||||
}
|
||||
}
|
||||
serveList.push(data), can.misc.localStorage(can, "serveList", JSON.stringify(serveList))
|
||||
return data
|
||||
},
|
||||
table: function(can, msg) {
|
||||
return msg.Table(function(value) {
|
||||
if (value.icons) {
|
||||
if (!can.base.beginWith(value.icons, web.HTTP)) {
|
||||
if (!can.base.beginWith(value.icons, nfs.PS)) { value.icons = nfs.P + value.icons }
|
||||
value.icons = can.misc.Resource(can, value.icons, value.space, can.db.serve)
|
||||
}
|
||||
}
|
||||
if (value.icon) {
|
||||
if (!can.base.beginWith(value.icon, web.HTTP)) {
|
||||
if (!can.base.beginWith(value.icon, nfs.PS)) { value.icon = nfs.P + value.icon }
|
||||
value.icon = can.misc.Resource(can, value.icon, value.space, can.db.serve)
|
||||
}
|
||||
}
|
||||
value.time = can.base.trimPrefix(value.time, can.base.Time(null, "%y-"))
|
||||
value.time = can.core.Split(value.time, ":").slice(0, -1).join(":")
|
||||
return value
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -3,9 +3,9 @@ const {kit, ice,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
http, html,
|
||||
} = require("../const.js")
|
||||
const {shy, Volcanos} = require("../proto.js")
|
||||
const {shy, Volcanos} = require("../proto-wx.js")
|
||||
module.exports =
|
||||
Volcanos("page", {
|
||||
setData: function(can, list) { can.ui.setData({list: list||can.ui.data.list}) },
|
||||
|
@ -5,7 +5,7 @@ const {kit, ice,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
} = require("../const.js")
|
||||
const {shy, Volcanos} = require("../proto.js")
|
||||
const {shy, Volcanos} = require("../proto-wx.js")
|
||||
module.exports =
|
||||
Volcanos("user", {
|
||||
agent: {
|
||||
@ -44,10 +44,25 @@ Volcanos("user", {
|
||||
}})
|
||||
},
|
||||
}, info: {},
|
||||
scene: function(can, scene) {
|
||||
can.misc.POST(can, can.request(), "/chat/wx/login/action/scene", {scene: scene, serve: can.db.serve}, function(msg) {
|
||||
can.misc.Info("app parse", msg.Result()), can.user.parse(can, msg.Result())
|
||||
})
|
||||
scene: function(can, scene, cb) {
|
||||
function post() {
|
||||
can.misc.POST(can, can.request(), "/chat/wx/login/action/scene", {scene: scene, serve: can.db.serve}, function(msg) {
|
||||
can.misc.Info("app scene", msg.Result()), can.user.parse(can, msg.Result())
|
||||
})
|
||||
}
|
||||
function wifi(cb) { can.db.ssid && can.db.password != "******"? can.user.agent.connectWifi(can, can.db.ssid, can.db.password||"", function() { can.db.password = "******", cb() }): cb() }
|
||||
if (scene) { var ls = scene.split(nfs.PS); scene = ls[2]
|
||||
if (ls[0] == "s") { can.db.serve = "https://"+ls[1] }
|
||||
if (ls[0] == "h") { can.db.serve = "http://"+ls[1] }
|
||||
if (ls[0] == "w") {
|
||||
wx.getLocalIPAddress({success(res) {
|
||||
can.db.serve = "http://"+res.localip.split(".").slice(0,3).join(".")+"."+parseInt("0x"+ls[1])+":9020", can.db.ssid = ls[3], can.db.password = ls[4]
|
||||
wifi(function() { post() })
|
||||
} })
|
||||
} else {
|
||||
wifi(function() { post() })
|
||||
}
|
||||
} else { wifi(cb) }
|
||||
},
|
||||
parse: function(can, text, cb) {
|
||||
if (text.indexOf("WIFI:") == 0) { var data = kit.Dict(can.core.Split(text, ":;").slice(1))
|
||||
@ -63,16 +78,18 @@ Volcanos("user", {
|
||||
if (ls[2].indexOf("/pages/") == 0) { data.pages = ls[2] }
|
||||
}
|
||||
can.misc.Info("app parse", data)
|
||||
if (data.cmd == "admin") {
|
||||
can.user.jumps(can.base.MergeURL(data.pages||chat.PAGES_RIVER, data))
|
||||
} if (data.cmd||data.index||data.share) {
|
||||
if (data.cmd||data.index||data.share) {
|
||||
can.user.jumps(can.base.MergeURL(data.pages||chat.PAGES_ACTION, data))
|
||||
} else if (data.pod||data.space||data.serve) {
|
||||
can.user.jumps(can.base.MergeURL(data.pages||chat.PAGES_RIVER, data))
|
||||
can.user.switchTab(can, web.DREAM, data)
|
||||
} else {
|
||||
can.misc.POST(can, can.request(), chat.WX_LOGIN_SCAN, data)
|
||||
}
|
||||
},
|
||||
switchTab: function(can, name, data, force) { data = data||can.db
|
||||
if (!force && data.serve == can.db.serve) { return wx.switchTab({url: name}) }
|
||||
can.misc.localStorage(can, web.SERVE, data.serve||""), wx.reLaunch({url: name})
|
||||
},
|
||||
jumps: function(url, cb) { wx.navigateTo({url: url, success: cb, fail: function(res) { console.warn(res) }}) },
|
||||
title: function(text, cb) { text && wx.setNavigationBarTitle({title: text, success: cb}) },
|
||||
trans: function(can, text, list, zone) { if (!text) { return text }
|
||||
@ -80,9 +97,9 @@ Volcanos("user", {
|
||||
}, _trans: {},
|
||||
toast: function(can, title) { wx.showToast({title: title||""}) },
|
||||
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() }
|
||||
login: function(can, cb, cbs) { var serve = can.misc.serveList(can, {serve: can.db.serve}); if (serve.sessid) { return cb && cb() }
|
||||
wx.login({success: function(res) { can.misc.POST(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()
|
||||
}) }})
|
||||
can.misc.serveList(can, {serve: can.db.serve, sessid: msg.Result()}), cb && cb()
|
||||
}) }, fail: function(res) { cbs && cbs(res) }})
|
||||
},
|
||||
})
|
||||
|
@ -3,7 +3,7 @@ const {kit, ice,
|
||||
lex, yac, ssh, gdb,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html, icon, svg
|
||||
http, html,
|
||||
} = require("const.js")
|
||||
|
||||
function shy(help, meta, list, cb) { var arg = arguments, i = 0; function next(type) {
|
||||
@ -15,7 +15,6 @@ function Volcanos(name, list) { if (Volcanos._page) { Volcanos._page[name] = lis
|
||||
|
||||
Volcanos._init = function() { var page = Volcanos._page; page.__proto__ = getApp(), delete(Volcanos._page)
|
||||
var can = {__proto__: page,
|
||||
Option: function() { return {} },
|
||||
request: function(event) { event = event||{}, event = event._event||event
|
||||
var msg = event._msg||can.misc.Message(event, can); event._msg = msg
|
||||
function set(key, value) { if (key == "_method") { return msg._method = value }
|
||||
@ -27,35 +26,43 @@ Volcanos._init = function() { var page = Volcanos._page; page.__proto__ = getApp
|
||||
}): can.core.Item(can.base.isFunc(item)? item(): item, set)
|
||||
}); return msg
|
||||
},
|
||||
run: function(event, cmds, cb) { wx.showLoading(); const info = wx.getSystemInfoSync()
|
||||
run: function(event, cmds, cb) { const info = wx.getSystemInfoSync(); var done = false
|
||||
can.misc.POST(can, can.request(event, {share: can.db.share}), can.base.MergeURL(can.onaction._apis||nfs.CHAT_ACTION, kit.Dict(
|
||||
// ice.POD, can.db.pod||can.db.space, ice.MSG_THEME, info.theme, ice.MSG_DEBUG, can.db.debug,
|
||||
ice.POD, can.db.pod, ice.MSG_THEME, info.theme, ice.MSG_DEBUG, can.db.debug,
|
||||
)), {cmds: (can.onaction._cmds||[]).concat(cmds)}, function(msg) { wx.hideLoading()
|
||||
ice.POD, can.base.isIn(can.db.index, "grant", "web.chat.grant")? can.db.pod: can.ConfSpace(), ice.MSG_DEBUG, can.db.debug, ice.MSG_THEME, info.theme,
|
||||
)), {cmds: (can.onaction._cmds||[ctx.ACTION, ctx.RUN, can.ConfIndex()]).concat(cmds)}, function(msg) { done = true, wx.hideLoading(), wx.stopPullDownRefresh()
|
||||
msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg)
|
||||
})
|
||||
}), can.onmotion.delay(can, function() { done || wx.showLoading() }, 500)
|
||||
},
|
||||
ConfIndex: function() { return can.db.index||can.ui.route.split("/").pop() },
|
||||
ConfSpace: function() { return can.db.space },
|
||||
Option: function() { return {} },
|
||||
}
|
||||
can.core.Item(require("frame-wx.js"), function(key, mod) { page[key] = can.base.Copy(page[key]||{}, mod, true) })
|
||||
can.core.Item(require("frame.js"), function(key, mod) { page[key] = can.base.Copy(page[key]||{}, mod, true) })
|
||||
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
|
||||
var _page = {data: {action: can.onaction.list, list: []},
|
||||
onLoad: function(options) { can.ui = this, can.db = options, can.db.serve = can.db.serve||can.misc.localStorage(can, web.SERVE)||can.conf.serve
|
||||
can.core.Item(can.db, function(key, value) { can.db[key] = decodeURIComponent(value) })
|
||||
can.core.Item(can.db, function(key, value) { can.db[key] = decodeURIComponent(value) })
|
||||
can.misc.Info("app show", can.ui.route, can.db, can.user.info), can.user.agent.enableDebug(can)
|
||||
can.user.title(can.db.title||can.db.pod||can.db.space||(can.db.serve||can.conf.serve).split("://")[1])
|
||||
function refresh() { can.ui.setData({conf: can.db}), can.user.login(can, function() { can.misc.WSS(can), can.onmotion.delay(can, function() { can.onaction.refresh({}, can) }, 300) }) }
|
||||
function wifi(cb) { can.db.ssid && can.db.password != "******"? can.user.agent.connectWifi(can, can.db.ssid, can.db.password||"", function() { can.db.password = "******", cb() }): cb() }
|
||||
if (can.db.scene) { var ls = can.db.scene.split(nfs.PS); can.db.scene = ls[2]
|
||||
if (ls[0] == "s") { can.db.serve = "https://"+ls[1] } if (ls[0] == "h") { can.db.serve = "http://"+ls[1] }
|
||||
if (ls[0] == "w") { can.db.serve = "http://192.168."+parseInt("0x"+ls[1][0])+"."+parseInt("0x"+ls[1][1])+":9020", can.db.ssid = ls[3], can.db.password = ls[4] }
|
||||
wifi(function() { can.user.scene(can, can.db.scene) })
|
||||
} else { wifi(refresh) }
|
||||
can.misc.Info("app show", can.ui.route, can.db, can.ui, can), can.user.agent.enableDebug(can)
|
||||
can.misc.serveList(can, {serve: can.db.serve}, true)
|
||||
can.user.scene(can, can.db.scene, function() { can.ui.setData({conf: can.db})
|
||||
can.user.login(can, function() { can.misc.WSS(can)
|
||||
can.onmotion.delay(can, function() { can.onaction.refresh({}, can) }, 300)
|
||||
}, function() { can.onaction.refresh({}, can) })
|
||||
})
|
||||
},
|
||||
onShow: function() {}, onReady: function() {}, onHide: function() {},
|
||||
onUnload: function() { can._socket && can._socket.close(), delete(can._socket) },
|
||||
onReachBottom: function() {}, onPullDownRefresh: function() { this.onUnload(), this.onLoad(can.db) }, onShareAppMessage: function() {}
|
||||
}; can.core.ItemCB(can.onaction, function(key, cb) { page[key] = function(event) { can.core.CallFunc(cb, [event, can, key, event.target.dataset]) } }), Page(page)
|
||||
onShow: function() { can.user.title(can.db.title = can.db.title||can.db.pod||can.db.space||can.db.serve.split("://")[1]) },
|
||||
onHide: function() {},
|
||||
onReady: function() {},
|
||||
onReachBottom: function() {},
|
||||
onPullDownRefresh: function() { this.onUnload(), this.onLoad(can.db) },
|
||||
onShareAppMessage: function() {
|
||||
var share = {title: can.db.title, path: can.base.MergeURL(can.ui.route, ctx.INDEX, can.db.index, web.SPACE, can.db.space, web.SERVE, can.db.serve)}
|
||||
can.misc.Info("app share", share)
|
||||
return share
|
||||
},
|
||||
}; can.core.ItemCB(can.onaction, function(key, cb) { _page[key] = function(event) { can.core.CallFunc(cb, [event, can, key, event.currentTarget.dataset]) } }), Page(_page)
|
||||
}
|
||||
|
||||
module.exports = {shy, Volcanos}
|
||||
|