From 69987767ade0c99053db452098d96095efffbcbc Mon Sep 17 00:00:00 2001 From: shy Date: Mon, 2 Jun 2025 19:13:26 +0800 Subject: [PATCH] add some --- frame.js | 14 +++++------- index.css | 14 ++++++++---- panel/header.js | 3 ++- plugin/input/img.js | 1 + plugin/input/key.js | 31 +++++++++++++++++--------- plugin/table.js | 54 +++++++++++++++++++++++++++------------------ 6 files changed, 72 insertions(+), 45 deletions(-) diff --git a/frame.js b/frame.js index a7cf8461..060894d1 100644 --- a/frame.js +++ b/frame.js @@ -361,7 +361,7 @@ Volcanos(chat.ONAPPEND, { if (can.page.tagis(can._target, "fieldset.cmd.form.output")) { can.page.ClassList.del(can, can._target, html.FORM), can.page.ClassList.del(can, can._target, html.OUTPUT) } can.page.ClassList.add(can, can._output, "_prepare") - can.onexport._output(sub, msg) + can.onexport._output && can.onexport._output(sub, msg) can.core.CallFunc([sub, chat.ONIMPORT, chat._INIT], {can: sub, msg: msg, cb: function(msg) { can.onappend.style(sub, sub.Conf(ctx.STYLE)), can.onmotion.story.auto(can, can._output), sub.onmotion.touchAction(sub) if (action !== false) { can.onkeymap._build(sub) @@ -674,12 +674,10 @@ Volcanos(chat.ONAPPEND, { function request(event) { delete(data.action); return can.request(event, data, can.Option()) } function run(event, cmd, arg) { can.misc.Event(event, can, function(msg) { can.run(request(event), [ctx.ACTION, cmd].concat(arg)) }) } function img(p) { return !msg.IsDetail()? can.page.Format(html.IMG, p, 48, 48): can.user.isMobile? can.page.Format(html.IMG, p, null, 320): can.page.Format(html.IMG, p, 320, null) } - if (key == mdb.ICON && value) { _value = can.base.contains(value, ".ico", ".png", ".jpg")? img(can.misc.Resource(can, data[key], data.pod||data.space||data.nodename)): "" } - if (key == mdb.ICONS && value) { _value = img(can.misc.Resource(can, data[key])) } - if (key == aaa.AVATAR && value) { _value = img(can.misc.Resource(can, data[key])) } - if (key == aaa.BACKGROUND && value) { _value = img(can.misc.Resource(can, data[key])) } - if (key == "user_avatar" && value) { _value = img(can.misc.Resource(can, data[key])) } - if (key == "auth_avatar" && value) { _value = img(can.misc.Resource(can, data[key])) } + if ((key == mdb.ICON || can.base.endWith(key, "_icon")) && value) { _value = can.base.contains(value, ".ico", ".png", ".jpg", "jpeg")? img(can.misc.Resource(can, data[key], data.pod||data.space||data.nodename)): "" } + if ((key == mdb.ICONS || can.base.endWith(key, "_icons")) && value) { _value = img(can.misc.Resource(can, data[key])) } + if ((key == aaa.AVATAR || can.base.endWith(key, "_avatar")) && value) { _value = img(can.misc.Resource(can, data[key])) } + if ((key == aaa.BACKGROUND || can.base.endWith(key, "_background")) && value) { _value = img(can.misc.Resource(can, data[key])) } if (key == nfs.IMAGE && value) { _value = can.core.List(can.core.Split(data[key]), function(item) { return img(can.misc.ShareCache(can, item, data.space)) }).join("") } if (key == mdb.HASH && can.base.isIn(can.ConfIndex(), "share", "web.share", web.TOKEN, aaa.SESS)) { _value = value.slice(0, 4)+"****" } if (key == "secret" && value) { _value = value.slice(0, 4)+"****" } @@ -1003,7 +1001,7 @@ Volcanos(chat.ONAPPEND, { sub.Status(html.HEIGHT, sub._output.offsetHeight), sub.Status(html.WIDTH, sub._output.offsetWidth) } can.core.CallFunc(on, {event: event, can: can, meta: meta, cb: _cb, target: target, sub: target._can, mod: can.onfigure[input],last: last, cbs: function(cb) { - target._can? show(target._can, cb): can.onappend._init(can, {type: html.INPUT, name: input, style: can.core.Keys(can.ConfIndex(), meta.name), mode: chat.FLOAT}, [path, meta.display], function(sub) { sub.Conf(meta) + target._can? show(target._can, cb): can.onappend._init(can, {type: html.INPUT, name: input, style: can.core.Keys(can.ConfIndex(), meta.name), mode: chat.FLOAT}, ["/plugin/table.js", path, meta.display], function(sub) { sub.Conf(meta) can.page.Append(can, sub._target, [{text: [can.page.unicode.remove, "", "close"], onclick: function() { sub.close() }}]) sub.run = function(event, cmds, cb) { var msg = sub.request(event) if (meta.range) { for (var i = meta.range[0]; i < meta.range[1]; i += meta.range[2]||1) { msg.Push(mdb.VALUE, i) } cb(msg); return } diff --git a/index.css b/index.css index 1ece5278..de94dd1b 100644 --- a/index.css +++ b/index.css @@ -46,7 +46,7 @@ body { --header-height:48px; --footer-height:var(--action-height); --action-height:32px; --status-height:32px; --textarea-height:96px; --input-width:140px; --button-width:60px; --form-width:360px; --url-input-width:480px; - --card-width:300px; --card-height:160px; --qrcode-width:320px; --qrcode-height:323px; + --card-width:300px; --card-height:160px; --qrcode-width:240px; --qrcode-height:323px; --story-height:var(--float-height); --iframe-height:480px; --plug-height:480px; --plug-width:var(--float-width); --desktop-height:684px; --desktop-width:var(--float-width); @@ -100,7 +100,7 @@ body.width1 { /* 320-640 手机竖屏 */ --table-button:2; --card-button:3; } body.en { --card-button:3; } -body.mobile { --project-width:240px; --footer-height:60px; --svg-font-size:13px; --qrcode-width:320px; } +body.mobile { --project-width:240px; --footer-height:60px; --svg-font-size:13px; --qrcode-width:240px; } body.mobile.dark { --body-bg-color:var(--output-bg-color); --action-output-bg-color:var(--output-bg-color); } body.mobile.light { --body-bg-color:var(--output-bg-color); --action-output-bg-color:var(--output-bg-color); } body.cmd.web.code.vimer { --code-line-height:24px; } @@ -417,8 +417,11 @@ body div.input.float tr.img td:last-child>div.item { width:var(--river-width); f body div.input.float tr.img td:last-child>div.item>div { background-color:gray; margin:var(--input-margin); } body div.input.float tr.img td:last-child>div>span { font-size:var(--action-height); } body div.input.float tr.img td:last-child>div>span.icon { display:none; } +// body div.input.float tr.img td:last-child>div>div>img { width:100% !important; height:100% !important; left:0 !important; top:0 !important;} +// body div.input.float tr.img td:last-child>div>div { position:relative; } +body div.input.float tr.img td:last-child>div { width:100% !important; justify-content:flex-start; } body div.input.float tr.icon td:last-child { position:relative; } -body div.input.float tr.icon td:last-child img:first-child { height:28px; width:28px; position:absolute; left:12px; top:12px; } +body div.input.float tr.icon:not(.img) td:last-child img:first-child { height:28px; width:28px; position:absolute; left:12px; top:12px; } body div.input.float tr.icon td:last-child input { padding-left:var(--action-height); } body div.input.float tr.icons td:last-child img { height:28px; width:28px; position:absolute; left:2px; top:2px; } body div.input.float tr.icons td:last-child span:not(.icon) { font-family:var(--code-font-family); position:absolute; left:33px; line-height:var(--action-height); } @@ -443,6 +446,9 @@ body div.input.float div.action { body.mobile { display:flex; } +fieldset.input.key>div.action { + display:none !important; +} body div.input.float div.action>div.item { margin-left:var(--button-margin); float:right; flex-grow:1; } body div.input.float div.action>div.item>input[type=button] { min-width:112px; width:100%; } body>div.input.login { flex-direction:column; } @@ -595,7 +601,7 @@ fieldset.panel.auto { background-color:var(--panel-bg-color); color:var(--panel- fieldset.panel.auto>div.output { background-color:var(--panel-bg-color); color:var(--panel-fg-color); } fieldset.panel.main>div.output { background-color:var(--action-output-bg-color); } fieldset:not(.panel) { background-color:var(--plugin-bg-color); color:var(--plugin-fg-color); } -fieldset.input div.output { background-color:var(--input-bg-color); } +fieldset.input>div.output { background-color:var(--input-bg-color); } fieldset.input div.output>table.content { border-collapse:collapse; } fieldset.input tr:hover { background-color:var(--tr-hover-bg-color); } fieldset.input td:hover { background-color:var(--td-hover-bg-color); } diff --git a/panel/header.js b/panel/header.js index 997c4f5f..316f6786 100644 --- a/panel/header.js +++ b/panel/header.js @@ -81,7 +81,8 @@ Volcanos(chat.ONACTION, {_init: function(can) {}, if (window.parent == window && can.misc.Search(can, ice.MSG_SESSID) && can.misc.CookieSessid(can, can.misc.Search(can, ice.MSG_SESSID)) && !can.user.isMailMaster) { return can.misc.Search(can, ice.MSG_SESSID, "") } can.user.info.sessid = can.misc.Search(can, ice.MSG_SESSID) - function lang(msg, cb) { can.user.info.language = msg.SearchOrOption(aaa.LANGUAGE)||msg.Option(ice.MSG_LANGUAGE) + function lang(msg, cb) { + can.user.info.language = msg.SearchOrOption(aaa.LANGUAGE)||msg.Option(ice.MSG_LANGUAGE) can.user.info.language? can.require([can.misc.Resource(can, nfs.SRC_TEMPLATE+web.CHAT_HEADER+"/language/"+can.user.info.language+".js")], cb, function(can, name, sub) { can.base.Copy(can.user._trans, sub._trans) }): cb && cb() can.onmotion.delay(can, function() { can.onimport._language(can) }) } diff --git a/plugin/input/img.js b/plugin/input/img.js index 6f86d3cb..eef04805 100644 --- a/plugin/input/img.js +++ b/plugin/input/img.js @@ -2,6 +2,7 @@ Volcanos(chat.ONFIGURE, {img: { _init: function(can, meta, target) { target.value == meta.value && (target.value = ""); var images = can.core.Split(target.value) var count = parseInt(meta.value||"1"), width = target.parentNode.offsetWidth; for (var n = 1; n < 10; n++) { if (n*n >= count) { width = (width/n-10); break } } // function add(target, hash) { target._hash = hash, can.page.Appends(can, target, [{img: can.base.MergeURL(can.misc.MergeURL(can, {_path: web.SHARE_CACHE+hash}, true), {pod: meta.space||undefined}), height: width, width: width}]) } + width = can.base.Max(width, 120) function add(target, hash) { target._hash = hash, can.page.Appends(can, target, [{img: hash, height: width, width: width}]) } function set() { target.value = can.page.SelectChild(can, target.parentNode, html.DIV, function(target) { return target._hash }).join(mdb.FS) } can.onmotion.hidden(can, target), can.onappend.style(can, html.FLEX, target.parentNode) diff --git a/plugin/input/key.js b/plugin/input/key.js index be132a11..98f58a2a 100644 --- a/plugin/input/key.js +++ b/plugin/input/key.js @@ -24,17 +24,6 @@ Volcanos(chat.ONFIGURE, {key: { } if (msg.Length() == 0 || msg.Length() == 1 && msg.Append(name) == target.value && target.value != "") { return can.onmotion.hidden(can) } if (can.base.isIn(msg.append[msg.append.length-1], ctx.ACTION, "cb")) { msg.append = msg.append.slice(0, -1) } var list = {} - can.onmotion.clear(can), can.onappend.table(can.sup, msg, function(value, key, index, item) { value = item[key] - if (msg.append.length == 1 && index < 100 && list[value]) { return } list[value] = true - return {text: [value, html.TD, [value == ""? html.HR: "", key]], style: msg.append && msg.append.length == 1? kit.Dict(html.MIN_WIDTH, target.offsetWidth-16): {}, onclick: function(event) { - can.onengine.signal(can, "onevent", can.request(event)) - can.close(); if (msg.cb && msg.cb[index]) { return msg.cb[index](value) } - var _cb = can.Conf("select"); if (_cb) { return _cb(target.value = value) } can.base.isFunc(cb) && cb(can, value, target.value) - }, _init: function(target) { - can.onappend.style(can, "i-"+index, target.parentNode) - // can.onappend.style(can, "s-"+can.base.replaceAll(item[name], "/", "_"), target.parentNode) - }} - }, can._output) can.showIcons = function(value, icons, title) { can.ui = can.ui||{} if (!can.ui.img) { can.ui.img = can.page.insertBefore(can, [{type: html.IMG}], target) @@ -46,6 +35,25 @@ Volcanos(chat.ONFIGURE, {key: { can.ui.img.src = can.misc.Resource(can, icons), can.ui.span.innerText = title||value target.value = value, can.onmotion.hidden(can, can._target) } + if (msg.Option("_display") && !can.base.beginWith(msg.Option("_display"), "/plugin/input/key.js") && !can.base.contains(msg.Option("_display"), "src/gonganxitong/common.js")) { + target._selectonly = true, can.ConfWidth(target.offsetWidth) + can.run = function(event, cmds, cb) { var list = msg["_input_args"]||msg.append, _msg = can.request(event) + can.showIcons(_msg.Option(list[0]), _msg.Option(list[2]||mdb.ICONS)||_msg.Option(mdb.ICONS)||_msg.Option(mdb.ICON)||_msg.Option("user_avatar"), _msg.Option(list[1])) + } + can.onappend._output(can, msg, msg.Option("_display")+",/plugin/table.js", function(msg) { can.layout(msg) }) + return + } + can.onmotion.clear(can), can.onappend.table(can.sup, msg, function(value, key, index, item) { value = item[key] + if (msg.append.length == 1 && index < 100 && list[value]) { return } list[value] = true + return {text: [value, html.TD, [value == ""? html.HR: "", key]], style: msg.append && msg.append.length == 1? kit.Dict(html.MIN_WIDTH, target.offsetWidth-16): {}, onclick: function(event) { + can.onengine.signal(can, "onevent", can.request(event)) + can.close(); if (msg.cb && msg.cb[index]) { return msg.cb[index](value) } + var _cb = can.Conf("select"); if (_cb) { return _cb(target.value = value) } can.base.isFunc(cb) && cb(can, value, target.value) + }, _init: function(target) { + can.onappend.style(can, "i-"+index, target.parentNode) + // can.onappend.style(can, "s-"+can.base.replaceAll(item[name], "/", "_"), target.parentNode) + }} + }, can._output) can.core.CallFunc([can.oninputs, "_show"], {event: event, can: can, msg: msg, target: target, name: name}) var display = msg.Option(ice.MSG_DISPLAY)? can.base.ParseURL(msg.Option(ice.MSG_DISPLAY)): {name: name} if (display.title && !msg[display.title]) { display.title = msg.append[1] } @@ -65,6 +73,7 @@ Volcanos(chat.ONFIGURE, {key: { meta.msg && meta.msg.Length() > 0? sub._show(sub, meta.msg, cb, target, meta.name): sub._load(event, sub, cb, target, meta.name, target.value) }) }, onblur: function(event, can, sub, cb, target) { + return if (target._hold) { return } if (target._selectonly) { return } // can.onengine.signal(can, "onevent", can.request(event, {query: can.page.getquery(can, target)+","+target.value})) diff --git a/plugin/table.js b/plugin/table.js index e0625f9c..cf557f1a 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -498,22 +498,25 @@ Volcanos(chat.ONIMPORT, { value.user_avatar && can.user.isMobile && can.page.Append(can, target, [{view: "place_info", _init: function(target) { _msg.action = [], _msg.PushButton("userInfo") if (can.base.endWith(can.ConfIndex(), ".member") && !_msg.Append("auth_name")) { _msg.action = [] } - can.onimport.itemcards(can, _msg, function(value) { return [ + can.onimport.itemcards(can, _msg, function(value) { value.icons = value.auth_avatar||value.user_avatar; return [ {view: html.TITLE, list: [value.user_name, can.onimport.authView(can, value), can.onimport.titleAction(can, value)]}, {view: html.STATUS, list: [value.uid.slice(0, 6), can.onimport.timeView(can, value)]}, ] }, function(event, value) { can.run(can.request(event, {uid: value.user_uid}), [ctx.ACTION, "userInfo"]) }, target) }}]) - } msg.Show(can) + } + can.onappend.table(can, msg) can.page.Select(can, target, html.TR, function(target) { target.className.indexOf("_uid") > -1 && can.page.ClassList.add(can, target, "hide") }) } else { + can.onappend.style(can, msg.Option(ctx.STYLE)) can.page.Append(can, target, msg.Table(function(value) { return can.onimport.itemcard(can, value, cb(value), cbs) - })), msg.Result() && can.onappend.board(can, msg), can.onappend.style(can, msg.Option(ctx.STYLE)) + })) } + msg.Result() && can.onappend.board(can, msg), can.onmotion.story.auto(can) can.page.Select(can, target, html.INPUT_BUTTON, function(target) { var style = can.Conf("_style."+target.name); style && can.page.ClassList.add(can, target, style) }) @@ -525,7 +528,7 @@ Volcanos(chat.ONIMPORT, { }) cb = cb|| function(event) { var done = false if (can.onaction.carddetail && can.onaction.carddetail(event, can, value)) { return } - if (value.uid) { return can.Option(UID, value.uid), can.Update() } + if (value.uid) { return can.Option(UID, value.uid), can.Update(can.request(event, value)) } can.core.Item(can.Option(), function(k, v) { if (!done && !v) { done = true, can.Option(k, value[k]), can.Update() } }) @@ -549,33 +552,38 @@ Volcanos(chat.ONIMPORT, { can.onmotion.select(can, event.currentTarget.parentNode, html.DIV_ITEM, event.currentTarget) }} }, - moneyView: function(can, value, key) { - return {text: ["¥ "+(value[key]||value.price||value.amount)+" 元", "", "price"]} + uidView: function(can, value) { return value.uid.slice(0, 6) }, + metaView: function(can, value) { + return {view: html.STATUS, list: [can.onimport.uidView(can, value), can.onimport.timeView(can, value), value.user_name]} + }, + shipView: function(can, value) { + return {view: html.STATUS, list: [value.city_name, value.city_name? "|": "", value.street_name, value.street_name? "|": "", value.service_name.replace(" ", " | ")]} + }, + spaceView: function(can, value) { + return {view: "space"} + }, + timeView: function(can, value, key) { + if (key) { return {text: [can.user.trans(can, key, null, html.INPUT)+": "+can.base.TimeTrim(value[key]), "", mdb.TIME]} } + return {text: [can.base.TimeTrim(value[key]||value.browse_time||value.updated_at||value.created_at||value.time), "", mdb.TIME]} + }, + unitView: function(can, value, key, unit) { if (!value[key] || value[key] == "0") { return } + return {text: [[can.user.trans(can, key, null, html.INPUT)+":", value[key]].concat(unit? [unit]: []).join(" "), "", key]} }, textView: function(can, value, key, type) { key || can.core.Item(value, function(k, v) { if (k == "status" || can.base.endWith(k, "_status")) { key = k } }); if (!type) { type = key.split("_").pop() } return value[key] && !can.base.isIn(value[key], "finish", "done") && {text: [can.user.transValue(can, value, key), "", [type, value[key], can.Conf("_trans.value."+key+".style."+value[key])||""]]} }, authView: function(can, value) { return can.base.isIn(value.auth_status, "issued", "2") && {view: [aaa.AUTH, html.SPAN], list: [{icon: "bi bi-patch-check-fill", style: {color: "var(--notice-bg-color)"}}]} }, - timeView: function(can, value, key) { - if (key) { return {text: [can.user.trans(can, key, null, html.INPUT)+": "+can.base.TimeTrim(value[key]), "", mdb.TIME]} } - return {text: [can.base.TimeTrim(value[key]||value.browse_time||value.updated_at||value.created_at||value.time), "", mdb.TIME]} - }, - uidView: function(can, value) { - return value.uid.slice(0, 6) - }, - unitView: function(can, value, key, unit) { if (!value[key] || value[key] == "0") { return } - return {text: [[can.user.trans(can, key, null, html.INPUT)+":", value[key]].concat(unit? [unit]: []).join(" "), "", key]} - }, + moneyView: function(can, value, key) { return {text: ["¥ "+(value[key]||value.price||value.amount)+" 元", "", "price"]} }, beginTime: function(can, value) { return (value.process_time||value.begin_time).split(" ")[0]+" ~ "+(value.finish_time||value.end_time).split(" ")[0] }, typeStyle: function(can, value, key) { return can.Conf("_trans.value."+key+".style."+value[key])||"" }, roleStyle: function(can, value, key) { return can.Conf("_trans.value."+key+".style."+value[key])||"" }, - shareTitle: function(can, msg, title, content, icons) { if (msg.IsDetail()) { var value = msg.TableDetail() - msg.Option("_share_title", msg.Option("_share_title")||(value[title]||value.title||value.name||value.uid).slice(0, 6)) - msg.Option("_share_content", msg.Option("_share_content")||value[content]||value.content||value.info) + shareTitle: function(can, msg, icons, title, content) { if (msg.IsDetail()) { var value = msg.TableDetail() msg.Option("_share_icons", msg.Option("_share_icons")||value[icons]||value.icons||value.avatar) + msg.Option("_share_title", msg.Option("_share_title")||(value[title]||value.title||value.name||value.uid.slice(0, 6))) + msg.Option("_share_content", msg.Option("_share_content")||value[content]||value.content||value.info) } }, titleAction: function(can, value, filter) { var filter = can.core.List(arguments).slice(2) return {view: html.ACTION, _init: function(target) { @@ -611,7 +619,7 @@ Volcanos(chat.ONEXPORT, { hash = typeof hash == code.STRING? hash.split(":").concat(can.core.List(arguments).slice(2)||[]): hash || can.core.Item(can.Option(), function(key, value) { return value||"" }) return can.sup.onexport.hash(can.sup, hash) }, - session: function(can, key, value) { return can.sup.onexport.session(can.sup, key, value) }, + session: function(can, key, value) { return can.sup && can.sup.onexport.session(can.sup, key, value) }, storage: function(can, key, value) { return can.sup.onexport.storage(can.sup, key, value) }, table: function(can) { var msg = can._msg; if (msg.Length() == 0) { return } var res = [msg.append && msg.append.join(mdb.FS)] msg.Table(function(line, index, array) { res.push(can.core.Item(line, function(key, value) { return value }).join(ice.FS)) }) @@ -679,7 +687,11 @@ Volcanos(chat.ONINPUTS, { _nameicon: function(event, can, msg, target, name, title) { name = name||mdb.NAME can.page.Appends(can, can._output, msg.Table(function(value) { var _title = can.user.trans(can.sup, value[title]||value[name]||value[mdb.NAME], null, "value."+name) - var icons = can.misc.ResourceIcons(can, can.sup.Conf("_trans.value."+name+".icons."+value[name])||can.sup.Conf("_trans.value."+name+".icons."+value[title])||value.icons||value.user_avatar) + var icons = can.misc.ResourceIcons(can, + value.icons||value.icon||value.user_avatar|| + can.sup.Conf("_trans.value."+name+".icons."+value[name])|| + can.sup.Conf("_trans.value."+name+".icons."+value[title]) + ) return {view: html.ITEM, list: [{img: can.misc.Resource(can, icons), }, {view: html.CONTAINER, list: [{view: [html.TITLE, "", _title]}, can.onappend.label(can, value, kit.Dict(