mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
opt frame.js
This commit is contained in:
parent
0ea50d737e
commit
e07fdd96d6
3
pane/Debug.css
Normal file
3
pane/Debug.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fieldset.Debug>div.output td {
|
||||||
|
padding:2px;
|
||||||
|
}
|
20
pane/Debug.js
Normal file
20
pane/Debug.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
|
can.require(["/plugin/github.com/Tencent/vConsole/dist/vconsole.min.js"], function(can) {
|
||||||
|
var v = new VConsole();
|
||||||
|
console.log(v);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, msg, list, cb, target) {
|
||||||
|
can.onimport._init(can, msg, list, cb, target)
|
||||||
|
can.user.log = function() {
|
||||||
|
can.page.Append(can, can._output, [{td: [
|
||||||
|
can.base.Time(),
|
||||||
|
can.base.FileLine(),
|
||||||
|
].concat(can.core.List(arguments))}])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
Volcanos("onexport", {help: "导出数据", list: []})
|
||||||
|
|
||||||
|
|
13
publish/chrome/chrome.html
Normal file
13
publish/chrome/chrome.html
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" type="text/css" href="/index.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script src="/proto.js"></script>
|
||||||
|
<script src="/chrome/chrome.js"></script>
|
||||||
|
</body>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
|
96
publish/chrome/chrome.js
Normal file
96
publish/chrome/chrome.js
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
var can = Volcanos("chrome", {
|
||||||
|
chrome: function(msg, cmd, cb) {
|
||||||
|
if (cmd.length == 0) {
|
||||||
|
// 窗口列表
|
||||||
|
chrome.windows.getAll(function(wins) {
|
||||||
|
can.core.List(wins, function(win) {win.wid = win.id
|
||||||
|
msg.Push(win, ["wid", "state", "left", "top", "width", "height"])
|
||||||
|
})
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (cmd.length == 1) {
|
||||||
|
// 标签列表
|
||||||
|
chrome.tabs.getAllInWindow(parseInt(cmd[0]), function(tabs) {
|
||||||
|
can.core.List(tabs, function(tab) {tab.tid = tab.id
|
||||||
|
msg.Push(tab, ["tid", "active", "width", "height", "index", "title", "url"])
|
||||||
|
})
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(msg._can)
|
||||||
|
delete(msg._event)
|
||||||
|
if (cmd[1] == "") {
|
||||||
|
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
|
||||||
|
cmd[1] = tabs[0].id
|
||||||
|
chrome.tabs.sendMessage(parseInt(cmd[1]), msg, function (res) {
|
||||||
|
msg.Copy(res), typeof cb == "function" && cb(msg)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
chrome.tabs.sendMessage(parseInt(cmd[1]), msg, function (res) {
|
||||||
|
msg.Copy(res), typeof cb == "function" && cb(msg)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
// 新建标签
|
||||||
|
chrome.tabs.create({windowId: parseInt(cmd[0]), url: cmd[1], selected: false}, function() {
|
||||||
|
can.chrome(msg, [cmd[0]], cb)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
bookmark: function(msg, cmd, cb) {
|
||||||
|
chrome.bookmarks.getSubTree(cmd[0]||"0", function(labs) {
|
||||||
|
for (var i = 0; i < labs.length; i++) {labs[i].pid = labs[i].parentId
|
||||||
|
msg.Push("time", can.base.Time(labs[i].dateAdded))
|
||||||
|
msg.Push(labs[i], ["pid", "id", "index", "title", "url"])
|
||||||
|
labs = labs.concat(labs[i].children||[])
|
||||||
|
}
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}, ["/lib/base", "/lib/core", "/lib/misc", "/lib/page", "/lib/user"], function(can) {can.Conf({iceberg: "http://localhost:9020/"})
|
||||||
|
can.user.toast = function(message, title) {chrome.notifications.create(null, {
|
||||||
|
message: message, title: title||"volcanos", iconUrl: "/favicon.ico", type: "basic",
|
||||||
|
})},
|
||||||
|
|
||||||
|
can.misc.WSS(can, "ws://localhost:9020/space/", {name: "chrome", type: "chrome"}, function(event, msg) {
|
||||||
|
if (msg.Option("_handle")) { return can.user.toast(msg.result.join("")) }
|
||||||
|
|
||||||
|
// can.user.toast(msg.detail.join(" "))
|
||||||
|
try {
|
||||||
|
switch (msg.detail[0]) {
|
||||||
|
case "space": can._share = msg.detail[2]; break
|
||||||
|
case "pwd": msg.Echo("hello world"); break
|
||||||
|
default: (can[msg.detail[0]]||can.chrome[msg.detail[0]])(msg, msg.detail.slice(1), function(msg) {
|
||||||
|
msg.Reply(msg)
|
||||||
|
}); return
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
can.user.toast(e)
|
||||||
|
}
|
||||||
|
msg.Reply(msg)
|
||||||
|
}, function() {can.user.toast("wss connect", "iceberg")})
|
||||||
|
|
||||||
|
can.run = function(event, cmd, cb, silent) { var msg = can.request(event)
|
||||||
|
can.misc.Run(event, can, {names: "code/chrome/crx"}, cmd, cb)
|
||||||
|
},
|
||||||
|
chrome.history.onVisited.addListener(function(item) {
|
||||||
|
can.run({}, ["history", item.id, item.title, item.url])
|
||||||
|
})
|
||||||
|
chrome.contextMenus.create({
|
||||||
|
title: "favor",
|
||||||
|
onclick: function(event) {
|
||||||
|
chrome.tabs.query({ active: true}, function (tabs) {
|
||||||
|
chrome.tabs.sendMessage(tabs[0].id, { action: "copy" }, function (response) {
|
||||||
|
console.log(response)
|
||||||
|
can.run({}, ["history", "id", response.title, response.src])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
56
publish/chrome/contexts.js
Normal file
56
publish/chrome/contexts.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
var can = Volcanos("chrome", {
|
||||||
|
spide: function(can, msg) {
|
||||||
|
can.page.Select(can, document.body, "video", function(item) {
|
||||||
|
var p = can.page.Select(can, document.body, "p.title")[0]
|
||||||
|
|
||||||
|
var ls = item.src.split("?")
|
||||||
|
var ls = ls[0].split(".")
|
||||||
|
msg.Push("time", can.base.Time())
|
||||||
|
msg.Push("type", "video")
|
||||||
|
msg.Push("name", (p && p.innerText || "video")+"."+ls[ls.length-1])
|
||||||
|
msg.Push("text", item.src)
|
||||||
|
msg.Push("link", item.src)
|
||||||
|
})
|
||||||
|
can.page.Select(can, document.body, "img", function(item) {
|
||||||
|
var ls = item.src.split("?")
|
||||||
|
var ls = ls[0].split("/")
|
||||||
|
|
||||||
|
msg.Push("time", can.base.Time())
|
||||||
|
msg.Push("type", "img")
|
||||||
|
|
||||||
|
if (item.src.startsWith("data:image")) {
|
||||||
|
msg.Push("name", item.src.slice(item.src.length-20))
|
||||||
|
} else {
|
||||||
|
msg.Push("name", ls[ls.length-1]||"image.jpg")
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.Push("text", item.src)
|
||||||
|
msg.Push("link", item.src)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}, [], function(can) {
|
||||||
|
can.user = user
|
||||||
|
can.page = page
|
||||||
|
can.misc = misc
|
||||||
|
can.core = core
|
||||||
|
can.base = base
|
||||||
|
|
||||||
|
chrome.extension.onMessage.addListener( function (msg, sender, cb) { var action = can[msg.detail[3]||"spide"]
|
||||||
|
msg = can.request({}, msg)
|
||||||
|
delete(msg._event)
|
||||||
|
delete(msg._can)
|
||||||
|
typeof action == "function" && action(can, msg) || typeof cb == "function" && cb(msg)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
|
||||||
|
chrome.extension.onMessage.addListener( function (request, sender, sendResponse) {
|
||||||
|
var title = can.page.Select(can, document.body, "p.title", function(item) {
|
||||||
|
return item.innerText
|
||||||
|
}).join("-")
|
||||||
|
can.page.Select(can, document.body, "video", function(item) {
|
||||||
|
sendResponse({poster: item.poster, src: item.src, title: title})
|
||||||
|
console.log(item)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
12
publish/chrome/popup.html
Normal file
12
publish/chrome/popup.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" type="text/css" href="/index.css">
|
||||||
|
</head>
|
||||||
|
<body style="min-width:800px; min-height:600px; overflow:auto">
|
||||||
|
<script src="/proto.js"></script>
|
||||||
|
<script src="/chrome/popup.js"></script>
|
||||||
|
</body>
|
||||||
|
<html>
|
||||||
|
|
12
publish/chrome/popup.js
Normal file
12
publish/chrome/popup.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
Volcanos({name: "demo", volcano: "/frame.js", iceberg: "http://localhost:9020/chat/", intshell: "plug.sh",
|
||||||
|
libs: ["/lib/base", "/lib/core", "/lib/misc", "/lib/page", "/lib/user"], panes: [
|
||||||
|
{name: "Header", help: "标题栏", pos: "head", state: ["time", "username"]},
|
||||||
|
{name: "River", help: "群聊组", pos: "left"},
|
||||||
|
{name: "Action", help: "工作台", pos: "middle"},
|
||||||
|
{name: "Search", help: "搜索框", pos: "float"},
|
||||||
|
{name: "Footer", help: "状态条", pos: "foot", state: ["ncmd" ]},
|
||||||
|
], main: {name: "Header", engine: "remote", list: ["/publish/order.js"]}, plugin: [
|
||||||
|
"/plugin/state.js", "/plugin/input.js", "/plugin/table.js",
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
28
publish/chrome/spided.js
Normal file
28
publish/chrome/spided.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) { can._output.innerHTML = "";
|
||||||
|
can.ui = can.page.Append(can, can._target, [
|
||||||
|
{view: ["content", "div"]}, {view: ["display", "pre"]},
|
||||||
|
])
|
||||||
|
can.onappend.table(can, msg, can.ui.content, "table")
|
||||||
|
can.onappend.board(can, msg,can.ui.display, "board")
|
||||||
|
var refresh = msg.Option("_refresh") || can.Conf("feature")["_refresh"]
|
||||||
|
refresh && can.core.Timer(refresh, function() {
|
||||||
|
can.run({})
|
||||||
|
})
|
||||||
|
return typeof cb == "function" && cb(msg)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
Volcanos("onaction", {help: "控件交互", list: [],
|
||||||
|
onclick: function(event, can) {
|
||||||
|
can.run(event, [], function() {})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
Volcanos("ondetail", {help: "控件交互", list: ["编辑", "删除"],
|
||||||
|
"编辑": function(event, can, key) {
|
||||||
|
console.log(key)
|
||||||
|
},
|
||||||
|
"删除": function(event, can, key) {
|
||||||
|
console.log(key)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
|
134
publish/client/mp/app.js
Normal file
134
publish/client/mp/app.js
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
const kit = require("utils/kit.js")
|
||||||
|
|
||||||
|
App({
|
||||||
|
// data: {}, conf: {serve: "https://shylinux.com/chat", space: "mac"},
|
||||||
|
data: {}, conf: {serve: "https://shylinux.com/chat", space: ""},
|
||||||
|
request: function(cmd, data, cb) { var app = this; data.sessid = app.conf.sessid, data.pod = app.conf.space
|
||||||
|
wx.request({method: "POST", url: app.conf.serve+"/"+cmd, data: data, success: function(res) { var msg = res.data
|
||||||
|
if (res.statusCode == 401) { return app.usercode(function() {app.request(cmd, data, cb)}) }
|
||||||
|
console.log("POST", cmd, msg)
|
||||||
|
|
||||||
|
msg.__proto__ = {
|
||||||
|
nRow: function() { return msg.append && msg.append[0] && msg[msg.append[0]].length || 0 },
|
||||||
|
Result: function() { return msg.result && msg.result.length > 0 && msg.result.join("") || "" },
|
||||||
|
Table: function(cb) { var row = 0
|
||||||
|
for (var i = 0; i < msg.append.length; i++) {
|
||||||
|
row = msg[msg.append[i]].length > row? msg[msg.append[i]].length: row
|
||||||
|
}
|
||||||
|
for (var i = 0; i < row; i++) { var line = {}
|
||||||
|
for (var k in msg.append) {
|
||||||
|
line[msg.append[k]] = msg[msg.append[k]][i]
|
||||||
|
}
|
||||||
|
typeof cb == "function" && cb(line, i, row)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
var row = 0
|
||||||
|
var index = []
|
||||||
|
if (msg.append) {
|
||||||
|
for (var i = 0; i < msg.append.length; i++) {
|
||||||
|
row = msg[msg.append[i]].length > row? msg[msg.append[i]].length: row
|
||||||
|
}
|
||||||
|
for (var i = 0; i < row; i++) {
|
||||||
|
index.push(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg._index = index
|
||||||
|
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
}})
|
||||||
|
},
|
||||||
|
download: function(cmd, data, cb) { var app = this; data.sessid = app.conf.sessid
|
||||||
|
wx.downloadFile({url: app.conf.serve+"/"+cmd, data: data, success: cb})
|
||||||
|
},
|
||||||
|
usercode: function(cb) { var app = this
|
||||||
|
wx.login({success: function(res) { app.request("mp/login/sess", {code: res.code}, function(msg) {
|
||||||
|
wx.setStorage({key: "sessid", data: msg.Result()})
|
||||||
|
app.conf.sessid = msg.Result(), typeof cb == "function" && cb()
|
||||||
|
})}})
|
||||||
|
},
|
||||||
|
userinfo: function(cb) { var app = this
|
||||||
|
if (app.conf.userInfo) {
|
||||||
|
app.request("mp/login/user", app.conf.userInfo, function(msg) {
|
||||||
|
typeof cb == "function" && cb(app.conf.userInfo)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
app.usercode(function() {
|
||||||
|
wx.getSetting({ success: function(res) { res.authSetting['scope.userInfo'] && wx.getUserInfo({success: function(res) {
|
||||||
|
app.request("mp/login/user", res.userInfo, function(msg) { app.conf.userInfo = res.userInfo
|
||||||
|
typeof cb == "function" && cb(res.userInfo)
|
||||||
|
})
|
||||||
|
}})}})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
location: function(arg) { wx.chooseLocation(arg) },
|
||||||
|
|
||||||
|
title: function(title) { wx.setNavigationBarTitle({title: title, success: function() {}})},
|
||||||
|
modal: function(title, content, cb) { wx.showModal({title: title||"", content: content||"", success: cb})},
|
||||||
|
toast: function(title, content) { wx.showToast({title: title, content: content||""})},
|
||||||
|
jumps: function(url, args, cb) { var next = "/pages/"+kit.Args(url, args)
|
||||||
|
console.log("jump", next), wx.navigateTo({url: next, success: cb})
|
||||||
|
},
|
||||||
|
scans: function(cb) { var app = this
|
||||||
|
wx.scanCode({success: function(res) { console.log("scan", res)
|
||||||
|
try {
|
||||||
|
var value = JSON.parse(res.result)
|
||||||
|
} catch(e) {
|
||||||
|
try {
|
||||||
|
var value = {"type": "url", "text": res.result}
|
||||||
|
var ls = res.result.split("?"); if (ls.length > 1) { ls = ls[1].split("&")
|
||||||
|
for (var i = 0; i < ls.length; i++) { var vs = ls[i].split("=")
|
||||||
|
value[vs[0]] = decodeURIComponent(vs[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
typeof cb == "function" && cb({type: "", text: res.result})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (value.type) {
|
||||||
|
case "share":
|
||||||
|
switch (value.name) {
|
||||||
|
case "invite":
|
||||||
|
app.userinfo(function(userInfo) {
|
||||||
|
app.modal("接受邀请", value.name, function(res) {
|
||||||
|
res.confirm && app.request("mp/login/auth", value, function(msg) {
|
||||||
|
app.toast("回执成功")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
break
|
||||||
|
|
||||||
|
case "login":
|
||||||
|
app.userinfo(function(userInfo) {
|
||||||
|
app.modal("授权登录", value.name, function(res) {
|
||||||
|
res.confirm && app.request("mp/login/auth", value, function(msg) {
|
||||||
|
app.toast("授权成功")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case "active":
|
||||||
|
app.userinfo(function(userInfo) {
|
||||||
|
app.modal("授权登录", value.name, function(res) {
|
||||||
|
res.confirm && app.request("mp/login/auth", value, function(msg) {
|
||||||
|
app.toast("授权成功")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
typeof cb == "function" && cb(value)
|
||||||
|
}
|
||||||
|
}})
|
||||||
|
},
|
||||||
|
|
||||||
|
onLaunch: function() {
|
||||||
|
this.conf.sessid = wx.getStorageSync("sessid")
|
||||||
|
console.log("load", "sessid", this.conf.sessid)
|
||||||
|
},
|
||||||
|
})
|
16
publish/client/mp/app.json
Normal file
16
publish/client/mp/app.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"pages": [
|
||||||
|
"pages/river/river",
|
||||||
|
"pages/action/action",
|
||||||
|
"pages/insert/insert"
|
||||||
|
],
|
||||||
|
"window": {
|
||||||
|
"backgroundColor": "#000",
|
||||||
|
"backgroundTextStyle": "dark",
|
||||||
|
"navigationBarBackgroundColor": "#000",
|
||||||
|
"navigationBarTitleText": "终端工具链",
|
||||||
|
"navigationBarTextStyle": "white"
|
||||||
|
},
|
||||||
|
"style": "v2",
|
||||||
|
"sitemapLocation": "sitemap.json"
|
||||||
|
}
|
13
publish/client/mp/app.wxml
Normal file
13
publish/client/mp/app.wxml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<template name="action">
|
||||||
|
<view class="action">
|
||||||
|
<view class="item" wx:for="{{action}}" wx:key="name">
|
||||||
|
<button size="mini" bindtap="onaction" data-name="{{item}}">{{item}}</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template name="list-name">
|
||||||
|
<view class="output" wx:if="{{msg.name}}">
|
||||||
|
<view class="item" wx:for="{{msg.name}}" wx:key="name" bindtap="ondetail" data-name="{{item}}" data-index="{{index}}">{{item}}</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
84
publish/client/mp/app.wxss
Normal file
84
publish/client/mp/app.wxss
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
page {
|
||||||
|
color:white;
|
||||||
|
font-size:14px;
|
||||||
|
font-family:monospace;
|
||||||
|
background-color:#272822;
|
||||||
|
white-space:pre;
|
||||||
|
}
|
||||||
|
|
||||||
|
view.action>view.item {
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
view.option>view.item {
|
||||||
|
padding:0;
|
||||||
|
border: 0;
|
||||||
|
float:left;
|
||||||
|
}
|
||||||
|
view.option input {
|
||||||
|
width:80px;
|
||||||
|
margin:2px;
|
||||||
|
padding:2px;
|
||||||
|
border:solid 1px green;
|
||||||
|
}
|
||||||
|
view.option view.textarea {
|
||||||
|
clear:both;
|
||||||
|
width:calc(100% - 2px);
|
||||||
|
border:solid 1px green;
|
||||||
|
}
|
||||||
|
view.option view.select {
|
||||||
|
border:solid 1px green;
|
||||||
|
float:left;
|
||||||
|
/* width:40px; */
|
||||||
|
padding:6px;
|
||||||
|
}
|
||||||
|
view.option view.select picker {
|
||||||
|
}
|
||||||
|
view.option view.select picker view {
|
||||||
|
}
|
||||||
|
view.output {
|
||||||
|
clear:both;
|
||||||
|
}
|
||||||
|
view.output view.item {
|
||||||
|
text-align:center;
|
||||||
|
font-size:18px;
|
||||||
|
padding:10px;
|
||||||
|
border:solid 1px green;
|
||||||
|
}
|
||||||
|
view.output view.list view.item {
|
||||||
|
background-color:darkgray;
|
||||||
|
margin-left:20px;
|
||||||
|
}
|
||||||
|
view.output view.code {
|
||||||
|
margin-left:10px;
|
||||||
|
padding:10px;
|
||||||
|
border-left:solid 2px cyan;
|
||||||
|
}
|
||||||
|
|
||||||
|
view.title {
|
||||||
|
margin-top:20px;
|
||||||
|
margin-bottom:10px;
|
||||||
|
font-weight:bold;
|
||||||
|
font-size:18px;
|
||||||
|
}
|
||||||
|
view.field {
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
}
|
||||||
|
tr {
|
||||||
|
display:flex;
|
||||||
|
justify-content:space-between;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
padding:5px;
|
||||||
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
|
border:solid 1px red;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
padding:5px;
|
||||||
|
width:100%;
|
||||||
|
text-align:center;
|
||||||
|
border:solid 1px green;
|
||||||
|
}
|
||||||
|
|
185
publish/client/mp/pages/action/action.js
Normal file
185
publish/client/mp/pages/action/action.js
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
const kit = require("../../utils/kit.js")
|
||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
action: ["扫码", "刷新", "清屏", "串行", "并行"],
|
||||||
|
river: "", storm: "", title: "",
|
||||||
|
res: [], his: {}, inputs: {},
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
"扫码": function(event, page, data, name) {
|
||||||
|
// app.jumps("scans/scans")
|
||||||
|
app.scans(function(res) {
|
||||||
|
res["sess.river"] = page.data.river
|
||||||
|
res["sess.storm"] = page.data.storm
|
||||||
|
app.request("mp/login/scan", res)
|
||||||
|
page.onaction(event, res, res.name)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
"刷新": function(event, page, data, name) {
|
||||||
|
var list = []; app.data[page.data.river+page.data.storm] = page.data.res = list
|
||||||
|
wx.showLoading()
|
||||||
|
app.request("action", {cmds: [page.data.river, page.data.storm]}, function(msg) {
|
||||||
|
wx.hideLoading()
|
||||||
|
msg.Table(function(line, index) {
|
||||||
|
line.name = line.name.split(" ")[0]
|
||||||
|
page.data.his[index] = []
|
||||||
|
line.inputs = JSON.parse(line.list)
|
||||||
|
line.feature = JSON.parse(line.meta)
|
||||||
|
if (!line.inputs || line.inputs.length === 0) {
|
||||||
|
line.inputs = [{_input: "text"}, {_input: "button", value: "执行"}]
|
||||||
|
}
|
||||||
|
list.push(line), line.inputs.forEach(function(input) {
|
||||||
|
input.action = input.action || input.value
|
||||||
|
input.value == "auto" && (input.value = "")
|
||||||
|
input.value = input.value || kit.Value(line, "feature.trans."+input.name)
|
||||||
|
if (input.value && input.value.startsWith("@")) {
|
||||||
|
input.value = ""
|
||||||
|
}
|
||||||
|
if (input._input == "select") {
|
||||||
|
input.values = input.values || input.value && input.value.split("|")
|
||||||
|
}
|
||||||
|
input._input == "button" && input.action == "auto" && page.run(event, index)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
page.setData({res: list})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
"串行": function(event, page, data, name) {
|
||||||
|
function cb(i) {
|
||||||
|
page.run(event, i, null, function() {i < page.data.res.length - 1&& cb(i+1)})
|
||||||
|
}
|
||||||
|
cb(0)
|
||||||
|
},
|
||||||
|
"并行": function(event, page, data, name) {
|
||||||
|
kit.List(page.data.res, function(field, index) {
|
||||||
|
page.run(event, index)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
"清屏": function(event, page, data, name) {
|
||||||
|
kit.List(page.data.res, function(field, index) {
|
||||||
|
delete(field.msg)
|
||||||
|
})
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onaction: function(event, data, name) {
|
||||||
|
data = data || event.target.dataset, name = name || data.name
|
||||||
|
console.log("action", "action", name)
|
||||||
|
this.action[name](event, this, data)
|
||||||
|
},
|
||||||
|
|
||||||
|
run: function(event, order, cmd, cb) {var page = this, field = page.data.res[order]
|
||||||
|
var cmds = [page.data.river, page.data.storm, field.id || field.key]
|
||||||
|
cmds = cmds.concat(cmd||kit.List(field.inputs, function(input) {
|
||||||
|
if (["text", "textarea", "select"].indexOf(input._input) > -1) {
|
||||||
|
return input.value || ""
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
for (var i = cmds.length-1; i > 0; i--) {
|
||||||
|
if (cmds[i] === "") {cmds.pop()} else {break}
|
||||||
|
}
|
||||||
|
|
||||||
|
wx.showLoading()
|
||||||
|
app.request("action?="+field.name, {cmds: cmds}, function(msg) {
|
||||||
|
wx.hideLoading()
|
||||||
|
page.data.res[order].msg = msg
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
onBlur: function(event) {var page = this, data = event.target.dataset
|
||||||
|
},
|
||||||
|
onFocus: function(event) {},
|
||||||
|
onInput: function(event) {var page = this, data = event.target.dataset
|
||||||
|
page.data.res[data.order].inputs[data.index].value = event.detail.value
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
},
|
||||||
|
onChange: function(event) {var page = this, data = event.target.dataset
|
||||||
|
page.data.res[data.order].inputs[data.index].index = parseInt(event.detail.value)
|
||||||
|
page.data.res[data.order].inputs[data.index].value = data.input.values[parseInt(event.detail.value)]
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
},
|
||||||
|
onEnter: function(event) {var page = this, data = event.target.dataset
|
||||||
|
page.data.res[data.order].inputs[data.index].value = event.detail.value
|
||||||
|
},
|
||||||
|
|
||||||
|
onClick: function(event) {var page = this, data = event.target.dataset
|
||||||
|
var field = page.data.res[data.order]
|
||||||
|
|
||||||
|
if (field.feature[data.input.name]) {
|
||||||
|
app.data.insert = {
|
||||||
|
field: field, input: data.input,
|
||||||
|
data: {}, list: field.feature[data.input.name], cb: function(res) {
|
||||||
|
var list = ["action", data.input.name]
|
||||||
|
kit.Item(res, function(key, value) {
|
||||||
|
key && value && list.push(key, value)
|
||||||
|
})
|
||||||
|
page.run(event, data.order, list)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
app.jumps("insert/insert", {river: page.data.river, storm: page.data.storm, title: field.name})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (data.input.name) {
|
||||||
|
case "返回":
|
||||||
|
// 恢复命令
|
||||||
|
page.data.his[data.order].pop()
|
||||||
|
var line = page.data.his[data.order].pop()
|
||||||
|
kit.List(field.inputs, function(input, index) {
|
||||||
|
input.value = line && line[index] || ""
|
||||||
|
})
|
||||||
|
default:
|
||||||
|
// 执行命令
|
||||||
|
page.data.his[data.order].push(kit.List(field.inputs, function(input) {
|
||||||
|
return input.value
|
||||||
|
})) && page.run(event, data.order)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onWhich: function(event) {var page = this, data = event.target.dataset
|
||||||
|
var field = page.data.res[data.order]
|
||||||
|
field.inputs.forEach(function(input, index) {
|
||||||
|
if (input.name == data.field) {
|
||||||
|
// 导入参数
|
||||||
|
page.data.res[data.order].inputs[index].value = data.value
|
||||||
|
page.setData({res: page.data.res})
|
||||||
|
// 执行命令
|
||||||
|
input.action == "auto" && page.data.his[data.order].push(kit.List(field.inputs, function(input) {
|
||||||
|
return input.value
|
||||||
|
})) && page.run(event, data.order)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad: function (options) {
|
||||||
|
console.log("page", "action", options)
|
||||||
|
app.conf.sessid = options.sessid || app.conf.sessid
|
||||||
|
this.data.river = options.river
|
||||||
|
this.data.storm = options.storm
|
||||||
|
this.data.title = options.title
|
||||||
|
app.title(options.title)
|
||||||
|
|
||||||
|
var data = app.data[options.river+options.storm]
|
||||||
|
if (data) { return this.setData({res: this.data.res = data}) }
|
||||||
|
this.onaction({}, {}, "刷新")
|
||||||
|
},
|
||||||
|
onReady: function () {},
|
||||||
|
onShow: function () {},
|
||||||
|
onHide: function () {},
|
||||||
|
onUnload: function () {},
|
||||||
|
onPullDownRefresh: function () {
|
||||||
|
this.onaction({}, {}, "刷新")
|
||||||
|
},
|
||||||
|
onReachBottom: function () {},
|
||||||
|
onShareAppMessage: function (res) {
|
||||||
|
console.log("action", "share", res)
|
||||||
|
return {
|
||||||
|
title: this.data.title,
|
||||||
|
path: "pages/action/action?river="+this.data.river+"&storm="+this.data.storm+"&title="+this.data.title,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
3
publish/client/mp/pages/action/action.json
Normal file
3
publish/client/mp/pages/action/action.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
45
publish/client/mp/pages/action/action.wxml
Normal file
45
publish/client/mp/pages/action/action.wxml
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<import src="../../app.wxml"/>
|
||||||
|
|
||||||
|
<template is="action" data="{{action}}"></template>
|
||||||
|
|
||||||
|
<view class="output">
|
||||||
|
<view class="field" wx:for="{{res}}" wx:key="name" wx:for-index="order" wx:for-item="field">
|
||||||
|
<view class="title"><text>{{field.name}}({{field.help}})</text></view>
|
||||||
|
<view class="option">
|
||||||
|
<!-- 参数 -->
|
||||||
|
<view class="item {{item._input}}" wx:for="{{field.inputs}}" wx:key="name">
|
||||||
|
<!-- 文本 -->
|
||||||
|
<input wx:if="{{item._input == 'text'}}" type="text" value="{{item.value}}" placeholder="{{item.name}}"
|
||||||
|
bindtap="onClick" bindinput="onInput" bindconfirm="onEnter" data-order="{{order}}" data-index="{{index}}" data-input="{{item}}"/>
|
||||||
|
|
||||||
|
<!-- 文本 -->
|
||||||
|
<textarea wx:elif="{{item._input == 'textarea'}}" value="{{item.value}}" placeholder="{{item.name}}"
|
||||||
|
bindtap="onClick" bindinput="onInput" data-field="{{field}}" data-order="{{order}}" data-index="{{index}}" data-input="{{item}}"></textarea>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<picker wx:elif="{{item._input == 'select'}}" bindchange="onChange" value="{{item.index||0}}" range="{{item.values}}"
|
||||||
|
data-field="{{field}}" data-order="{{order}}" data-index="{{index}}" data-input="{{item}}">
|
||||||
|
<view>{{item.values[item.index||0]}}</view>
|
||||||
|
</picker>
|
||||||
|
|
||||||
|
<!-- 按钮 -->
|
||||||
|
<button wx:elif="{{item._input == 'button'}}" size="mini" bindtap="onClick" data-field="{{field}}" data-order="{{order}}" data-index="{{index}}" data-input="{{item}}">{{item.value||item.name}}</button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 输出 -->
|
||||||
|
<view class="output">
|
||||||
|
<!-- 表格 -->
|
||||||
|
<table wx:if="{{field.msg}}">
|
||||||
|
<tr><th wx:for="{{field.msg.append}}" wx:key="name">{{item}}</th></tr>
|
||||||
|
<tr wx:for="{{field.msg._index}}" wx:key="name" wx:for-index="line">
|
||||||
|
<td wx:for="{{field.msg.append}}" bindtap="onWhich" data-value="{{field.msg[item][line]}}" data-index="{{line}}" data-field="{{item}}" data-order="{{order}}">{{field.msg[item][line]}}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- 文本 -->
|
||||||
|
<view class="output"><rich-text wx:for="{{field.msg.result}}" wx:key="name" nodes="{{item}}"></rich-text></view>
|
||||||
|
<!-- <view class="code" wx:elif="{{field.msg.result}}"><text wx:for="{{field.msg.result}}" wx:key="name">{{item}}</text></view> -->
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
6
publish/client/mp/pages/action/action.wxss
Normal file
6
publish/client/mp/pages/action/action.wxss
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
view.option view.item {
|
||||||
|
padding:0;
|
||||||
|
}
|
||||||
|
view.option view.item.select {
|
||||||
|
padding:3px;
|
||||||
|
}
|
80
publish/client/mp/pages/insert/insert.js
Normal file
80
publish/client/mp/pages/insert/insert.js
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
const kit = require("../../utils/kit.js")
|
||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
action: ["扫码"],
|
||||||
|
field: {},
|
||||||
|
insert: [],
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
"扫码": function(event, page, data, name) {
|
||||||
|
app.scans(function(res) {
|
||||||
|
res["sess.river"] = page.data.river
|
||||||
|
res["sess.storm"] = page.data.storm
|
||||||
|
app.request("mp/login/scan", res)
|
||||||
|
page.onaction(event, res, res.name)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onaction: function(event, data, name) {
|
||||||
|
data = data || event.target.dataset, name = name || data.name
|
||||||
|
console.log("action", "action", name)
|
||||||
|
this.action[name](event, this, data)
|
||||||
|
},
|
||||||
|
|
||||||
|
onInput: function(event) {var page = this, data = event.target.dataset
|
||||||
|
app.data.insert[data.index].value = event.detail.value
|
||||||
|
},
|
||||||
|
onFocus: function(event) {},
|
||||||
|
onConfirm: function (event) { var page = this
|
||||||
|
kit.List(page.data.insert, function(item) {
|
||||||
|
app.data.insert.data[item.name] = item.value
|
||||||
|
})
|
||||||
|
app.data.insert.cb(app.data.insert.data)
|
||||||
|
wx.navigateBack()
|
||||||
|
},
|
||||||
|
onLoad: function (options) {
|
||||||
|
this.data.insert = app.data.insert.list
|
||||||
|
|
||||||
|
var p = app.data.insert.input.action
|
||||||
|
if (p.startsWith("@")) {
|
||||||
|
var cb = this.plugin[p.slice(1,-1)]; cb && cb(this)
|
||||||
|
}
|
||||||
|
var cb = this.plugin[p]; cb && cb(this)
|
||||||
|
kit.List(app.data.insert.list, function(item) {
|
||||||
|
item.action = item.action || item.value
|
||||||
|
item.value && item.value.startsWith("@") && (item.value = "")
|
||||||
|
app.data.insert.data[item.name] = item.value
|
||||||
|
})
|
||||||
|
console.log("page", "insert", options)
|
||||||
|
app.title(options.title)
|
||||||
|
this.setData(this.data)
|
||||||
|
},
|
||||||
|
onReady: function () {},
|
||||||
|
onShow: function () {},
|
||||||
|
onHide: function () {},
|
||||||
|
onUnload: function () {},
|
||||||
|
onPullDownRefresh: function () {},
|
||||||
|
onReachBottom: function () {},
|
||||||
|
|
||||||
|
plugin: {
|
||||||
|
getLocation: function(page, data) { app.location({success: function(res) {
|
||||||
|
res.latitude = parseInt(res.latitude * 100000)
|
||||||
|
res.longitude = parseInt(res.longitude * 100000)
|
||||||
|
kit.List(page.data.insert, function(item) {
|
||||||
|
res[item.name] && (item.value = res[item.name])
|
||||||
|
}), page.setData(page.data)
|
||||||
|
}}) },
|
||||||
|
scanQRCode: function(page) { app.scans(function(res) {
|
||||||
|
kit.List(page.data.insert, function(item) {
|
||||||
|
res[item.name] && (item.value = res[item.name])
|
||||||
|
}), page.setData(page.data)
|
||||||
|
}) },
|
||||||
|
paste: function(page, data) { wx.getClipboardData({success: function(res) {
|
||||||
|
kit.List(page.data.insert, function(item) {
|
||||||
|
res[item.name] && (item.value = res[item.name])
|
||||||
|
}), page.setData(page.data)
|
||||||
|
}}) },
|
||||||
|
},
|
||||||
|
})
|
3
publish/client/mp/pages/insert/insert.json
Normal file
3
publish/client/mp/pages/insert/insert.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
26
publish/client/mp/pages/insert/insert.wxml
Normal file
26
publish/client/mp/pages/insert/insert.wxml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<import src="../../app.wxml"/>
|
||||||
|
<template is="action" data="{{action}}"></template>
|
||||||
|
|
||||||
|
<view class="output">
|
||||||
|
<view class="item" wx:for="{{insert}}" wx:key="name">
|
||||||
|
<!-- 文本 -->
|
||||||
|
<input wx:if="{{item._input == 'text'}}" type="text" value="{{item.value}}" placeholder="{{item.name}}"
|
||||||
|
bindtap="onClick" bindinput="onInput" bindconfirm="onEnter" data-index="{{index}}" data-input="{{item}}"/>
|
||||||
|
|
||||||
|
<!-- 文本 -->
|
||||||
|
<textarea wx:elif="{{item._input == 'textarea'}}" value="{{item.value}}" placeholder="{{item.name}}"
|
||||||
|
bindtap="onClick" bindinput="onInput" data-index="{{index}}" data-input="{{item}}"></textarea>
|
||||||
|
|
||||||
|
<!-- 列表 -->
|
||||||
|
<picker wx:elif="{{item._input == 'select'}}" bindchange="onChange" value="{{item.index||0}}" range="{{item.values}}"
|
||||||
|
data-index="{{index}}" data-input="{{item}}">
|
||||||
|
<view>{{item.values[item.index||0]}}</view>
|
||||||
|
</picker>
|
||||||
|
|
||||||
|
<!-- 按钮 -->
|
||||||
|
<button wx:elif="{{item._input == 'button'}}" size="mini" bindtap="onClick" data-index="{{index}}" data-input="{{item}}">{{item.name||item.value}}</button>
|
||||||
|
</view>
|
||||||
|
<button bindtap="onConfirm">提交</button>
|
||||||
|
<button bindtap="onCancel">取消</button>
|
||||||
|
</view>
|
||||||
|
|
1
publish/client/mp/pages/insert/insert.wxss
Normal file
1
publish/client/mp/pages/insert/insert.wxss
Normal file
@ -0,0 +1 @@
|
|||||||
|
/* pages/insert/insert.wxss */
|
84
publish/client/mp/pages/river/river.js
Normal file
84
publish/client/mp/pages/river/river.js
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
const kit = require("../../utils/kit.js")
|
||||||
|
const app = getApp()
|
||||||
|
|
||||||
|
Page({
|
||||||
|
data: {
|
||||||
|
action: ["扫码", "刷新", "登录"],
|
||||||
|
river: {},
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
"扫码": function(event, page, data) { app.scans(function(res) {
|
||||||
|
switch (res.type) {
|
||||||
|
case "url":
|
||||||
|
app.request("mp/login/scan", res, function(msg) {
|
||||||
|
page.onaction({}, {}, "刷新")
|
||||||
|
})
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
res.name && page.onaction(event, res, res.name)
|
||||||
|
}
|
||||||
|
}) },
|
||||||
|
"刷新": function(event, page, data) {
|
||||||
|
wx.showLoading()
|
||||||
|
app.request("river", {}, function(msg) {
|
||||||
|
wx.hideLoading()
|
||||||
|
var river = {}; msg.Table(function(value) {
|
||||||
|
river[value.hash] = value
|
||||||
|
})
|
||||||
|
page.setData({river: river})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
"登录": function(event, page, data) { app.conf.sessid = "",
|
||||||
|
app.userinfo(function(res) {
|
||||||
|
page.onaction(event, data, "刷新")
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
onaction: function(event, data, name) {
|
||||||
|
data = data || event.target.dataset, name = name || data.name
|
||||||
|
console.log("action", "river", name)
|
||||||
|
this.action[name](event, this, data)
|
||||||
|
},
|
||||||
|
ondetail: function(event, data) { var page = this
|
||||||
|
data = data || event.target.dataset.item
|
||||||
|
console.log("detail", "river", data)
|
||||||
|
|
||||||
|
var river = page.data.river[data.hash]
|
||||||
|
if (river.tool) {
|
||||||
|
river.hidetool = !river.hidetool
|
||||||
|
page.setData({river: page.data.river})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
wx.showLoading()
|
||||||
|
app.request("river", {cmds: [data.hash, "tool"]}, function(msg) {
|
||||||
|
wx.hideLoading()
|
||||||
|
river.tool = {}; msg.Table(function(value) {
|
||||||
|
river.tool[value.hash] = value
|
||||||
|
value.river = data
|
||||||
|
})
|
||||||
|
page.setData({river: page.data.river})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onchange: function(event, data) { var page = this
|
||||||
|
data = data || event.target.dataset.item
|
||||||
|
app.jumps("action/action", {river: data.river.hash, storm: data.hash, title: data.river.name+"."+data.name})
|
||||||
|
},
|
||||||
|
|
||||||
|
onLoad: function (options) { var page = this
|
||||||
|
console.log("page", "river", options)
|
||||||
|
app.conf.sessid = options.sessid || app.conf.sessid
|
||||||
|
app.usercode(function() {
|
||||||
|
page.onaction({}, options, "刷新")
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onReady: function () {},
|
||||||
|
onShow: function () {},
|
||||||
|
onHide: function () {},
|
||||||
|
onUnload: function () {},
|
||||||
|
onPullDownRefresh: function () {
|
||||||
|
this.onaction({}, {}, "刷新")
|
||||||
|
},
|
||||||
|
onReachBottom: function () {},
|
||||||
|
onShareAppMessage: function () {}
|
||||||
|
})
|
3
publish/client/mp/pages/river/river.json
Normal file
3
publish/client/mp/pages/river/river.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
12
publish/client/mp/pages/river/river.wxml
Normal file
12
publish/client/mp/pages/river/river.wxml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<import src="../../app.wxml"/>
|
||||||
|
|
||||||
|
<template is="action" data="{{action}}"></template>
|
||||||
|
|
||||||
|
<view class="output">
|
||||||
|
<view class="item" wx:for="{{river}}" wx:key="name">
|
||||||
|
<view class="item" bindtap="ondetail" data-item="{{item}}">{{item.name}}</view>
|
||||||
|
<view class="list" wx:if="{{!item.hidetool}}">
|
||||||
|
<view class="item" bindtap="onchange" wx:for="{{item.tool}}" wx:key="name" data-item="{{item}}">{{item.name}}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
0
publish/client/mp/pages/river/river.wxss
Normal file
0
publish/client/mp/pages/river/river.wxss
Normal file
4
publish/client/mp/plugin/story/paste.js
Normal file
4
publish/client/mp/plugin/story/paste.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
module.exports = {
|
||||||
|
onimport: function() {},
|
||||||
|
}
|
1
publish/client/mp/plugin/story/paste.wxml
Normal file
1
publish/client/mp/plugin/story/paste.wxml
Normal file
@ -0,0 +1 @@
|
|||||||
|
hello wrold
|
89
publish/client/mp/project.config.json
Normal file
89
publish/client/mp/project.config.json
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
{
|
||||||
|
"description": "项目配置文件",
|
||||||
|
"packOptions": {
|
||||||
|
"ignore": []
|
||||||
|
},
|
||||||
|
"setting": {
|
||||||
|
"urlCheck": true,
|
||||||
|
"es6": true,
|
||||||
|
"postcss": true,
|
||||||
|
"minified": true,
|
||||||
|
"newFeature": true,
|
||||||
|
"autoAudits": false,
|
||||||
|
"coverView": true,
|
||||||
|
"showShadowRootInWxmlPanel": true,
|
||||||
|
"scopeDataCheck": false
|
||||||
|
},
|
||||||
|
"compileType": "miniprogram",
|
||||||
|
"libVersion": "2.0.4",
|
||||||
|
"appid": "wxf4e5104d83476ed6",
|
||||||
|
"projectname": "%E7%BB%88%E7%AB%AF%E5%B7%A5%E5%85%B7%E9%93%BE",
|
||||||
|
"debugOptions": {
|
||||||
|
"hidedInDevtools": []
|
||||||
|
},
|
||||||
|
"isGameTourist": false,
|
||||||
|
"simulatorType": "wechat",
|
||||||
|
"simulatorPluginLibVersion": {},
|
||||||
|
"condition": {
|
||||||
|
"search": {
|
||||||
|
"current": -1,
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"conversation": {
|
||||||
|
"current": -1,
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"plugin": {
|
||||||
|
"current": -1,
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"game": {
|
||||||
|
"currentL": -1,
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"gamePlugin": {
|
||||||
|
"current": -1,
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"miniprogram": {
|
||||||
|
"current": -1,
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"id": 0,
|
||||||
|
"name": "pages/action/action",
|
||||||
|
"pathName": "pages/action/action",
|
||||||
|
"query": "river=c796cd&storm=9092d5",
|
||||||
|
"scene": 1008
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"name": "action",
|
||||||
|
"pathName": "pages/action/action",
|
||||||
|
"query": "river=d022b3&storm= c22d21",
|
||||||
|
"scene": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"name": "pages/river/river",
|
||||||
|
"pathName": "pages/river/river",
|
||||||
|
"query": "river=c796cd&storm=9092d5",
|
||||||
|
"scene": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": -1,
|
||||||
|
"name": "pages/scans/scans",
|
||||||
|
"pathName": "pages/scans/scans",
|
||||||
|
"query": "river=c796cd&storm=9092d5",
|
||||||
|
"scene": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4,
|
||||||
|
"name": "pages/action/action",
|
||||||
|
"pathName": "pages/action/action",
|
||||||
|
"query": "river=d82c1d&storm=12d1d7&title=mac.paste",
|
||||||
|
"scene": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
publish/client/mp/sitemap.json
Normal file
7
publish/client/mp/sitemap.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||||
|
"rules": [{
|
||||||
|
"action": "allow",
|
||||||
|
"page": "*"
|
||||||
|
}]
|
||||||
|
}
|
42
publish/client/mp/utils/kit.js
Normal file
42
publish/client/mp/utils/kit.js
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
module.exports = {
|
||||||
|
Number: function(d, n) {var res = [];
|
||||||
|
while (d > 0) {res.push(d % 10); d = parseInt(d / 10); n--}
|
||||||
|
while (n > 0) {res.push("0"); n--}
|
||||||
|
return res.reverse(), res.join("");
|
||||||
|
},
|
||||||
|
Time: function(t, fmt) {var now = t? new Date(t): new Date();
|
||||||
|
fmt = fmt || "%y-%m-%d %H:%M:%S";
|
||||||
|
fmt = fmt.replace("%y", now.getFullYear())
|
||||||
|
fmt = fmt.replace("%m", Number(now.getMonth()+1, 2))
|
||||||
|
fmt = fmt.replace("%d", Number(now.getDate(), 2))
|
||||||
|
fmt = fmt.replace("%H", Number(now.getHours(), 2))
|
||||||
|
fmt = fmt.replace("%M", Number(now.getMinutes(), 2))
|
||||||
|
fmt = fmt.replace("%S", Number(now.getSeconds(), 2))
|
||||||
|
return fmt
|
||||||
|
},
|
||||||
|
Args: function(url, args) {var list = []
|
||||||
|
for (var k in args) {
|
||||||
|
list.push(encodeURIComponent(k)+"="+encodeURIComponent(args[k]))
|
||||||
|
}
|
||||||
|
return url+"?"+list.join("&")
|
||||||
|
},
|
||||||
|
List: function(list, cb, cbs) {var res = [], val;
|
||||||
|
for (var i = 0; i < list.length; i++) {
|
||||||
|
typeof cb == "function"? (val = cb(list[i], i, list)) != undefined && res.push(val): res.push(list[i])
|
||||||
|
}
|
||||||
|
return typeof cbs == "function" && cbs(res), res
|
||||||
|
},
|
||||||
|
Item: function(list, cb, cbs) {
|
||||||
|
for (var k in list) {
|
||||||
|
cb(k, list[k])
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Value: function(item, key) {
|
||||||
|
var p = item, ls = key.split(".")
|
||||||
|
while (p && ls.length > 0) {
|
||||||
|
p = p[ls[0]], ls = ls.slice(1)
|
||||||
|
}
|
||||||
|
return p
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
50
publish/client/mp/utils/util.js
Normal file
50
publish/client/mp/utils/util.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
const formatTime = date => {
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = date.getMonth() + 1
|
||||||
|
const day = date.getDate()
|
||||||
|
const hour = date.getHours()
|
||||||
|
const minute = date.getMinutes()
|
||||||
|
const second = date.getSeconds()
|
||||||
|
|
||||||
|
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
||||||
|
}
|
||||||
|
|
||||||
|
const formatNumber = n => {
|
||||||
|
n = n.toString()
|
||||||
|
return n[1] ? n : '0' + n
|
||||||
|
}
|
||||||
|
function Number(d, n) {var res = [];
|
||||||
|
while (d > 0) {res.push(d % 10); d = parseInt(d / 10); n--}
|
||||||
|
while (n > 0) {res.push("0"); n--}
|
||||||
|
return res.reverse(), res.join("");
|
||||||
|
}
|
||||||
|
function Time(t, fmt) {var now = t? new Date(t): new Date();
|
||||||
|
fmt = fmt || "%y-%m-%d %H:%M:%S";
|
||||||
|
fmt = fmt.replace("%y", now.getFullYear())
|
||||||
|
fmt = fmt.replace("%m", Number(now.getMonth()+1, 2))
|
||||||
|
fmt = fmt.replace("%d", Number(now.getDate(), 2))
|
||||||
|
fmt = fmt.replace("%H", Number(now.getHours(), 2))
|
||||||
|
fmt = fmt.replace("%M", Number(now.getMinutes(), 2))
|
||||||
|
fmt = fmt.replace("%S", Number(now.getSeconds(), 2))
|
||||||
|
return fmt
|
||||||
|
}
|
||||||
|
function Args(url, args) {var list = []
|
||||||
|
for (var k in args) {
|
||||||
|
list.push(encodeURIComponent(k)+"="+encodeURIComponent(args[k]))
|
||||||
|
}
|
||||||
|
return url+"?"+list.join("&")
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
formatTime: formatTime,
|
||||||
|
Time: Time,
|
||||||
|
Args: Args,
|
||||||
|
List: function(list, cb) {
|
||||||
|
var res = [], val;
|
||||||
|
for (var i = 0; i < list.length; i++) {
|
||||||
|
typeof cb == "function"? (val = cb(list[i], i, list)) != undefined && res.push(val): res.push(list[i])
|
||||||
|
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
},
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user