1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
shaoying 2020-06-24 10:05:03 +08:00
parent 8aed020f1b
commit 00636dc611
10 changed files with 86 additions and 46 deletions

View File

@ -130,7 +130,7 @@ var can = Volcanos("chrome", {
chrome.history.onVisited.addListener(function(item) {
can.run({}, ["history", item.id, item.title, item.url], function(msg) {
can.user.toast(item.url, item.title)
// can.user.toast(item.url, item.title)
})
})

View File

@ -6,7 +6,7 @@
</head>
<body style="min-width:800px; min-height:600px">
<script src="/proto.js"></script>
<script src="/plugin/chrome/popup.js"></script>
<script src="/chrome/popup.js"></script>
</body>
<html>

View File

@ -1,7 +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: [
{type: "pane", name: "Action", help: "工作台", pos: "middle", list: ["/pane/Action.js", "/pane/Action.css"]},
], main: {name: "Action", engine: "remote", list: ["/publish/order.js"]}, plugin: [
{name: "Header", help: "标题栏", pos: "head", state: ["time", "username"]},
{name: "River", help: "群聊组", pos: "left"},
{name: "Storm", help: "应用流", pos: "right"},
{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",
],
})

View File

@ -68,7 +68,7 @@ Volcanos("onengine", { _init: function(can, meta, list, cb, target) {
typeof cb == "function" && cb(msg)
return true
case "Action":
var river = can.onengine.river[cmds[0]]
var river = can.onengine.river[cmds[0]||"main"]
var storm = river && river.storm[cmds[1]]
var action = storm && storm.action && storm.action[cmds[2]]
if (!storm) { break } if (cmds.length == 2) {
@ -261,6 +261,9 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met
})
var args = {}; can.core.List(msg.option, function(key) { args[key] = msg.Option(key) })
// can.core.Item(can.Option(), function(key, value) { args[key] = value })
//
can.user.locals(can, args)
location.href = can.user.Share(can, args, true)
})
},

View File

@ -5,7 +5,7 @@ var base = Volcanos("base", {help: "基础模块",
Ext: function(file) { return (file.split("/").pop().split(".").pop()||"txt").toLowerCase() },
Path: function() {var res = ""
for (var i = 0; i < arguments.length; i++) {
res += (arguments[i].indexOf("/") == 0 || res.endsWith("/")? "": "/") + arguments[i]
res += (arguments[i].indexOf("/") == 0 || res.endsWith("/")? "": "/") + arguments[i].trim()
}
return res
},

View File

@ -72,6 +72,9 @@ var misc = Volcanos("misc", {help: "工具模块",
if (url.indexOf("ws") == -1) {
url = location.protocol.replace("http", "ws")+"//"+location.host+"/space/" + (url||"")
}
if (url.indexOf("chrome") == 0) {
url = "ws://localhost:9020/space/"
}
if (can._socket) {return can._socket}
args["share"] = can._share || ""

View File

@ -68,7 +68,7 @@ var user = Volcanos("user", {help: "用户模块",
return args
} else if (value == undefined) {
// return args[key] || can.user.Cookie(can, key)
return args[key]
return args[key]||can.user.locals(can, key)
} else {
args[key] = value
args[key] == "" && delete(args[key])
@ -107,5 +107,19 @@ var user = Volcanos("user", {help: "用户模块",
isIPhone: navigator.userAgent.indexOf("iPhone") > -1,
isMacOSX: navigator.userAgent.indexOf("Mac OS X") > -1,
isWindows: navigator.userAgent.indexOf("Windows") > -1,
locals: function(can, key, value) {
if (typeof key == "object") {
can.core.Item(key, function(key, value) {
localStorage.setItem(key, value)
})
return key
}
if (value != undefined) {
localStorage.setItem(key, value)
}
if (key != undefined) {
return localStorage.getItem(key)
}
},
})

View File

@ -91,7 +91,12 @@ Volcanos("onexport", {help: "导出数据", list: [], _init: function(can, msg,
})
},
}]}
})); ui.River.click(), ui.Footer.click(), ui.Storm.click()
}));
if (location.protocol == "chrome-extension:") {
ui.River.click()
} else {
ui.River.click(), ui.Footer.click(), ui.Storm.click()
}
typeof cb == "function" && cb()
})

View File

