mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
add mp
This commit is contained in:
parent
bfabe57ea3
commit
87c9232f65
2
const.js
2
const.js
@ -41,6 +41,7 @@ var ice = {
|
|||||||
MSG_USERNICK: "user.nick", MSG_USERNAME: "user.name", MSG_USERROLE: "user.role", MSG_LANGUAGE: "user.lang",
|
MSG_USERNICK: "user.nick", MSG_USERNAME: "user.name", MSG_USERROLE: "user.role", MSG_LANGUAGE: "user.lang",
|
||||||
MSG_MODE: "sess.mode", MSG_THEME: "sess.theme", MSG_TITLE: "sess.title", MSG_RIVER: "sess.river", MSG_STORM: "sess.storm",
|
MSG_MODE: "sess.mode", MSG_THEME: "sess.theme", MSG_TITLE: "sess.title", MSG_RIVER: "sess.river", MSG_STORM: "sess.storm",
|
||||||
MSG_DAEMON: "sess.daemon", LOG_DISABLE: "log.disable", LOG_TRACEID: "log.id",
|
MSG_DAEMON: "sess.daemon", LOG_DISABLE: "log.disable", LOG_TRACEID: "log.id",
|
||||||
|
MSG_DEBUG: "debug",
|
||||||
|
|
||||||
ErrWarn: "warn: ", ErrNotLogin: "not login: ", ErrNotRight: "not right: ", ErrNotValid: "not valid: ", ErrNotFound: "not found: ",
|
ErrWarn: "warn: ", ErrNotLogin: "not login: ", ErrNotRight: "not right: ", ErrNotValid: "not valid: ", ErrNotFound: "not found: ",
|
||||||
NFS: "nfs", USR: "usr", CAN_PLUGIN: "can._plugin",
|
NFS: "nfs", USR: "usr", CAN_PLUGIN: "can._plugin",
|
||||||
@ -133,6 +134,7 @@ var tcp = {
|
|||||||
CLIENT: "client", SERVER: "server",
|
CLIENT: "client", SERVER: "server",
|
||||||
PROTO: "proto", HOST: "host", PORT: "port",
|
PROTO: "proto", HOST: "host", PORT: "port",
|
||||||
SERVICE: "service", HOSTNAME: "hostname",
|
SERVICE: "service", HOSTNAME: "hostname",
|
||||||
|
WIFI: "wifi", SSID: "ssid",
|
||||||
}
|
}
|
||||||
var nfs = {
|
var nfs = {
|
||||||
DIR: "dir", CAT: "cat", DEFS: "defs", PACK: "pack", TRASH: "trash", DIR_ROOT: "dir_root",
|
DIR: "dir", CAT: "cat", DEFS: "defs", PACK: "pack", TRASH: "trash", DIR_ROOT: "dir_root",
|
||||||
|
2
frame.js
2
frame.js
@ -377,7 +377,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
|||||||
})
|
})
|
||||||
}, title: can.user.trans(can, can.Option(key) == undefined? key: "click to detail", null, html.INPUT), _init: function(target) {
|
}, title: can.user.trans(can, can.Option(key) == undefined? key: "click to detail", null, html.INPUT), _init: function(target) {
|
||||||
key == ctx.ACTION && can.onappend.mores(can, target, data, can.user.isMobile && !can.user.isLandscape()? 2: can.isCmdMode()? 5: 3)
|
key == ctx.ACTION && can.onappend.mores(can, target, data, can.user.isMobile && !can.user.isLandscape()? 2: can.isCmdMode()? 5: 3)
|
||||||
can.Option(key) != undefined && can.page.style(can, target, "cursor", "pointer")
|
can.page.style(can, target, "cursor", key == mdb.KEY? "default": can.Option(key) != undefined? "pointer": "text")
|
||||||
}}
|
}}
|
||||||
}); table && can.onappend.style(can, chat.CONTENT, table), table && msg.IsDetail() && can.onappend.style(can, mdb.DETAIL, table)
|
}); table && can.onappend.style(can, chat.CONTENT, table), table && msg.IsDetail() && can.onappend.style(can, mdb.DETAIL, table)
|
||||||
msg.append && msg.append[msg.append.length-1] == ctx.ACTION && can.onappend.style(can, ctx.ACTION, table)
|
msg.append && msg.append[msg.append.length-1] == ctx.ACTION && can.onappend.style(can, ctx.ACTION, table)
|
||||||
|
@ -321,6 +321,7 @@ body.mobile div.project:not(.toggle) { border-right:var(--box-border); width:120
|
|||||||
div.profile:not(.toggle) { border-left:var(--box-border); width:50%; }
|
div.profile:not(.toggle) { border-left:var(--box-border); width:50%; }
|
||||||
div.display:not(.toggle) { border-top:var(--box-border); }
|
div.display:not(.toggle) { border-top:var(--box-border); }
|
||||||
div.output div.code input[type=button][name=login] { background-color:var(--notice-bg-color); color:var(--notice-fg-color); }
|
div.output div.code input[type=button][name=login] { background-color:var(--notice-bg-color); color:var(--notice-fg-color); }
|
||||||
|
table.content td { cursor:pointer; }
|
||||||
/* table card */
|
/* table card */
|
||||||
div.output.card>div.item.stop { color:var(--disable-fg-color); }
|
div.output.card>div.item.stop { color:var(--disable-fg-color); }
|
||||||
div.output.card>div.item { background:var(--plugin-bg-color); padding:10px; border:var(--box-border); border-radius:var(--plugin-radius); margin:10px; width:320px; float:left; box-shadow:var(--box-shadow); }
|
div.output.card>div.item { background:var(--plugin-bg-color); padding:10px; border:var(--box-border); border-radius:var(--plugin-radius); margin:10px; width:320px; float:left; box-shadow:var(--box-shadow); }
|
||||||
|
2
publish/client/mp/Makefile
Normal file
2
publish/client/mp/Makefile
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
all:
|
||||||
|
${CTX_ROOT}/bin/ice.bin web.admin web.chat.wx.ide make
|
@ -5,8 +5,15 @@ 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", appid: "wxf4e5104d83476ed6",
|
data: {}, conf: {
|
||||||
module: "shylinux.com/x/volcanos", version: "v0.2.1"},
|
serve: "https://2021.shylinux.com", appid: "wxf4e5104d83476ed6",
|
||||||
base: base, core: core, misc: misc, page: page, user: user,
|
module: "shylinux.com/x/volcanos", version: "v0.2.1",
|
||||||
onLaunch: function() { console.log("app load", this.conf) },
|
}, base: base, core: core, misc: misc, page: page, user: user,
|
||||||
|
onLaunch: function() {
|
||||||
|
const res = wx.getSystemInfoSync()
|
||||||
|
this.conf.platform = res.platform
|
||||||
|
this.conf.brand = res.brand
|
||||||
|
this.conf.model = res.model
|
||||||
|
console.log("app load", this.conf)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<template name="table">
|
<template name="table">
|
||||||
<table class="{{msg._style}}" wx:if="{{msg}}">
|
<table class="{{msg._style}}" wx:if="{{msg}}">
|
||||||
<tr><th wx:for="{{msg._head}}" wx:key="index">{{item}}</th></tr>
|
<tr><th wx:for="{{msg._head}}" wx:key="index">{{item}}</th></tr>
|
||||||
|
@ -11,7 +11,7 @@ page { padding:10px; }
|
|||||||
page, view { box-sizing: border-box; }
|
page, view { box-sizing: border-box; }
|
||||||
view.debug { font-family:monospace; font-style:italic; padding:10px; clear:both; }
|
view.debug { font-family:monospace; font-style:italic; padding:10px; clear:both; }
|
||||||
view.output { width:100%; overflow:auto; clear:both; }
|
view.output { width:100%; overflow:auto; clear:both; }
|
||||||
view.output textarea { width:100%; }
|
view.output textarea { width:100%; text-align:left; }
|
||||||
view.output view.item { font-size:18px; text-align:center; padding:10px; border:var(--box-border); }
|
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.output view.list view.item { margin-left:20px; }
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {ice, ctx, mdb, code, chat, html} = require("../../utils/const.js")
|
const {ice, ctx, mdb, code, chat, http, 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, {
|
||||||
@ -48,12 +48,13 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
|
|||||||
can.run(event, [ctx.ACTION, ctx.COMMAND], function(msg) {
|
can.run(event, [ctx.ACTION, ctx.COMMAND], 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)
|
||||||
})
|
})
|
||||||
} else if (can.db.cmd||can.db.index) {
|
} else if (can.db.river && can.db.storm) {
|
||||||
can.run(event, [ctx.ACTION, ctx.COMMAND, can.db.cmd||can.db.index], function(msg) {
|
can.onaction._cmds = [can.db.river, can.db.storm]
|
||||||
|
can.run(event, [], function(msg) { can.onimport._init(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.onimport._init(can, 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;
|
||||||
@ -69,8 +70,10 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
|
|||||||
can.onaction._refresh(event, can, order)
|
can.onaction._refresh(event, can, order)
|
||||||
},
|
},
|
||||||
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 msg = can.request(event)
|
||||||
var field = can.ui.data.list[order||0]
|
var field = can.ui.data.list[order||0]
|
||||||
if (field.feature[name]) {
|
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) {
|
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.run(event, can.base.Simple([field.id||field.index, ctx.ACTION, name], res), function(msg) {
|
||||||
can.onaction._refresh(event, can, order)
|
can.onaction._refresh(event, can, order)
|
||||||
@ -84,10 +87,11 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
|
|||||||
can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { input.value = ls[i++]||"" } })
|
can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { input.value = ls[i++]||"" } })
|
||||||
can.onaction._refresh(event, can, order)
|
can.onaction._refresh(event, can, order)
|
||||||
break
|
break
|
||||||
case ctx.RUN:
|
case ctx.RUN: break
|
||||||
case ice.LIST:
|
case ice.LIST:
|
||||||
case "refresh": break
|
case "refresh": msg._method = http.GET
|
||||||
default: m.Option(ctx.ACTION, name)
|
break
|
||||||
|
default: msg.Option(ctx.ACTION, name)
|
||||||
}
|
}
|
||||||
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 } }
|
for (var i = cmd.length-1; i > 0; i--) { if (cmd[i] === "") { cmd.pop() } else { break } }
|
||||||
@ -110,7 +114,8 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
|
|||||||
},
|
},
|
||||||
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) { can.request(event, field.msg.Table()[data.index])
|
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)
|
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]) {
|
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})
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
"condition": {
|
"condition": {
|
||||||
"miniprogram": {
|
"miniprogram": {
|
||||||
"list": [
|
"list": [
|
||||||
|
{
|
||||||
|
"name": "cli.qrcode",
|
||||||
|
"pathName": "pages/action/action",
|
||||||
|
"query": "index=cli.qrcode",
|
||||||
|
"launchMode": "default",
|
||||||
|
"scene": null
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "cli.runtime",
|
"name": "cli.runtime",
|
||||||
"pathName": "pages/action/action",
|
"pathName": "pages/action/action",
|
||||||
|
@ -22,6 +22,8 @@ var ice = {
|
|||||||
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",
|
||||||
MSG_ACTION: "_action", MSG_STATUS: "_status",
|
MSG_ACTION: "_action", MSG_STATUS: "_status",
|
||||||
|
MSG_THEME: "sess.theme",
|
||||||
|
MSG_DEBUG: "debug",
|
||||||
}
|
}
|
||||||
var ctx = {
|
var ctx = {
|
||||||
CONTEXT: "context", COMMAND: "command", CONFIG: "config", INPUTS: "inputs", FEATURE: "feature",
|
CONTEXT: "context", COMMAND: "command", CONFIG: "config", INPUTS: "inputs", FEATURE: "feature",
|
||||||
|
@ -75,12 +75,11 @@ Volcanos("misc", {
|
|||||||
})
|
})
|
||||||
return socket
|
return socket
|
||||||
},
|
},
|
||||||
requests: function(can, msg, cmd, data, cb) {
|
|
||||||
can.misc.request(can, msg, cmd, data, function(msg) { cb && cb(msg) })
|
|
||||||
},
|
|
||||||
request: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid, data.appid = data.appid||can.conf.appid
|
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.db.serve||can.conf.serve)+cmd, data: data, success: function(res) {
|
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) {
|
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) })
|
||||||
|
@ -18,7 +18,17 @@ 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) {
|
||||||
|
if (res.result.indexOf("WIFI:") == 0) {
|
||||||
|
var ls = can.core.Split(res.result, ":;"), data = {}
|
||||||
|
for (var i = 1; i < ls.length; i += 2) { data[ls[i]] = ls[i+1] }
|
||||||
|
console.log("scan", data)
|
||||||
|
can.user.agent.connectWifi(can, data.S, data.P, function() {
|
||||||
|
can.user.toast(can, "success")
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
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)) }
|
||||||
console.log("scan", data)
|
console.log("scan", data)
|
||||||
if (cb && cb(data)) { return }
|
if (cb && cb(data)) { return }
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const {ice, ctx, mdb, nfs, code, chat} = require("const.js")
|
const {kit, ice, ctx, mdb, nfs, code, chat} = require("const.js")
|
||||||
function shy(help, meta, list, cb) { var arg = arguments, i = 0; function next(type) {
|
function shy(help, meta, list, cb) { var arg = arguments, i = 0; function next(type) {
|
||||||
if (type == code.OBJECT) { if (typeof arg[i] == code.OBJECT && arg[i].length == undefined) { return arg[i++] }
|
if (type == code.OBJECT) { if (typeof arg[i] == code.OBJECT && arg[i].length == undefined) { return arg[i++] }
|
||||||
} else if (type == code.ARRAY) { if (typeof arg[i] == code.OBJECT && arg[i].length != undefined) { return arg[i++] }
|
} else if (type == code.ARRAY) { if (typeof arg[i] == code.OBJECT && arg[i].length != undefined) { return arg[i++] }
|
||||||
@ -21,8 +21,11 @@ Volcanos._init = function() {
|
|||||||
}): can.core.Item(can.base.isFunc(item)? item(): item, set)
|
}): can.core.Item(can.base.isFunc(item)? item(): item, set)
|
||||||
}); return msg
|
}); return msg
|
||||||
},
|
},
|
||||||
run: function(event, cmds, cb) { wx.showLoading()
|
run: function(event, cmds, cb) {
|
||||||
can.misc.requests(can, can.request(event, {pod: can.db.pod||can.db.space}), can.onaction._apis||nfs.CHAT_ACTION, {cmds: (can.onaction._cmds||[]).concat(cmds)}, function(msg) {
|
wx.showLoading(); const res = wx.getSystemInfoSync()
|
||||||
|
can.misc.request(can, can.request(event), can.base.MergeURL(can.onaction._apis||nfs.CHAT_ACTION, kit.Dict(
|
||||||
|
ice.POD, can.db.pod||can.db.space, ice.MSG_THEME, res.theme, ice.MSG_DEBUG, can.db.debug,
|
||||||
|
)), {cmds: (can.onaction._cmds||[]).concat(cmds)}, function(msg) {
|
||||||
msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg), wx.hideLoading()
|
msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg), wx.hideLoading()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -31,11 +34,13 @@ Volcanos._init = function() {
|
|||||||
onLoad: function(options) { can.ui = this, can.db = options, can.db.serve = can.db.serve||can.conf.serve
|
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.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])
|
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, can.db)
|
||||||
if (can.db.ssid && can.db.password != "******") {
|
if (can.db.ssid && can.db.password != "******") {
|
||||||
can.user.agent.connectWifi(can, can.db.ssid, can.db.password||"", function() { can.db.password = "******"
|
can.user.agent.connectWifi(can, can.db.ssid, can.db.password||"", function() { can.db.password = "******"
|
||||||
|
can.core.Timer(300, function() {
|
||||||
can.ui.setData({conf: can.db}), can.user.login(can, function() { can.onaction.refresh({}, can) })
|
can.ui.setData({conf: can.db}), can.user.login(can, function() { can.onaction.refresh({}, can) })
|
||||||
})
|
})
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
can.ui.setData({conf: can.db}), can.user.login(can, function() { can.onaction.refresh({}, can) })
|
can.ui.setData({conf: can.db}), can.user.login(can, function() { can.onaction.refresh({}, can) })
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user