From 675dc57b6968683321f23086aedd5bfba3e8e5f1 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Sun, 23 Oct 2022 12:49:29 +0800 Subject: [PATCH] opt some --- frame.js | 9 ++++++--- lib/base.js | 7 ++++++- page/index.css | 7 ++++--- panel/action.js | 8 ++++++-- panel/header.js | 3 +++ plugin/local/code/inner/syntax.js | 1 + plugin/local/code/vimer.js | 2 +- plugin/local/team/plan.js | 2 +- plugin/local/wiki/word.js | 6 +++++- plugin/state.js | 4 ++-- plugin/story/trend.js | 3 ++- plugin/table.js | 6 +++++- 12 files changed, 42 insertions(+), 16 deletions(-) diff --git a/frame.js b/frame.js index bf62564a..3837ca63 100644 --- a/frame.js +++ b/frame.js @@ -512,8 +512,7 @@ Volcanos(chat.ONLAYOUT, {help: "页面布局", _init: function(can, target) { ta }) can.page.Select(can, target, html.FIELDSET_LEFT, function(field, index) { - can.user.isMobile || (width -= field.offsetWidth) - can.page.styleHeight(can, field, height) + can.page.styleHeight(can, field, height), can.user.isMobile || (width -= field.offsetWidth) can.page.Select(can, target, [[html.FIELDSET_LEFT, html.DIV_OUTPUT]], function(output) { can.page.styleHeight(can, output, height-html.ACTION_HEIGHT) }) @@ -536,7 +535,11 @@ Volcanos(chat.ONLAYOUT, {help: "页面布局", _init: function(can, target) { ta var rect = event.target == document.body? {left: window.innerWidth/2, top: 200, right: window.innerWidth/2, bottom: 200}: event.target.getBoundingClientRect() var layout = right? {left: rect.right, top: rect.top}: {left: rect.left, top: rect.bottom} can.getActionSize(function(left, top, width, height) { left = left||0, top = top||0 - if (layout.top+target.offsetHeight > window.innerHeight) { layout.top = "", layout.bottom = window.innerHeight-top-height } + if (layout.top+target.offsetHeight > window.innerHeight) { + layout.top = "", layout.bottom = can.base.Min(window.innerHeight-top-height, 0) + layout[html.MAX_HEIGHT] = window.innerHeight + layout["overflow"] = "auto" + } if (layout.left+target.offsetWidth > window.innerWidth) { layout.left = "", layout.right = 0 } }) return can.onmotion.move(can, target, layout), layout diff --git a/lib/base.js b/lib/base.js index 3b1c3c06..d2a7e783 100644 --- a/lib/base.js +++ b/lib/base.js @@ -212,7 +212,12 @@ Volcanos("base", {help: "数据类型", Int: function(val, def) { return parseIn replaceAll: function(str) { for (var i = 1; i < arguments.length; i += 2) { if (!arguments[i]) { continue } if (str.replaceAll) { str = str.replaceAll(arguments[i], arguments[i+1]); continue } - if (str.replace) { str = str.replace(arguments[i], arguments[i+1]); continue } + if (arguments[i] && str.replace) { + while (str.indexOf(arguments[i]) > -1) { + str = str.replace(arguments[i], arguments[i+1]) + } + continue + } } return str }, diff --git a/page/index.css b/page/index.css index e7186a63..4443798a 100644 --- a/page/index.css +++ b/page/index.css @@ -234,6 +234,8 @@ body.mobile textarea { font-size:1.2rem; border-radius:0; } body.mobile input[type=text] { font-size:1.2rem; height:38px; border-radius:0; margin-right:5px; } body.mobile input[type=button] { font-size:1.2rem; height:38px; border-radius:0; } body.mobile fieldset.float input[type=button] { font-size:1.4rem; height:38px; } +body.mobile fieldset.plugin { margin:10px 0; } +body.mobile fieldset.plugin.full { margin:0; } body.mobile table.layout div.toggle { font-size:48px; } body.mobile table.content th { padding:6px 6px; } @@ -269,11 +271,10 @@ body.mobile fieldset.Footer.foot div.output { height:3rem; } body.mobile fieldset.Footer.foot div.output div { height:2.6rem; } body.mobile fieldset.Footer.foot input[name=cmd] { height:38px; } -body.mobile.landscape fieldset.Header.head { position:unset; display:none; } -body.mobile.landscape fieldset.Header.head div.search>input { width:240px; } +body.mobile.landscape fieldset.Header.head { position:unset; } body.mobile.landscape fieldset.Header.head div.state.time { display:block; } body.mobile.landscape fieldset.Action.main { margin-top:0; margin-bottom:0; } -body.mobile.landscape fieldset.Footer.foot { position:unset; display:none; } +body.mobile.landscape fieldset.Footer.foot { position:unset; } body.mobile.landscape fieldset.Footer.foot input[name=cmd] { width:240px; } body.mobile fieldset.draw.spide div.action { display:none; } diff --git a/panel/action.js b/panel/action.js index bd602f85..b19d48df 100644 --- a/panel/action.js +++ b/panel/action.js @@ -121,6 +121,10 @@ Volcanos(chat.ONKEYMAP, {help: "键盘交互", _focus: [], _init: function(can, Volcanos(chat.ONACTION, {help: "操作数据", _init: function(can, cb, target) { can.Conf(html.MARGIN_Y, 4*html.PLUGIN_MARGIN+2*html.ACTION_HEIGHT+html.ACTION_MARGIN) can.Conf(html.MARGIN_X, 4*html.PLUGIN_MARGIN) + if (can.user.isMobile) { + can.Conf(html.MARGIN_Y, 4*html.PLUGIN_MARGIN+2*html.ACTION_HEIGHT+html.ACTION_MARGIN) + can.Conf(html.MARGIN_X, 2*html.PLUGIN_MARGIN) + } if (can.user.mod.isPod || can.user.isMobile) { var gt = "❯", lt = "❮"; function toggle(view) { return can.onmotion.toggle(can, can._root.River._target) } @@ -205,10 +209,10 @@ Volcanos(chat.ONACTION, {help: "操作数据", _init: function(can, cb, target) can.onlayout._init(can) var cb = can.onlayout[button]; if (can.base.isFunc(cb)? cb(can, silent): (function() {})()) { return } - can.page.style(can, can._target, html.HEIGHT, can.ConfHeight()+can.Conf(html.MARGIN_Y), html.WIDTH, can.ConfWidth()+can.Conf(html.MARGIN_X)) + (button == "" && can.user.isMobile) || can.page.style(can, can._target, html.HEIGHT, can.ConfHeight()+can.Conf(html.MARGIN_Y), html.WIDTH, can.ConfWidth()+can.Conf(html.MARGIN_X)) can.core.Next(can._plugins, function(sub, next) { can.onmotion.delay(can, function() { sub.onaction._resize(sub, button == "" || button == ice.AUTO, can.ConfHeight(), can.ConfWidth()), next() - if (button == "" || button == ice.AUTO) { can.page.style(can, sub._output, html.MAX_HEIGHT, "") } + if (button == "") { can.page.style(can, sub._output, html.MAX_HEIGHT, "") } }, 10) }) }, help: function(can, button) { can.user.open("/help/"+button+".shy") }, diff --git a/panel/header.js b/panel/header.js index 8d5ad2b2..bd94b3a0 100644 --- a/panel/header.js +++ b/panel/header.js @@ -145,6 +145,9 @@ Volcanos(chat.ONACTION, {help: "交互数据", "clear": "清除背景", "logout": "退出登录", }, + onsize: function(can, msg) { + can.onimport.topic(can) + }, onmain: function(can, msg) { can.run({}, [], function(msg) { if (!can.Conf(aaa.USERNICK, msg.Option(aaa.USERNICK)||msg.Option(ice.MSG_USERNICK)||msg.Option(ice.MSG_USERNAME))) { diff --git a/plugin/local/code/inner/syntax.js b/plugin/local/code/inner/syntax.js index b15ccf31..02d19a0d 100644 --- a/plugin/local/code/inner/syntax.js +++ b/plugin/local/code/inner/syntax.js @@ -279,6 +279,7 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", "for": code.KEYWORD, "while": code.KEYWORD, "break": code.KEYWORD, + "continue": code.KEYWORD, "switch": code.KEYWORD, "case": code.KEYWORD, "default": code.KEYWORD, diff --git a/plugin/local/code/vimer.js b/plugin/local/code/vimer.js index 43b951a0..451e2e22 100644 --- a/plugin/local/code/vimer.js +++ b/plugin/local/code/vimer.js @@ -28,7 +28,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar Volcanos(chat.ONFIGURE, {help: "索引导航", create: function(can, target, zone, path) { can.isCmdMode()? can.onappend._action(can, can.base.Obj(can._msg.Option(ice.MSG_ACTION)).concat( - window.webview? ["查找", "git", "vim", "录屏", "日志", "编辑器", "浏览器", "首页", "百度"]: ["查找"]), target): can.onmotion.hidden(can, target.parentNode) + window.webview? ["查找", "录屏", "git", "vim", "日志", "编辑器", "浏览器", "首页", "百度"]: ["查找"]), target): can.onmotion.hidden(can, target.parentNode) }, recent: function(can, target, zone, path) { var total = 0 function show(msg, cb) { diff --git a/plugin/local/team/plan.js b/plugin/local/team/plan.js index 87e3b2d3..250acbe6 100644 --- a/plugin/local/team/plan.js +++ b/plugin/local/team/plan.js @@ -111,7 +111,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onmotion.clear( }, layout: function(can) { can.page.styleWidth(can, can.ui.content, can.ConfWidth()-can.ui.project.offsetWidth-can.ui.profile.offsetWidth) - if (can.isCmdMode() || can.isPlugType()) { can.page.styleHeight(can, can._output, can.ConfHeight()) + if (can.isCmdMode() || can.isFullMode() || can.isPlugType()) { can.page.styleHeight(can, can._output, can.ConfHeight()) var height = can._display_heights[can.sup.task? [can.sup.task.zone, can.sup.task.id].join(ice.FS): ""]||200 if (can.ui.display.innerHTML && can.ui.display.style.display != html.NONE) { can.page.style(can, can.ui.content, html.HEIGHT, can.ConfHeight()-height) diff --git a/plugin/local/wiki/word.js b/plugin/local/wiki/word.js index 01e19c5f..a5471c91 100644 --- a/plugin/local/wiki/word.js +++ b/plugin/local/wiki/word.js @@ -100,6 +100,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }) }, chart: function(can, data, target) { + can.page.style(can, target, html.MAX_WIDTH, can.ConfWidth(), "overflow", "auto") if (!data.fg && !data.bg) { target.className.baseVal = "story auto" } target.onclick = function(event) { @@ -164,7 +165,10 @@ Volcanos(chat.ONACTION, {help: "控件交互", }) can.onappend._init(can, {type: "story word float"}, [], function(sub) { - sub.run = can.run, sub.sup = can, can.sub = sub, can.onappend._action(sub, [ + sub.run = can.run, sub.sup = can, can.sub = sub, can.onappend._action(sub, can.user.isMobile && window.innerHeight > window.innerWidth? [ + "大纲", "上一页", + "下一页", "结束", + ]: [ ["布局", "开讲", "网格", "快闪"], "大纲", "首页", "上一页", ["菜单"].concat(can.core.List(list, function(page) { return page[0].innerHTML })), "下一页", "隐藏", "结束", diff --git a/plugin/state.js b/plugin/state.js index 9c80138c..5c1ddb15 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -127,14 +127,14 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ "刷新数据": function(event, can) { can.Update({}, can.Input([], true)) }, "切换浮动": function(event, can, button, sub) { can.onaction._switch(can, sub, "float", function() { - can.ConfHeight(window.innerHeight/2), html.WIDTH, can.ConfWidth(window.innerWidth/2) + can.ConfHeight(window.innerHeight/2), html.WIDTH, can.ConfWidth(window.innerWidth/(can.user.isMobile? 1: 2)) can.getActionSize(function(left) { can.onmotion.move(can, can._target, {left: left||0, top: window.innerHeight/2-4*html.ACTION_HEIGHT-html.PLUGIN_MARGIN}) }) }, function() { can.page.style(can, can._target, html.LEFT, "", html.TOP, "") }) }, "切换全屏": function(event, can, button, sub) { can.onaction._switch(can, sub, "full", function() { can.ConfWidth(window.innerWidth) can.page.style(can, can._target, html.LEFT, "", html.BOTTOM, "") - can.ConfHeight(window.innerHeight-html.ACTION_HEIGHT-can.onexport.statusHeight(can)-(can.user.isMobile? 2*html.ACTION_HEIGHT: 0)) + can.ConfHeight(window.innerHeight-html.ACTION_HEIGHT-can.onexport.statusHeight(can)) }, function() {}) }, "共享工具": function(event, can) { var meta = can.Conf() diff --git a/plugin/story/trend.js b/plugin/story/trend.js index 345d1b2e..ef96d3e2 100644 --- a/plugin/story/trend.js +++ b/plugin/story/trend.js @@ -43,6 +43,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar return {height: height, width: width, space: space, step: step} }, layout: function(can) { + can.onmotion.toggle(can, can._option, !can.user.isMobile || !can.isFullMode()) can.onaction[can.Action(ice.VIEW)]({}, can) }, transform: function(can, target) { @@ -51,7 +52,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }, [""]) Volcanos(chat.ONACTION, {help: "组件菜单", list: [ [ice.VIEW, "趋势图", "柱状图", "折线图", "数据源"], - [html.HEIGHT, ice.AUTO, 100, 200, 400, 600, 800, ice.AUTO], + [html.HEIGHT, ice.AUTO, 100, 200, 400, 600, 800], ["space", 10, 20, 50, 100], [html.SPEED, 10, 20, 50, 100], ], diff --git a/plugin/table.js b/plugin/table.js index 0a08d070..de515897 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -11,6 +11,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar can.onappend.board(can, msg, target) can.onmotion.story.auto(can, target) can.base.isFunc(cb) && cb(msg) + can.user.isMobile && can.onmotion.toggle(can, can._action, can.ConfHeight() < can.ConfWidth()) can.page.Select(can, target, "input[type=button]", function(target) { if (target.value == target.name) { target.value = can.user.trans(can, target.name) } }) @@ -220,7 +221,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }, }) Volcanos(chat.ONLAYOUT, {help: "界面布局", - _init: function(can) { can.core.CallFunc([can.onimport, html.LAYOUT], {can: can}) }, + _init: function(can) { + can.user.isMobile && can.onmotion.toggle(can, can._action, can.ConfHeight() < can.ConfWidth()) + can.core.CallFunc([can.onimport, html.LAYOUT], {can: can}) + }, float: function(can) { can.onlayout._init(can) }, full: function(can) { can.sup.onimport.size(can.sup, can.ConfHeight(), can.ConfWidth(), false)