@ -5,7 +5,11 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can.table = can.onappend.table(can, can.ui.content, "table", msg, function(value, key, index, line) {
return {text: [value, "td"], onclick: function(event) {
if (line.path.endsWith("/")) {
can.run(event, [can.Option("path", line.path)])
} else {
can.onimport.file(can, line.path)
}
}}
})
@ -39,12 +43,15 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can.rate = can.ctrl.rate.value = 1
limit = can.ctrl.limit.value = parseInt(msg.Option("limit"))||1
can.height = can.ctrl.height.value = parseInt(msg.Option("height"))||400
can.onimport.page(can, list, begin, limit)
can.Option("path") != "最近/" && can.onimport.page(can, list, begin, limit)
},
page: function(can, list, begin, limit) { can.ui.display.innerHTML = ""
for (var i = begin; i < begin+limit; i++) { can.onimport.file(can, list[i].path) }
for (var i = begin; i < begin+limit; i++) { list[i] && can.onimport.file(can, list[i].path) }
},
file: function(can, item) { item = (can._msg.Option("prefix")||"")+"/"+item
file: function(can, item) {
var p = location.href.startsWith("http")? "": "http://localhost:9020"
item = item.startsWith("http")? item: p+can.base.Path("/share/local", " "+(can._msg.Option("prefix")||""), item)
var ls = item.split("/")
var ls = ls[ls.length-1].split(".")
var ext = ls[ls.length-1].toLowerCase()
@ -53,16 +60,15 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
}, ["/plugin/local/wiki/feel.css"])
Volcanos("onfigure", {help: "组件菜单", list: [],
image: function(can, path) {
return {img: "/share/local/"+path, height: can.height}
return {img: path, height: can.height}
},
jpg: function(can, path) { return can.onfigure.image(can, path) },
qrc: function(can, path) { return can.onfigure.image(can, path) },
video: function(can, path) { var auto = true, loop = true, total = 0
var p = location.href.startsWith("https")? "": "http://localhost:9020"
function cb(event) { console.log(event) }
return {className: "preview", type: "video", style: {height: can.height},
data: {src: p+"/share/local/"+path, controls: "controls", autoplay: auto, loop: loop, playbackRate: can.rate},
data: {src: path, controls: "controls", autoplay: auto, loop: loop, playbackRate: can.rate},
oncontextmenu: cb, onplay: cb, onpause: cb, onended: cb,
onloadedmetadata: function(event) { total = event.timeStamp
event.target.currentTime = can._msg.currentTime || 0
@ -72,10 +78,22 @@ Volcanos("onfigure", {help: "组件菜单", list: [],
}
},
m4v: function(can, path) { return can.onfigure.video(can, path) },
mp4: function(can, path) { return can.onfigure.video(can, path) },
})
Volcanos("onaction", {help: "组件菜单", list: ["", "上传"],
Volcanos("onaction", {help: "组件菜单", list: ["", "上传", "收藏"],
"上传": function(event, can) { can.onappend.upload(can) },
"收藏": function(event, can) {
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(tabs[0].id, { action: "copy" }, function (response) {
can.onimport.file(can, response.src)
var msg = can.request(event); msg.Option(can.Option())
can.run(event, ["action", "spide", "mp4", response.title, response.src, "poster", response.poster], function(msg) {
}, true)
})
})
},
})
Volcanos("onexport", {help: "导出数据", list: ["当前行"],
position: function(can, index, total) { total = total || can.max

View File

@ -1,38 +1,30 @@
Volcanos("onengine", { river: {
"main": {name: "main", storm: {
"main": {name: "main", action: [
{name: "IDE", help: "集成开发环境", inputs: [
{type: "text", name: "path", value: "tmp", action: "auto"},
{type: "text", name: "name", value: "hi.qrc", action: "auto"},
{type: "text", name: "key", value: "", action: "auto"},
{type: "button", name: "打开", action: "auto"},
{type: "button", name: "返回"},
{type: "button", name: "提交"},
{type: "button", name: "历史"},
], index: "web.wiki.inner", feature: {display: "/plugin/inner.js", style: "editor"}},
"main": {name: "main", index: [
"web.code.inner",
"web.code.git.status",
"web.code.git.total",
]},
"word": {name: "word", action: [
{name: "trans", help: "词汇", inputs: [
{type: "text", name: "word", value: "miss"},
{type: "text", name: "method", value: ""},
{type: "button", name: "翻译"},
], group: "web.wiki.alpha", index: "trans"},
"task": {name: "task", index: [
"web.team.plan",
"web.wiki.draw.draw",
"web.wiki.word",
]},
"hello": {name: "应用1", action: [
{name: "some", help: "some", inputs: [
{type: "text", name: "one"},
{type: "button", name: "one"},
], engine: function(event, can, msg, pane, cmds, cb) {
can.onappend.toast(can, "hello", "world");
msg.Echo("hello world");
typeof cb == "function" && cb(msg);
}},
"relay": {name: "relay", index: [
"aaa.totp.get",
"web.route",
]},
"world": {name: "应用2", action: [
{name: "hello", help: "world", inputs: [
{type: "text", name: "one", value: "pwd"},
{type: "button", name: "one"},
], group: "cli", index: "system"},
"性能": {name: "性能", index: [
"web.code.pprof",
"web.code.bench",
"web.favor",
"web.cache",
"web.share",
]},
"wiki": {name: "wiki", index: [
// "web.wiki.draw.draw",
"web.wiki.feel",
"web.wiki.data",
]},
}},
}, })