From 81f7175f6466b3f05684bfd2b98dbac5ec78e8b6 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Wed, 19 Oct 2022 12:28:05 +0800 Subject: [PATCH] opt some --- lib/misc.js | 3 +++ page/index.css | 1 + panel/action.css | 1 + panel/action.js | 16 ++++------------ panel/header.css | 8 +------- plugin/local/mall/goods.css | 4 ++-- plugin/local/mall/goods.js | 22 +++++++++------------- plugin/local/team/plan.js | 5 +++-- plugin/state.js | 2 +- 9 files changed, 25 insertions(+), 37 deletions(-) diff --git a/lib/misc.js b/lib/misc.js index 68d79c24..c1fd5296 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -237,6 +237,9 @@ Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg var search = can.core.Item(args, function(key, value) { return key+"="+encodeURIComponent(value) }).join("&") return search? location.search = search: location.href = location.pathname }), + MergeCache: shy("地址链接", function(can, hash) { + return can.misc.MergeURL(can, {_path: "/share/cache/"+hash}, true) + }), MergePodCmd: shy("地址链接", function(can, objs) { objs.pod = can.core.Keys(can.misc.Search(can, "pod"), objs.pod) objs.topic = can.misc.Search(can, "topic") diff --git a/page/index.css b/page/index.css index 4e2b6b77..befcc5b3 100644 --- a/page/index.css +++ b/page/index.css @@ -236,6 +236,7 @@ body.mobile table.content th { padding:6px 6px; } body.mobile table.layout td.content div.toggle.project { width:30px; } body.mobile table.layout td.content div.toggle.profile { width:30px; } +body.mobile table.layout td.content div.toggle.display { margin-top:-30px; height:30px; } body.mobile form.option>div.item { margin:0; height:38px; } body.mobile div.action>div.item { margin:0; height:38px; } diff --git a/panel/action.css b/panel/action.css index f9a277e2..a90a04c8 100644 --- a/panel/action.css +++ b/panel/action.css @@ -40,6 +40,7 @@ fieldset.Action.flow>div.output>fieldset.plugin { float:left; } fieldset.Action.free>div.output>fieldset.plugin { position:absolute; } fieldset.Action.free>div.output>fieldset.plugin.select { display:block; } +fieldset.Action.cmd { overflow:hidden; } fieldset.panel.cmd>div.output>fieldset.plugin { padding:0; margin:0; } fieldset.panel.cmd>div.output>fieldset.plugin>legend { padding:0 10px; margin-right:3px; float:left; } diff --git a/panel/action.js b/panel/action.js index 58d84f57..431ab4ea 100644 --- a/panel/action.js +++ b/panel/action.js @@ -12,6 +12,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) { meta.id && (sub._option.dataset = sub._option.dataset||{}, sub._option.dataset.id = meta.id) can.page.style(can, sub._output, html.MAX_WIDTH, can.ConfWidth()) + sub.Mode(can.Mode()) sub.run = function(event, cmds, cb) { return can.run(sub.request(event, {width: sub.ConfWidth(), height: sub.ConfHeight()}), can.misc.concat(can, [river, storm, meta.id||meta.index], cmds), cb) }, can._plugins = can.misc.concat(can, can._plugins, [sub]) @@ -37,8 +38,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) { }) }, _cmd: function(can, item, next) { can.onengine.signal(can, chat.ONACTION_CMD) can.onappend.plugin(can, can.base.Copy(item, {mode: "cmd", opts: can.misc.Search(can)}), function(sub, meta, skip) { - sub.run = function(event, cmds, cb) { - can.runActionCommand(can.request(event, {width: can.ConfWidth(), height: can.ConfHeight()}), sub._index, cmds, cb) } + sub.run = function(event, cmds, cb) { can.runActionCommand(can.request(event, {width: can.ConfWidth(), height: can.ConfHeight()}), sub._index, cmds, cb) } can._plugins = can.misc.concat(can, can._plugins, [sub]) can.user.title(meta.name), skip || next() }) @@ -193,14 +193,9 @@ Volcanos(chat.ONACTION, {help: "操作数据", _init: function(can, cb, target) can.onmotion.select(can, can._output, html.FIELDSET_PLUGIN, parseInt(event.key)-1) } }, - onsize: function(can, msg, height, width) { - can.Conf({height: height-can.Conf(html.MARGIN_Y), width: width-can.Conf(html.MARGIN_X)}) - }, + onsize: function(can, msg, height, width) { can.Conf({height: height-can.Conf(html.MARGIN_Y), width: width-can.Conf(html.MARGIN_X)}) }, onprint: function(can, msg) { can.page.styleHeight(can, can._target, "") }, - onresize: function(can, msg) { - can.onlayout._init(can) - can.onaction.layout(can, can.Conf(chat.LAYOUT)) - }, + onresize: function(can, msg) { can.onlayout._init(can), can.onaction.layout(can, can.Conf(chat.LAYOUT)) }, layout: function(can, button, silent) { button = button||ice.AUTO can.page.ClassList.del(can, can._target, can.Conf(chat.LAYOUT)); if (button == ice.AUTO) { button = "" } @@ -210,9 +205,6 @@ 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 } - // var cb = can.onlayout[button]; if (can.base.isFunc(cb)? cb(can, silent): (can.getActionSize(function(height, width) { - // can.ConfHeight(can.base.Min(200, height-can.Conf(html.MARGIN_Y)-(can.isCmdMode()? 0: 200))), can.ConfWidth(width-can.Conf(html.MARGIN_X)) - // }), false)) { 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)) 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() diff --git a/panel/header.css b/panel/header.css index 7e78b07f..b7e7c77b 100644 --- a/panel/header.css +++ b/panel/header.css @@ -7,10 +7,4 @@ fieldset.Header>div.output div.state { float:right; } fieldset.Header>div.output div.state.avatar { padding:0; height:31px; } fieldset.Header>div.output div.state.avatar>img { height:31px; } fieldset.Header>div.output div.search { margin-left:20px; float:left; } -fieldset.Header>div.output div.search>input { margin-top:-5px; border-radius:0; } - -fieldset.goods>div.output>div.item>div { padding:10px; float:left; clear:none; } -fieldset.goods>div.output>div.item { height:170px; width:430px; float:left; border-radius:10px; } -fieldset.goods>div.output>div.item>div.image img { border-radius:10px; } -fieldset.goods>div.output>div.item>div.content>div.title { width:240px; height:50px; white-space:break-spaces; overflow:auto; } -fieldset.goods>div.output>div.item>div.content>div.price { color:red; } \ No newline at end of file +fieldset.Header>div.output div.search>input { margin-top:-5px; border-radius:0; } \ No newline at end of file diff --git a/plugin/local/mall/goods.css b/plugin/local/mall/goods.css index d1493e69..3fa4f1de 100644 --- a/plugin/local/mall/goods.css +++ b/plugin/local/mall/goods.css @@ -1,6 +1,6 @@ -fieldset.goods>div.output>div.item { height:170px; float:left; border-radius:10px; } +fieldset.goods>div.output>div.item { border-radius:10px; height:170px; float:left; } fieldset.goods>div.output>div.item>div { padding:10px; float:left; clear:none; } fieldset.goods>div.output>div.item>div.image img { border-radius:10px; } fieldset.goods>div.output>div.item>div.content { float:right; } -fieldset.goods>div.output>div.item>div.content>div.title { height:50px; white-space:break-spaces; overflow:hidden; } +fieldset.goods>div.output>div.item>div.content>div.title { white-space:break-spaces; overflow:hidden; height:50px; } fieldset.goods>div.output>div.item>div.content>div.price { color:red; } \ No newline at end of file diff --git a/plugin/local/mall/goods.js b/plugin/local/mall/goods.js index 71c61bca..b987f4de 100644 --- a/plugin/local/mall/goods.js +++ b/plugin/local/mall/goods.js @@ -1,15 +1,14 @@ Volcanos(chat.ONIMPORT, { - _init: function(can, msg, cb, target) { - var width = can.onexport.width(can); can.user.isMobile && can.page.style(can, can._output, html.HEIGHT, can.ConfHeight()) + _init: function(can, msg, target) { can.page.Appends(can, target, msg.Table(function(item) { - return {view: html.ITEM, style: {width: width}, list: [ - {view: wiki.IMAGE, list: [{img: can.misc.MergeURL(can, {_path: "/share/cache/"+can.core.Split(item.image)[0]}), width: 150}]}, + return {view: html.ITEM, list: [ + {view: wiki.IMAGE, list: [{img: can.misc.MergeCache(can, can.core.Split(item.image)[0]), width: 150}]}, {view: wiki.CONTENT, list: [ - {view: [wiki.TITLE, html.DIV, item.name], style: {width: width-190}}, + {view: [wiki.TITLE, html.DIV, item.name]}, {view: [wiki.CONTENT, html.DIV, item.text]}, {view: [mall.PRICE, html.DIV, "¥ "+(item.price||0)]}, {view: [mall.COUNT, html.DIV, "还剩 "+(item.count||0)]}, - {view: html.ACTION, inner: item.action, style: {width: width-190}}, + {view: html.ACTION, inner: item.action}, ]}, ], onclick: function(event) { if (can.page.tagis(event.target, html.INPUT) && event.target.type == html.BUTTON) { @@ -18,14 +17,11 @@ Volcanos(chat.ONIMPORT, { can.Option(mdb.HASH, item.hash), can.Update() } }} - })), can.base.isFunc(cb) && cb(msg) + })), can.onimport.layout(can) }, - layout: function(can) { can.user.isMobile && can.page.style(can, can._output, html.HEIGHT, can.ConfHeight()) - var width = can.onexport.width(can); can.page.Select(can, can._output, html.DIV_ITEM, function(target) { - can.page.style(can, target, html.WIDTH, width), can.page.Select(can, target, "div.title,div.action", function(target) { - can.page.style(can, target, html.WIDTH, width-190) - }) - }) + layout: function(can) { var width = can.onexport.width(can) + can.page.Select(can, can._output, "div.item>div.content", function(target) { can.page.styleWidth(can, target, width-190) }) + can.isCmdMode() && can.page.styleHeight(can, can._output, can.ConfHeight()) }, }, [""]) Volcanos(chat.ONEXPORT, { diff --git a/plugin/local/team/plan.js b/plugin/local/team/plan.js index c09d480a..4991dab0 100644 --- a/plugin/local/team/plan.js +++ b/plugin/local/team/plan.js @@ -1,7 +1,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, target) { can.onmotion.clear(can, target) - can.ui = can.onlayout.profile(can) - can.onimport.layout(can) + can.isCmdMode() && can.page.styleHeight(can, can._output, can.ConfHeight()) can._display_heights = {} + can.ui = can.onlayout.profile(can), can.onimport.layout(can) can.onimport[can.Option("scale")||"week"](can, msg) can.page.style(can, can.ui.project, html.MAX_HEIGHT, can.ui.content.offsetHeight) can.page.style(can, can.ui.profile, html.MAX_HEIGHT, can.ui.content.offsetHeight) @@ -122,6 +122,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar can.onimport._content(can, msg, head, list, key, get, set) }, layout: function(can) { + can.user.isMobile && can.page.styleHeight(can, can._output, can.ConfHeight()) if (can.isCmdMode()) { var height = can._display_heights[can.sup.task? [can.sup.task.zone, can.sup.task.id].join(ice.FS): ""]||html.ACTION_HEIGHT if (can.ui.display.innerHTML && can.ui.display.style.display != "none") { diff --git a/plugin/state.js b/plugin/state.js index 3a3f34d8..136090d3 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -156,7 +156,7 @@ Volcanos(chat.ONACTION, {help: "交互操作", list: [ }, "生成链接": function(event, can) { var meta = can.Conf(), args = can.Option() args.cmd = meta.index||can.core.Keys(meta.ctx, meta.cmd), args.cmd == "web.wiki.word" && (args.cmd = args.path) - can.onmotion.share(event, can, [], [mdb.LINK, can.user.copy(event, can, can.misc.MergeURL(can, args))]) + can.onmotion.share(event, can, [], [mdb.LINK, can.user.copy(event, can, can.misc.MergePodCmd(can, args))]) }, "生成脚本": function(event, can) { var conf = can.Conf() var args = can.Input("", true).join(ice.SP), list = [