1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 08:48:06 +08:00
This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-11-21 15:53:00 +08:00
parent bfabe57ea3
commit 87c9232f65
13 changed files with 65 additions and 26 deletions

View File

@ -41,6 +41,7 @@ var ice = {
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_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: ",
NFS: "nfs", USR: "usr", CAN_PLUGIN: "can._plugin",
@ -133,6 +134,7 @@ var tcp = {
CLIENT: "client", SERVER: "server",
PROTO: "proto", HOST: "host", PORT: "port",
SERVICE: "service", HOSTNAME: "hostname",
WIFI: "wifi", SSID: "ssid",
}
var nfs = {
DIR: "dir", CAT: "cat", DEFS: "defs", PACK: "pack", TRASH: "trash", DIR_ROOT: "dir_root",

View File

@ -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) {
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)
msg.append && msg.append[msg.append.length-1] == ctx.ACTION && can.onappend.style(can, ctx.ACTION, table)

View File

@ -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.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); }
table.content td { cursor:pointer; }
/* table card */
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); }

View File

@ -0,0 +1,2 @@
all:
${CTX_ROOT}/bin/ice.bin web.admin web.chat.wx.ide make

View File

@ -5,8 +5,15 @@ const page = require("utils/lib/page.js")
const user = require("utils/lib/user.js")
App({
data: {}, conf: {serve: "https://2021.shylinux.com", appid: "wxf4e5104d83476ed6",
module: "shylinux.com/x/volcanos", version: "v0.2.1"},
base: base, core: core, misc: misc, page: page, user: user,
onLaunch: function() { console.log("app load", this.conf) },
data: {}, conf: {
serve: "https://2021.shylinux.com", appid: "wxf4e5104d83476ed6",
module: "shylinux.com/x/volcanos", version: "v0.2.1",
}, 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)
},
})

View File

@ -12,7 +12,6 @@
</view>
</template>
<template name="table">
<table class="{{msg._style}}" wx:if="{{msg}}">
<tr><th wx:for="{{msg._head}}" wx:key="index">{{item}}</th></tr>

View File

@ -11,7 +11,7 @@ page { padding:10px; }
page, view { box-sizing: border-box; }
view.debug { font-family:monospace; font-style:italic; padding:10px; 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.list view.item { margin-left:20px; }

View File

@ -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")
Volcanos._page = {}
Volcanos(chat.ONIMPORT, {
@ -48,12 +48,13 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
can.run(event, [ctx.ACTION, ctx.COMMAND], function(msg) {
can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onimport._init(can, msg)
})
} else if (can.db.cmd||can.db.index) {
can.run(event, [ctx.ACTION, ctx.COMMAND, can.db.cmd||can.db.index], function(msg) {
} else if (can.db.river && can.db.storm) {
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)
})
} 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;
@ -69,8 +70,10 @@ Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
can.onaction._refresh(event, can, order)
},
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]
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)
@ -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.onaction._refresh(event, can, order)
break
case ctx.RUN:
case ctx.RUN: break
case ice.LIST:
case "refresh": break
default: m.Option(ctx.ACTION, name)
case "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 } }
@ -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
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)
if (field.feature[input.name]) {
can.onAction(event, can, input.name, {order: order, name: input.name})

View File

@ -6,6 +6,13 @@
"condition": {
"miniprogram": {
"list": [
{
"name": "cli.qrcode",
"pathName": "pages/action/action",
"query": "index=cli.qrcode",
"launchMode": "default",
"scene": null
},
{
"name": "cli.runtime",
"pathName": "pages/action/action",

View File

@ -22,6 +22,8 @@ var ice = {
MSG_FIELDS: "fields", MSG_SESSID: "sessid",
MSG_DETAIL: "detail", MSG_OPTION: "option", MSG_APPEND: "append", MSG_RESULT: "result",
MSG_ACTION: "_action", MSG_STATUS: "_status",
MSG_THEME: "sess.theme",
MSG_DEBUG: "debug",
}
var ctx = {
CONTEXT: "context", COMMAND: "command", CONFIG: "config", INPUTS: "inputs", FEATURE: "feature",

View File

@ -75,12 +75,11 @@ Volcanos("misc", {
})
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
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) {
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) })

View File

@ -18,7 +18,17 @@ Volcanos("user", {
}})
},
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)) }
console.log("scan", data)
if (cb && cb(data)) { return }

View File

@ -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) {
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++] }
@ -21,8 +21,11 @@ Volcanos._init = function() {
}): can.core.Item(can.base.isFunc(item)? item(): item, set)
}); return msg
},
run: function(event, cmds, cb) { wx.showLoading()
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) {
run: function(event, cmds, cb) {
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()
})
},
@ -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
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, can.db)
if (can.db.ssid && 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) })
})
})
} else {
can.ui.setData({conf: can.db}), can.user.login(can, function() { can.onaction.refresh({}, can) })
}