mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
add some
This commit is contained in:
parent
f30bdb9696
commit
fda6e6f969
11
misc/wx/ide.shy
Normal file
11
misc/wx/ide.shy
Normal file
@ -0,0 +1,11 @@
|
||||
title "微信小程序"
|
||||
refer `
|
||||
官网 https://weixin.qq.com/
|
||||
后台 https://mp.weixin.qq.com/
|
||||
文档 https://developers.weixin.qq.com/miniprogram/dev/api/
|
||||
`
|
||||
qrcode `https://mp.weixin.qq.com/a/~HkylKD4DZShrgSm5GuXWLQ~~`
|
||||
|
||||
field web.chat.wx.access
|
||||
field web.chat.wx.ide
|
||||
field web.chat.wx.scan
|
@ -1,22 +0,0 @@
|
||||
package wx
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/web"
|
||||
"shylinux.com/x/icebergs/core/chat"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func init() {
|
||||
web.Index.MergeCommands(ice.Commands{
|
||||
web.PP(PAGES): {Actions: aaa.WhiteAction("", ctx.ACTION), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg[0]) == 0 || arg[0] == "" || arg[0] == chat.RIVER {
|
||||
web.RenderMain(m)
|
||||
} else {
|
||||
web.RenderCmd(m, kit.Select(m.Option(ctx.INDEX), m.Option(ice.CMD)))
|
||||
}
|
||||
}},
|
||||
})
|
||||
}
|
126
misc/wx/scan.js
126
misc/wx/scan.js
@ -1,126 +0,0 @@
|
||||
const {ice, ctx, mdb, web, code, chat, http, html} = require("../../utils/const.js")
|
||||
const {shy, Volcanos} = require("../../utils/proto.js")
|
||||
Volcanos._page = {}
|
||||
Volcanos(chat.ONIMPORT, {
|
||||
_init: function(can, msg) { can.ui.data.list = []
|
||||
msg.Table(function(field, order) { can.ui.data.list.push(field)
|
||||
field.feature = can.base.Obj(field.meta, {})
|
||||
field.inputs = can.base.Obj(field.list, [])
|
||||
field.name = can.core.Split(field.name)[0]
|
||||
if (!field.inputs || field.inputs.length === 0) {
|
||||
return can.core.Timer(30, function() {
|
||||
can.onaction._refresh({}, can, order)
|
||||
})
|
||||
}
|
||||
can.core.List(field.inputs, function(input) {
|
||||
input.action = input.action || input.value
|
||||
input.value == ice.AUTO && (input.value = "")
|
||||
if (input.value && input.value.indexOf("@") == 0) {
|
||||
input.action = input.value.slice(1), input.value = ""
|
||||
}
|
||||
if (input.type == html.SELECT) {
|
||||
input.values = input.values || can.core.Split(input.value)
|
||||
}
|
||||
if (can.base.isIn(input.type, html.TEXT, html.TEXTAREA)) {
|
||||
input.placeholder = can.user.trans(can, input.placeholder||input.name, field, html.INPUT)
|
||||
}
|
||||
if (input.type == html.BUTTON) {
|
||||
input.value = can.user.trans(can, input.value||input.name, field)
|
||||
} else {
|
||||
if (can.db.cmd||can.db.index) { input.value = input.value||can.db[input.name] }
|
||||
}
|
||||
input.type == html.BUTTON && input.action == ice.AUTO && can.core.Timer(30, function() {
|
||||
can.onaction._refresh({}, can, order)
|
||||
})
|
||||
})
|
||||
}), can.page.setData(can), can.user.toast(can, "加载成功")
|
||||
},
|
||||
})
|
||||
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.onaction._apis = "", can.onaction._cmds = []
|
||||
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.onimport._init(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.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)
|
||||
})
|
||||
}
|
||||
},
|
||||
onaction: 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) {
|
||||
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) {
|
||||
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()
|
@ -1,44 +0,0 @@
|
||||
<import src="../../app.wxml"/>
|
||||
<view class="page action">
|
||||
<template is="action" 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">
|
||||
<view class="legend"><text>{{field.name}}({{field.help}})</text></view>
|
||||
<view class="option"> <!-- 参数 -->
|
||||
<view class="item {{item.type}}" wx:for="{{field.inputs}}" wx:key="name">
|
||||
<!-- 文本 -->
|
||||
<textarea wx:if="{{item.type == 'textarea'}}" placeholder="{{item.name}}" value="{{item.value}}"
|
||||
bindinput="onInputs" data-index="{{index}}" data-order="{{order}}"></textarea>
|
||||
<!-- 文本 -->
|
||||
<input wx:elif="{{item.type == 'text'}}" placeholder="{{item.placeholder||item.name}}" value="{{item.value}}" type="text"
|
||||
bindinput="onInputs" data-index="{{index}}" data-order="{{order}}"/>
|
||||
<!-- 列表 -->
|
||||
<picker wx:elif="{{item.type == 'select'}}" range="{{item.values}}" value="{{item.index||0}}"
|
||||
bindchange="onChange" data-index="{{index}}" data-order="{{order}}">{{item.value||item.values[item.index||0]}}</picker>
|
||||
<!-- 按钮 -->
|
||||
<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>
|
||||
</view>
|
||||
</view>
|
||||
<view class="action"> <!-- 参数 -->
|
||||
<view class="item {{item.type}}" wx:for="{{field.msg._action}}" wx:key="name">
|
||||
<!-- 按钮 -->
|
||||
<button wx:if="{{item.type == 'button'}}" size="mini"
|
||||
bindtap="onAction" data-index="{{index}}" data-order="{{order}}" data-name="{{item.name}}">{{item.value||item.name}}</button>
|
||||
</view>
|
||||
</view>
|
||||
<view class="output"> <!-- 输出 -->
|
||||
<!-- 表格 -->
|
||||
<template is="table" data="{{order: order, msg: field.msg}}"></template>
|
||||
<!-- 文本 -->
|
||||
<view class="code"><rich-text wx:for="{{field.msg.result}}" wx:key="index" nodes="{{item}}"></rich-text></view>
|
||||
</view>
|
||||
<view class="status"> <!-- 参数 -->
|
||||
<view class="item {{item.name}}" wx:for="{{field.msg._status}}" wx:key="name">
|
||||
<text class="name">{{item.name}}</text>: <text class="value">{{item.value}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
19
misc/wx/studio.go
Normal file
19
misc/wx/studio.go
Normal file
@ -0,0 +1,19 @@
|
||||
package wx
|
||||
|
||||
import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const STUDIO = "studio"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
STUDIO: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(ctx.COMMAND, kit.Split(kit.Select("web.chat.wx.access,web.chat.wx.ide,web.chat.wx.scan", mdb.Config(m, ctx.CMDS))))
|
||||
ctx.DisplayStory(m, "")
|
||||
}},
|
||||
})
|
||||
}
|
@ -5,22 +5,10 @@ refer `
|
||||
测试 https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index
|
||||
文档 https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html
|
||||
`
|
||||
qrcode `http://weixin.qq.com/r/_B1-Z7TEXOkjrfAE90jq`
|
||||
|
||||
chapter "配置"
|
||||
field web.chat.wx.access
|
||||
field web.chat.wx.menu
|
||||
field web.chat.wx.scan
|
||||
field web.chat.wx.tags
|
||||
field web.chat.wx.users
|
||||
|
||||
chapter "数据"
|
||||
field web.chat.favor
|
||||
# field web.chat.location
|
||||
|
||||
title "微信小程序"
|
||||
refer `
|
||||
官网 https://weixin.qq.com/
|
||||
后台 https://mp.weixin.qq.com/
|
||||
文档 https://developers.weixin.qq.com/miniprogram/dev/api/
|
||||
`
|
||||
qrcode `https://mp.weixin.qq.com/a/~HkylKD4DZShrgSm5GuXWLQ~~`
|
||||
|
Loading…
x
Reference in New Issue
Block a user