diff --git a/frame.js b/frame.js index 4ec41e73..8a826a4c 100644 --- a/frame.js +++ b/frame.js @@ -530,6 +530,9 @@ Volcanos("onmotion", {help: "动态特效", list: [], _init: function(can, targe can.page.Modify(can, item, {style: can.base.Obj(meta.style)}) can.core.CallFunc(that._hash[meta.type], [can, meta, target||can._output]) }) + can.page.Select(can, target||can._output, html.IFRAME, function(item) { + can.page.Modify(can, item, {style: {height: can.Conf(html.HEIGHT)-88, width: can.Conf(html.WIDTH)-30}}) + }) }, }, float: {_hash: {}, @@ -658,6 +661,7 @@ Volcanos("onkeypop", {help: "键盘交互", list: [], _focus: [], _init: functio document.body.onkeydown = function(event) { var msg = can.request(event) msg.Option("model", "normal"); if (event.target.tagName == "INPUT") { msg.Option("model", event.ctrlKey? "insert_ctrl": "insert") + return } if (msg.Option(ice.MSG_HANDLE) == ice.TRUE) { return } can.onengine.signal(can, "onkeydown", msg) diff --git a/lib/user.js b/lib/user.js index 65ff3a7c..e65b9fe8 100644 --- a/lib/user.js +++ b/lib/user.js @@ -174,11 +174,10 @@ Volcanos("user", {help: "用户操作", agent: { var ui = can.page.Append(can, document.body, [{view: chat.CARTE, style: {left: 0, top: 0}, onmouseleave: function(event) { // can.page.Remove(can, ui._target) - }, list: can.core.List(list, function(item) { + }, list: can.core.List(list, function(item, index) { return can.base.isString(item)? {view: "item", list: [{text: can.user.trans(can, item), click: function(event) { can.user.isMobile && can.page.Remove(can, ui._target) - can.base.isFunc(cb) && cb(event, item, meta) - // can.onmotion.float.del(can, "carte") + can.base.isFunc(cb) && cb(event, item, meta, index) }, onmouseenter: function(event) { carte._float && can.page.Remove(can, carte._float._target) } }] }: {view: "item", list: [{text: can.user.trans(can, item[0])}], onmouseenter: function(event) { @@ -226,7 +225,6 @@ Volcanos("user", {help: "用户操作", agent: { return {type: html.TR, list: [{type: html.TD, list: [{text: item._trans||can.user.trans(can, item.name)||""}]}, {type: html.TD, list: [can.page.input(can, item)]} ]} })}, {view: chat.ACTION}, ]}]); can.onlayout.figure(event, can, ui._target) - can.page.ClassList.add(can, ui._target, "float") var action = can.onappend._action(can, button||[html.SUBMIT, html.CANCEL], ui.action, { cancel: function(event) { can.page.Remove(can, ui._target) }, diff --git a/page/index.js b/page/index.js index b5c5c256..1fd768ae 100644 --- a/page/index.js +++ b/page/index.js @@ -4,36 +4,20 @@ Volcanos({name: "chat", panels: [ {name: "Action", help: "工作台", pos: chat.MAIN}, {name: "Search", help: "搜索框", pos: chat.AUTO}, {name: "Footer", help: "状态条", pos: chat.FOOT, state: ["ncmd"]}, - ], main: {name: "Header", list: ["/publish/order.js"]}, plugin: [ - "/plugin/state.js", - "/plugin/input.js", - "/plugin/table.js", - "/plugin/input/key.js", - "/plugin/input/date.js", - "/plugin/story/spide.js", - "/plugin/story/trend.js", - "/plugin/local/code/inner.js", - "/plugin/local/code/vimer.js", - "/plugin/local/wiki/draw/path.js", - "/plugin/local/wiki/draw.js", - "/plugin/local/wiki/word.js", - "/plugin/local/chat/div.js", - "/plugin/local/team/plan.js", - "/plugin/input/province.js", - ], river: { + ], main: {name: "Header", list: ["/publish/order.js"]}, river: { serivce: {name: "运营群", storm: { - wx: {name: "公众号 wx", action: [ + wx: {name: "公众号 wx", list: [ {name: "微信公众号", help: "wx", index: "web.wiki.word", args: ["usr/icebergs/misc/wx/wx.shy"]}, ]}, - mp: {name: "小程序 mp", action: [ + mp: {name: "小程序 mp", list: [ {name: "微信小程序", help: "mp", index: "web.wiki.word", args: ["usr/icebergs/misc/mp/mp.shy"]}, ]}, - lark: {name: "机器人 lark", action: [ + lark: {name: "机器人 lark", list: [ {name: "飞书机器人", help: "lark", index: "web.wiki.word", args: ["usr/icebergs/misc/lark/lark.shy"]}, ]}, }}, product: {name: "产品群", storm: { - office: {name: "办公 office", action: [ + office: {name: "办公 office", list: [ {name: "feel", help: "影音媒体", index: "web.wiki.feel"}, {name: "draw", help: "思维导图", index: "web.wiki.draw"}, {name: "data", help: "数据表格", index: "web.wiki.data"}, @@ -42,18 +26,18 @@ Volcanos({name: "chat", panels: [ {name: "index", help: "索引", index: "web.wiki.word", args: ["usr/learning/index.shy"]}, {name: "context", help: "编程", index: "web.wiki.word", args: ["src/main.shy"]}, ]}, - english: {name: "英汉 english", action: [ + english: {name: "英汉 english", list: [ {name: "english", help: "英汉", index: "web.wiki.alpha.alpha", args: ["word", "hi"]}, {name: "chinese", help: "汉英", index: "web.wiki.alpha.alpha", args: ["line", "你好"]}, {name: "wubi", help: "五笔", index: "web.code.input.wubi", args: ["word", "wqvb"]}, {name: "wubi", help: "五笔", index: "web.code.input.wubi", args: ["line", "你好"]}, ]}, - learning: {name: "学习 learning", action: [ + learning: {name: "学习 learning", list: [ {name: "golang", help: "编程", index: "web.wiki.word", args: ["usr/golang-story/src/main.shy"]}, {name: "tmux", help: "粘贴", index: "web.code.tmux.text"}, {name: "study", help: "学习", index: "web.wiki.word", args: ["usr/learning/study.shy"]}, ]}, - chrome: {name: "爬虫 chrome", action: [ + chrome: {name: "爬虫 chrome", list: [ {name: "feel", help: "网页爬虫", index: "web.wiki.feel", args: ["spide/"], feature: { display: "/plugin/local/wiki/feel.js", height: 200, limit: 3, @@ -63,39 +47,39 @@ Volcanos({name: "chat", panels: [ ]}, }}, project: {name: "研发群", storm: { - studio: {name: "研发 studio", action: [ + studio: {name: "研发 studio", list: [ {name: "vimer", help: "编辑器", index: "web.code.vimer", args: ["src/", "main.go"], _action: ["autogen", "compile", "binpack"]}, {name: "repos", help: "代码库", index: "web.code.git.status"}, {name: "plan", help: "任务表", index: "web.team.plan"}, {name: "ctx", help: "上下文", index: "web.wiki.word", args: ["src/main.shy"]}, ]}, - web: {name: "网页 web", action: [ + web: {name: "网页 web", list: [ {name: "HTML5", help: "浏览器", index: "web.wiki.word", args: ["usr/icebergs/misc/chrome/chrome.shy"]}, ]}, - cli: {name: "命令 cli", action: [ + cli: {name: "命令 cli", list: [ {name: "bash", help: "命令行", index: "web.wiki.word", args: ["usr/icebergs/misc/bash/bash.shy"]}, {name: "git", help: "代码库", index: "web.wiki.word", args: ["usr/icebergs/misc/git/git.shy"]}, {name: "vim", help: "编辑器", index: "web.wiki.word", args: ["usr/icebergs/misc/vim/vim.shy"]}, {name: "tmux", help: "命令行", index: "web.wiki.word", args: ["usr/icebergs/misc/tmux/tmux.shy"]}, ]}, - linux: {name: "系统 linux", action: [ + linux: {name: "系统 linux", list: [ {name: "idc", help: "平台", index: "web.wiki.word", args: ["usr/linux-story/idc/idc.shy"]}, {name: "iso", help: "系统", index: "web.wiki.word", args: ["usr/linux-story/iso/iso.shy"]}, {name: "iot", help: "设备", index: "web.wiki.word", args: ["usr/linux-story/iot/iot.shy"]}, {name: "cli", help: "命令", index: "web.wiki.word", args: ["usr/linux-story/cli/cli.shy"]}, {name: "linux", help: "系统", index: "web.wiki.word", args: ["usr/linux-story/src/main.shy"]}, ]}, - nginx: {name: "代理 nginx", action: [ + nginx: {name: "代理 nginx", list: [ {name: "nginx", help: "代理", index: "web.wiki.word", args: ["usr/nginx-story/src/main.shy"]}, ]}, - context: {name: "编程 context", action: [ + context: {name: "编程 context", list: [ {name: "golang", help: "编程", index: "web.wiki.word", args: ["usr/golang-story/src/main.shy"]}, ]}, - redis: {name: "缓存 redis", action: [ + redis: {name: "缓存 redis", list: [ {name: "redis", help: "缓存", index: "web.wiki.word", args: ["usr/redis-story/src/main.shy"]}, {name: "kafka", help: "队列", index: "web.wiki.word", args: ["usr/redis-story/src/kafka/kafka.shy"]}, ]}, - mysql: {name: "存储 mysql", action: [ + mysql: {name: "存储 mysql", list: [ {name: "mysql", help: "数据存储", index: "web.wiki.word", args: ["usr/mysql-story/src/main.shy"]}, {name: "clickhouse", help: "数据存储", index: "web.wiki.word", args: ["usr/mysql-story/src/clickhouse/clickhouse.shy"]}, ]}, diff --git a/panel/action.js b/panel/action.js index aa164f7f..db685227 100644 --- a/panel/action.js +++ b/panel/action.js @@ -74,9 +74,9 @@ Volcanos("onengine", {help: "解析引擎", list: [], _engine: function(event, p if (!storm || cmds.length != 2) { return false } if (storm.index) { cmds = [ctx.ACTION, ctx.COMMAND].concat(storm.index) - can.run(event, cmds, cb) - } else { - can.core.List(storm.action, function(value) { + can.run(event, cmds, cb) // 命令详情 + } else { // 命令列表 + can.core.List(storm.list, function(value) { msg.Push("name", value.name||"") msg.Push("help", value.help||"") msg.Push("inputs", JSON.stringify(value.inputs)) diff --git a/panel/cmd.js b/panel/cmd.js index d3807161..1f413223 100644 --- a/panel/cmd.js +++ b/panel/cmd.js @@ -18,7 +18,7 @@ Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, msg, can.page.ClassList.add(can, can._target, "Action") }, _plugin: function(can, item, next) { - item.height = window.innerHeight, item.width = window.innerWidth, item.opts = can.misc.Search() + item.height = window.innerHeight, item.width = window.innerWidth, item.opts = can.misc.Search(can) can.onappend.plugin(can, item, function(sub, meta) { can.user.title(meta.name), next() }) }, }) diff --git a/panel/header.js b/panel/header.js index 98bf0fea..75f9fb88 100644 --- a/panel/header.js +++ b/panel/header.js @@ -39,6 +39,11 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, !can.user.isMobile && can.core.List(msg.result||["shylinux.com/x/contexts"], function(item) { can.page.Append(can, target, [{view: [chat.TITLE, html.DIV, item], title: "返回主页", onclick: function(event) { can.onaction.title(event, can) + }, onmouseenter: function(event) { + var list = msg.Table() + can.user.carte(event, can, {}, can.core.List(list, function(item) { return item.name }), function(event, item, meta, index) { + can.user.open(list[index].path) + }) }}]) }) }, diff --git a/panel/search.js b/panel/search.js index 8c438cdf..813cc8c9 100644 --- a/panel/search.js +++ b/panel/search.js @@ -4,32 +4,31 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, return {text: [key == kit.MDB_TEXT && can.base.isFunc(line.text) && line.text.help || value, html.TD], onclick: function(event) { can.onaction[can.type == "*"||event.ctrlKey? chat.PLUGIN: mdb.SELECT](event, can, index) }} - }, can.ui.content, can.core.List((msg.Option("sort")||"ctx,cmd,type,name,text").split(","), function(item) { + }, can.ui.content, can.core.List((msg.Option("sort")||"ctx,cmd,type,name,text").split(ice.FS), function(item) { return list.indexOf(item) })); table && can.page.Modify(can, can.ui.display, {style: {width: table.offsetWidth}}) - msg.Length() == 1 && can.page.Select(can, table, html.TD)[0].click() - can.onappend._status(can, can.base.Obj(msg.Option("_status"), []).concat({name: "selected", value: "0"})) - can.get("Action", "size", function(msg, height) { - can.page.Modify(can, can.ui.profile, {"max-height": height-table.offsetHeight}) + can.getActionSize(function(msg, height) { + can.page.Modify(can, can.ui.profile, kit.Dict(html.MAX_HEIGHT, height-table.offsetHeight)) }) + msg.Length() == 1 && can.page.Select(can, table, html.TD)[0].click() }, _word: function(can, msg, cmds, fields) { can.type = cmds[0] var cb = can.onaction[cmds[1]]; if (cb) { cb({}, can); return } var res = can.request({}, { - word: cmds, fields: fields.join(","), sort: msg.Option("sort"), + word: cmds, fields: fields.join(ice.FS), sort: msg.Option("sort"), river: msg.Option(chat.RIVER), index: msg.Option("index"), }) can.onengine.signal(can, chat.ONSEARCH, res) can.run(res._event, cmds, function(res) { can.onimport._init(can, res, fields) }) - can.onmotion.show(can), can.ui.input.focus(), can.ui.word.setSelectionRange(0, -1) + can.onmotion.show(can), can.onmotion.focus(can, can.ui.word) }, select: function(can, msg, cmds, cb) { can.ui.word.value = cmds[1] - var fields = (cmds[2]||msg.Option(ice.MSG_FIELDS)||"ctx,cmd,type,name,text").split(",") + var fields = (cmds[2]||msg.Option(ice.MSG_FIELDS)||"ctx,cmd,type,name,text").split(ice.FS) can.page.Appends(can, can.ui.display, [{th: fields}]), can.cb = function() { can.base.isFunc(cb) && cb(can.onexport.select(can)), can.onmotion.hide(can) } @@ -38,9 +37,9 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, can.onimport._word(can, msg, cmds, fields) }, can.onimport._word(can, msg, cmds, fields) - can.get("Action", "size", function(msg, top, left, width, height) { - can.page.Modify(can, can._output, {style: {"max-width": width, "max-height": height-40}}) + can.getActionSize(function(msg, top, left, width, height) { can.page.Modify(can, can._target, {style: {top: top, left: left}}) + can.page.Modify(can, can._output, {style: kit.Dict(html.MAX_HEIGHT, height-71, html.MAX_WIDTH, width)}) }) }, }) @@ -88,13 +87,11 @@ Volcanos("onaction", {help: "交互操作", list: [cli.CLEAR, cli.CLOSE, cli.DON plugin: function(event, can, index) { var line = can.list[index] if (can.base.isFunc(line.text)) { return can.onmotion.hide(can), line.text(event) } - var cmd = line.cmd == ctx.COMMAND? can.core.Keys(line.type, line.name.split(" ")[0]): can.core.Keys(line.ctx, line.cmd) + var cmd = line.cmd == ctx.COMMAND? can.core.Keys(line.type, line.name.split(ice.SP)[0]): can.core.Keys(line.ctx, line.cmd) can.onappend.plugin(can, {type: chat.PLUGIN, index: cmd||msg.Option(kit.MDB_INDEX)}, function(sub, meta) { - can.get("Action", "size", function(msg, height, width) { - height -= can.ui.content.offsetHeight+204 - can.page.Modify(can, sub._output, {style: {"max-height": height}}) - sub.Conf(html.HEIGHT, height+28) - sub.Conf(html.WIDTH, width-60) + can.getActionSize(function(msg, height, width) { height -= can.ui.content.offsetHeight+204 + can.page.Modify(can, sub._output, {style: kit.Dict(html.MAX_HEIGHT, height-26, html.MAX_WIDTH, width-40)}) + sub.Conf(html.HEIGHT, height+28), sub.Conf(html.WIDTH, width-60) }) sub.run = function(event, cmds, cb) { var msg = can.request(event, line) diff --git a/proto.js b/proto.js index 2ad505b4..3c5d1d9b 100644 --- a/proto.js +++ b/proto.js @@ -16,6 +16,11 @@ var kit = { MDB_HASH: "hash", MDB_LIST: "list", + Dict: function() { var res = {} + for (var i = 0; i < arguments.length; i += 2) { + res[arguments[i]] = arguments[i+1] + } return res + } } var ice = { SP: " ", PS: "/", PT: ".", FS: ",", NL: "\n", @@ -121,12 +126,36 @@ var chat = { ONMAIN: "onmain", ONSIZE: "onsize", ONLOGIN: "onlogin", ONSEARCH: "onsearch", - HEAD: "head", LEFT: "left", MAIN: "main", AUTO: "auto", FOOT: "foot", + HEAD: "head", LEFT: "left", MAIN: "main", AUTO: "auto", HIDE: "hide", FOOT: "foot", SCROLL: "scroll", LEFT: "left", TOP: "top", RIGHT: "right", BOTTOM: "bottom", HEADER: "header", FOOTER: "footer", - SSO: "sso", - CMD_MARGIN: 53, + SSO: "sso", CMD_MARGIN: 53, + + panel_list: [ + {name: "Header", help: "标题栏", pos: "head", state: ["time", "usernick", "avatar"]}, + {name: "River", help: "群聊组", pos: "left", action: ["create", "refresh"]}, + {name: "Action", help: "工作台", pos: "main"}, + {name: "Search", help: "搜索框", pos: "auto"}, + {name: "Footer", help: "状态条", pos: "foot", state: ["ncmd"]}, + ], + plugin_list: [ + "/plugin/state.js", + "/plugin/input.js", + "/plugin/table.js", + "/plugin/input/key.js", + "/plugin/input/date.js", + "/plugin/story/spide.js", + "/plugin/story/trend.js", + "/plugin/local/code/inner.js", + "/plugin/local/code/vimer.js", + "/plugin/local/wiki/draw/path.js", + "/plugin/local/wiki/draw.js", + "/plugin/local/wiki/word.js", + "/plugin/local/chat/div.js", + "/plugin/local/team/plan.js", + "/plugin/input/province.js", + ], } var team = { TASK: "task", PLAN: "plan", @@ -148,6 +177,7 @@ var html = { FORM: "form", FILE: "file", SPACE: "space", CLICK: "click", DIV: "div", IMG: "img", CODE: "code", SPAN: "span", VIDEO: "video", TABLE: "table", TR: "tr", TH: "th", TD: "td", BR: "br", + IFRAME: "iframe", SCROLL: "scroll", HEIGHT: "height", WIDTH: "width", LEFT: "left", TOP: "top", RIGHT: "right", BOTTOM: "bottom", @@ -157,6 +187,8 @@ var html = { LIST: "list", ITEM: "item", MENU: "menu", SUBMIT: "submit", CANCEL: "cancel", WSS: "wss", SVG: "svg", + MAX_HEIGHT: "max-height", MAX_WIDTH: "max-width", + MAX_HEIGHT: "max-height", } var lang = { STRING: "string", NUMBER: "number", @@ -178,7 +210,8 @@ function shy(help, meta, list, cb) { }; var _can_name = "", _can_path = "" var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", args: {}, pack: {}, libs: [], cache: {}}, function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list - if (typeof name == lang.OBJECT) { var Config = name; Config.panels = Config.panels||[], Config.main = Config.main||{} + if (typeof name == lang.OBJECT) { var Config = name; Config.panels = Config.panels||chat.panel_list, Config.main = Config.main||{name: "Header"} + Config.plugin = Config.plugin||chat.plugin_list libs = [], meta.libs = ["/lib/base.js", "/lib/core.js", "/lib/misc.js", "/lib/page.js", "/lib/user.js"] meta.iceberg = Config.iceberg||meta.iceberg @@ -242,6 +275,7 @@ var Volcanos = shy("火山架", {iceberg: "/chat/", volcano: "/frame.js", args: } return can.search({}, [can.core.Keys(name, "onexport", key)], cb) }, + getActionSize: function(cb) { can.get("Action", "size", cb) }, search: function(event, cmds, cb) { return can.run && can.run(event, ["_search"].concat(cmds), cb, true) }, Conf: function(key, value) { return can.core.Value(can._conf, key, value) }, _conf: {}, @@ -289,19 +323,5 @@ function cmd(tool) { Volcanos({name: "chat", panels: [ {name: "Header", help: "标题栏", pos: "hidden", state: ["time", "usernick", "avatar"]}, {name: "cmd", help: "工作台", pos: chat.MAIN, tool: tool}, - ], main: {name: "cmd", list: []}, plugin: [ - "/plugin/state.js", - "/plugin/input.js", - "/plugin/table.js", - "/plugin/input/key.js", - "/plugin/input/date.js", - "/plugin/story/spide.js", - "/plugin/story/trend.js", - "/plugin/local/code/inner.js", - "/plugin/local/code/vimer.js", - "/plugin/local/wiki/draw/path.js", - "/plugin/local/wiki/draw.js", - "/plugin/local/wiki/word.js", - ], - }) + ]}) }