From c75c98e8a67170ad9ce5365f7ca78c3130396b9a Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 16 Aug 2020 18:29:48 +0800 Subject: [PATCH] opt some --- chrome/contexts.js | 11 ++++++++++- lib/user.js | 1 + pane/Header.js | 12 +++++++----- plugin/local/code/inner.css | 2 +- plugin/local/code/inner.js | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/chrome/contexts.js b/chrome/contexts.js index 8847c410..bfb96d67 100644 --- a/chrome/contexts.js +++ b/chrome/contexts.js @@ -12,9 +12,18 @@ var can = Volcanos("chrome", { 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") - msg.Push("name", "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) }) diff --git a/lib/user.js b/lib/user.js index 71819ad4..e9c804d8 100644 --- a/lib/user.js +++ b/lib/user.js @@ -236,5 +236,6 @@ 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, + isExtension: location && location.protocol && location.protocol == "chrome-extension:", }) diff --git a/pane/Header.js b/pane/Header.js index d10635ff..e1a7435d 100644 --- a/pane/Header.js +++ b/pane/Header.js @@ -92,7 +92,7 @@ Volcanos("onexport", {help: "导出数据", list: [], _init: function(can, msg, }, }], }]).input) var height = document.body.offsetHeight - var ui = can.page.Append(can, can._output, can.core.List(["River", "Footer", "pack"], function(item) { + var ui = can.page.Append(can, can._output, can.core.List(can.user.isMobile || can.user.isExtension? ["River"]: [], function(item) { return {view: "item", list: [{type: "input", data: {name: item, type: "button", value: item.toLowerCase()}, onclick: function(event) { var cb = can.onaction[item]; if (typeof cb == "function") { @@ -106,12 +106,14 @@ Volcanos("onexport", {help: "导出数据", list: [], _init: function(can, msg, }]} })); - if (location.protocol == "chrome-extension:") { - ui.River.click() + if (can.user.isExtension) { + ui.River && ui.River.click() } else if (can.user.Search(can, "pod")) { - ui.River.click(), ui.Footer.click() + can.onaction.Footer({}, can) + ui.River && ui.River.click() } else if (can.user.isMobile) { - ui.River.click(), ui.Footer.click() + can.onaction.Footer({}, can) + ui.River && ui.River.click() } typeof cb == "function" && cb() diff --git a/plugin/local/code/inner.css b/plugin/local/code/inner.css index 08a07261..d8ac7460 100644 --- a/plugin/local/code/inner.css +++ b/plugin/local/code/inner.css @@ -52,7 +52,7 @@ fieldset.editor>div.output div.content { font-size:16px; font-family:monospace; border-left:solid 2px red; min-height:20px; - min-width:800px; + min-width:400px; max-width:1000px; overflow:auto; float:left; diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index 99edcb5e..7ce02072 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -50,7 +50,7 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb, can.file = file, can.parse = can.base.Ext(file||path), can.max = 0 can.onsyntax._init(can, can._msg) - var width = can._target.offsetWidth - can.ui.project.offsetWidth - can.ui.preview.offsetWidth - 60 + var width = can._target.offsetWidth - can.ui.project.offsetWidth - can.ui.preview.offsetWidth - 30 can.Status("当前行", can.onexport.position(can, parseInt(can.Option("line")))-1) can.page.Modify(can, can.ui.content, {style: {"max-width": width+"px"}}) }