From 6a46ee498324e42ce75d4ae5e6ba3c0adfb7e34e Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 19 Apr 2024 21:45:11 +0800 Subject: [PATCH] add some --- const.js | 4 ++- frame.js | 6 ++-- index.css | 13 +++++---- lib/user.js | 77 +++++++++++++++++++++++++------------------------ panel/header.js | 1 + 5 files changed, 54 insertions(+), 47 deletions(-) diff --git a/const.js b/const.js index a9a8b18c..e77850af 100644 --- a/const.js +++ b/const.js @@ -334,7 +334,8 @@ var html = {value: { PLUGIN_PADDING: 0, PLUGIN_MARGIN: 0, HEADER_HEIGHT: 48, ACTION_HEIGHT: 32, STATUS_HEIGHT: 32, - CARD_WIDTH: 280, CARD_HEIGHT: 160, QRCODE_WIDTH: 360, + QRCODE_HEIGHT: 363, QRCODE_WIDTH: 360, + CARD_HEIGHT: 160, CARD_WIDTH: 280, STORY_HEIGHT: 480, PLUG_HEIGHT: 480, PLUG_WIDTH: 800, DESKTOP_HEIGHT: 684, DESKTOP_WIDTH: 1200, @@ -345,6 +346,7 @@ var html = {value: { ORDER_SHOW_LIMIT: 30, ORDER_SHOW_DELAY: 150, CODE_FONT_SIZE: 14, CODE_LINE_HEIGHT: 20, }, + STORY: "story", FIELDSET: "fieldset", LEGEND: "legend", OPTION: "option", ACTION: "action", OUTPUT: "output", STATUS: "status", OPTION_ARGS: "select.args,input.args,textarea.args", INPUT_ARGS: "input.args,textarea.args", INPUT_BUTTON: "input[type=button]", INPUT_FILE: "input[type=file]", FORM_OPTION: "form.option", DIV_ACTION: "div.action", DIV_OUTPUT: "div.output", DIV_STATUS: "div.status", diff --git a/frame.js b/frame.js index c0525b48..88a13548 100644 --- a/frame.js +++ b/frame.js @@ -392,14 +392,14 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { field: function(can, type, item, target) { type = type||html.STORY, item = item||{} var name = can.core.Split(item.nick||item.index||"", " .").pop()||""; can.base.isIn(name, - tcp.SERVER, tcp.CLIENT, web.STUDIO, mdb.SEARCH, web.SERVICE, can.core.Split(can.ConfIndex(), ".").pop(), "launchTemplate", - ) && (name = (item.index||"").split(".").slice(-2).join(".")), (type != "story" && type != html.PLUG && !can.base.isIn(can.ConfIndex(), + tcp.SERVER, tcp.CLIENT, web.STUDIO, mdb.SEARCH, web.SERVICE, can.core.Split(can.ConfIndex(), lex.PT).pop(), "launchTemplate", + ) && (name = (item.index||"").split(lex.PT).slice(-2).join(lex.PT)), (type != html.STORY && type != html.PLUG && !can.base.isIn(can.ConfIndex(), web.DESKTOP, web.MESSAGE, web.VIMER, )) && (name = can.core.Keys(item.space||item._space, name)) var title = item.title || can.user.isMobile && (can.user.isEnglish(can)? name: (item.help||name)) || (!item.help || name == item.help || can.user.isEnglish(can)? name: name+"("+can.core.Split(item.help)[0]+")") target = can.base.isFunc(target)? target(): target return can.page.Append(can, target||can._output, [{view: [type, html.FIELDSET], style: item.style, list: [{type: html.LEGEND, list: [ - item.icons && {img: can.misc.Resource(can, (item.icons.indexOf("/") == -1? "usr/icons/": "")+item.icons, item.space||item._space)}, + item.icons && {img: can.misc.Resource(can, (item.icons.indexOf(nfs.PS) == -1? nfs.USR_ICONS: "")+item.icons, item.space||item._space)}, item.icon && {icon: item.icon}, {text: title}, ]}, {view: [html.OPTION, html.FORM]}, html.ACTION, html.OUTPUT, html.STATUS]}]) }, diff --git a/index.css b/index.css index 10d5e758..00b9bbd5 100644 --- a/index.css +++ b/index.css @@ -52,7 +52,7 @@ body { --header-height:48px; --footer-height:var(--action-height); --action-height:32px; --status-height:var(--action-height); --textarea-height:96px; --input-width:140px; --button-width:60px; --form-width:360px; --url-input-width:480px; - --card-width:300px; --card-height:160px; --qrcode-width:360px; --qrcode-height:364px; + --card-width:300px; --card-height:160px; --qrcode-width:360px; --qrcode-height:363px; --story-height:var(--float-height); --iframe-height:420px; --plug-height:var(--float-height); --plug-width:var(--float-width); --desktop-height:684px; --desktop-width:var(--float-width); @@ -70,7 +70,7 @@ body { } body.web.code.vimer.cmd { --code-line-height:24px; } body.en { --card-button:3; } -body.mobile { --footer-height:60px; --qrcode-height:284px; --svg-font-size:13px; } +body.mobile { --footer-height:60px; --svg-font-size:13px; } body.width1 { /* 320-640 手机竖屏 */ --project-width:120px; --river-width:280px; --input-width:80px; --url-input-width:160px; --form-width:290px; --river-margin:0; --plugin-margin:0; --legend-margin:5px; --button-margin:5px; @@ -318,6 +318,7 @@ body>div.input input[name=submit] { border:var(--box-notice); } body>div.input input[name=submit]:hover { background-color:var(--notice-bg-color); color:var(--notice-fg-color); } body>div.input input[name=cancel]:hover { background-color:var(--danger-bg-color); color:var(--danger-fg-color); } body>div.input div.action { padding:var(--table-padding); width:100%; position:sticky; bottom:0; flex-direction:row-reverse; } +body>div.input.login div.action { padding:0; } body>div.input div.action>div.item { margin-left:var(--button-margin); float:right; } body>div.input div.action>div.item>input[type=button] { width:112px; } body>div.input.login { flex-direction:column; } @@ -598,7 +599,7 @@ div.item.text.url>input { width:var(--river-width); } div.item.text.line>input { width:80px; } div.item.text.limit>input { width:var(--button-width); } div.item.text.offend>input { width:var(--button-width); } -body:not(.width2) fieldset.plugin>form.option>div.item.text.path>input { width:var(--project-width); } +body:not(.width2):not(.mobile) fieldset.plugin>form.option>div.item.text.path>input { width:var(--project-width); } body:not(.width2) fieldset.plugin>div.action>div.item.text.filter>input { width:var(--input-width); transition:all 1.2s; } body:not(.width2) fieldset.plugin>div.action>div.item.text.filter>input:focus { width:var(--project-width); transition:all 0.5s; } div.item.text.will>input { border:var(--box-notice); } @@ -712,7 +713,7 @@ body.mobile fieldset.Search>div.action>div.item.filter>span { position:absolute; body.mobile fieldset.Search>div.action>div.item.filter { width:100%; position:relative; } body.mobile fieldset.River { position:fixed; top:var(--header-height); z-index:11; } body.mobile fieldset.River>div.output { font-size:1.4rem; min-width:var(--project-width); } -html:not(.login) body.mobile:not(.cmd) fieldset.Action { margin-top:var(--header-height); } +body.mobile:not(.cmd) fieldset.Action { margin-top:var(--header-height); } body.mobile fieldset.Action.cmd { margin-top:0; } body.mobile fieldset.Action { overflow:hidden; } body.mobile fieldset.Action>div.output { overflow-x:hidden; } @@ -729,7 +730,7 @@ body.mobile.landscape fieldset.Action { margin-top:0; } body.mobile.landscape>div.input.login { padding:0; } body.mobile.landscape>div.input.login>div.output { height:290px; } body.mobile.landscape>div.input.login>div.output img { max-height:280px; } -body.mobile.login>fieldset.panel.Action>div.output { background-color:var(--panel-output-bg-color); } +html.login body.mobile>fieldset.panel.Action>div.output { background-color:var(--panel-bg-color); } /* print */ body.print { -webkit-filter: grayscale(100%); } body.print { background-color:white; color:black; } @@ -864,7 +865,7 @@ fieldset.Search>div.output>div.profile { border-left:none; width:unset; } fieldset.Search>div.output>div.content>table.content td { cursor:pointer; } fieldset.Action.tabs table.content { width:100%; } fieldset.Action>div.output>fieldset.plugin:not(.float):not(.full):not(.cmd) { padding:var(--plugin-padding); margin:var(--plugin-margin); } -fieldset.Action>div.output>fieldset.plugin:not(.float):not(.full):not(.cmd)>legend { float:none; } +fieldset.Action>div.output>fieldset.plugin:not(.float):not(.full):not(.cmd)>legend { background-color:var(--plugin-bg-color); float:none; } body.mobile fieldset.float:not(.full):not(.cmd)>legend { float:none; } body.width6 fieldset.plugin.word>form.option>div.item.text>input { width:var(--project-width); } body.width6 fieldset.plugin.iframe>form.option input[name=hash] { width:var(--form-width); } diff --git a/lib/user.js b/lib/user.js index 01aada2d..cb74de6b 100644 --- a/lib/user.js +++ b/lib/user.js @@ -275,46 +275,49 @@ Volcanos("user", { }), resize: html.IMG, }) }, login: function(can, _cb, _msg) { - can.page.ClassList.add(can, document.body.parentNode, aaa.LOGIN), can.onimport.theme(can), can.misc.CookieSessid(can, "") - var ui - var socket = can.ondaemon._init(can, "", aaa.LOGIN, function(event, msg, cmd, arg, cb) { - function check() { - if (can.misc.CookieSessid(can)) { can.page.ClassList.del(can, document.body.parentNode, aaa.LOGIN) - can.onmotion.clearFloat(can), can.onmotion.delay(can, function() { socket._close = true, socket.close() }) - return can.base.isFunc(_cb) && _cb(), _cb = null, true - } can.core.Timer(1000, function() { check() }), can.onimport.theme(can) - } - if (cmd == cli.PWD) { if (check() || ui) { return } can.page.ClassList.add(can, document.body, aaa.LOGIN), can._wss_name = can.ondaemon._list[0] = arg[0] - var _list = [], list = {}; _msg.Table(function(value) { if (value.order == "") {} else if (value.type == mdb.PLUGIN) { + can.misc.CookieSessid(can, ""), can.page.ClassList.add(can, document.body.parentNode, aaa.LOGIN), can.onimport.theme(can) + function check() { + if (can.misc.CookieSessid(can) || can.user.info.sessid) { can.page.ClassList.del(can, document.body.parentNode, aaa.LOGIN), can.onimport.theme(can) + can.onmotion.clearFloat(can), can.onmotion.delay(can, function() { socket._close = true, socket.close() }) + return can.base.isFunc(_cb) && _cb(), _cb = null, true + } can.core.Timer(1000, function() { check() }) + } + var ui, socket = can.ondaemon._init(can, "", aaa.LOGIN, function(event, msg, cmd, arg) { + if (cmd == ice.MSG_SESSID) { + if (!can.misc.CookieSessid(can, arg[0])) { can.user.info.sessid = arg[0] } check() + } else if (cmd == cli.PWD) { if (check() || ui) { return } can._wss_name = can.ondaemon._list[0] = arg[0] + var _list = [], list = {}; _msg.Table(function(value) { if (!value.order) { return } can.user.trans(can, kit.Dict(value.name, value.help)) - _list.push(value.name), list[value.name] = function(target) { - can.onappend.plugin(can, {space: value.space, index: value.index, args: can.core.Split(value.args), style: html.OUTPUT}, function(sub) { - var run = sub.run; sub.run = function(event, cmds, cb) { var msg = can.request(event, {space: arg[0]}); can.page.exportValue(can, msg), run(event, cmds, cb) } - sub.onexport.output = function() { can.page.style(can, sub._output, html.MAX_HEIGHT, ""), can.page.style(can, sub._output, html.MAX_WIDTH, "") } - }, ui.output) - } } else if (value.type == cli.QRCODE) { - can.user.trans(can, kit.Dict(value.name, value.help)) - _list.push(value.name), list[value.name] = function(target) { can.page.Modify(can, target, arg[2]) } } }) - ui = can.onappend.tabview(can, list, _list, can.page.Append(can, document.body, [{view: "input login float flex"}])._target) - if (window.parent != window && window.innerHeight < 480) { can.onmotion.hidden(can, ui.output) } - var _cmd = "space login "+arg[0]; ui.display = can.page.Append(can, ui._target, [html.DISPLAY])._target, can.onappend.style(can, html.FLEX, ui.display) - can.page.Appends(can, ui.display, [{text: [ - can.user.trans(can, "or command login", "或命令行授权: "), html.LABEL]}, {text: ["$ "+_cmd, "", html.ITEM], title: "点击复制,并后台执行此命令,即可登录", style: {cursor: "copy"}, onclick: function() { can.user.copy(event, can, _cmd) }}]) - var referrer - can.page.style(can, can._root.Action._output, html.HEIGHT, can.page.height()) - can.page.Append(can, ui.display, [{text: [ - can.user.trans(can, "or oauth login", "或第三方授权: "), html.LABEL]}, {view: [["sso", html.FLEX]], list: _msg.Table(function(value) { - return value.type == "oauth" && {view: [[html.ITEM, html.FLEX]], title: "点击跳转,授权登录", list: [{img: can.misc.Resource(can, value.icons)}, {text: value.name}], onclick: function() { - can.user.jumps(can.base.MergeURL(value.link, ice.BACK, location.href)) - }, _init: function(target) { - if (!referrer && document.referrer) { var u = new URL(document.referrer); referrer = true - value.link.indexOf(u.origin) == 0 && can.onmotion.delay(can, function() { target.click() }, 300) + if (value.type == cli.QRCODE) { + _list.push(value.name), list[value.name] = function(target) { can.page.Modify(can, target, arg[2]) } + } else if (value.type == mdb.PLUGIN) { + _list.push(value.name), list[value.name] = function(target) { + can.onappend.plugin(can, {space: value.space, index: value.index, args: can.core.Split(value.args), height: html.QRCODE_HEIGHT, width: 420, style: html.OUTPUT}, function(sub) { + var run = sub.run; sub.run = function(event, cmds, cb) { var msg = can.request(event, {space: arg[0]}); can.page.exportValue(can, msg), run(event, cmds, cb) } + }, ui.output) } - }} - }) }]) + } + }) + var _cmd = "space login "+arg[0] + ui = can.onappend.tabview(can, list, _list, can.page.Append(can, document.body, [{view: "input login float flex"}])._target) + can.page.Append(can, ui._target, [{view: [[html.DISPLAY, html.FLEX]], list: [ + {text: [can.user.trans(can, "or command login", "或命令行授权: "), html.LABEL]}, + {text: ["$ "+_cmd, "", html.ITEM], title: "点击复制,并后台执行此命令,即可登录", style: {cursor: "copy"}, onclick: function() { can.user.copy(event, can, _cmd) }}, + {text: [can.user.trans(can, "or oauth login", "或第三方授权: "), html.LABEL]}, + {view: [["sso", html.FLEX]], list: _msg.Table(function(value) { + return value.type == "oauth" && {view: [[html.ITEM, html.FLEX]], title: "点击跳转,授权登录", list: [ + {img: can.misc.Resource(can, value.icons)}, {text: value.name}, + ], onclick: function() { + can.user.jumps(can.base.MergeURL(value.link, ice.BACK, location.href)) + }, _init: function(target) { + if (document.referrer) { var u = new URL(document.referrer) + value.link.indexOf(u.origin) == 0 && can.onmotion.delay(can, function() { target.click() }, 300) + } + }} + }) }, + ]}]), window.parent != window && window.innerHeight < 480 && can.onmotion.hidden(can, ui.output) can.page.style(can, ui._target, {left: (can.page.width()-ui._target.offsetWidth)/2, top: can.page.height() < 640? (can.page.height()-ui._target.offsetHeight)/2: (can.page.height()-ui._target.offsetHeight-html.HEADER_HEIGHT-html.ACTION_HEIGHT)/4+html.HEADER_HEIGHT}) - cb && cb(); return true - } else if (cmd == ice.MSG_SESSID) { if (!can.misc.CookieSessid(can, arg[0])) { can.user.info.sessid = arg[0] } check(), cb && cb(); return true } + } }) }, logout: function(can) { can.user.toastConfirm(can, aaa.LOGOUT, "", function() { can.runAction({}, aaa.LOGOUT, [], function(msg) { diff --git a/panel/header.js b/panel/header.js index 8d4e5d4f..1c77d3c7 100644 --- a/panel/header.js +++ b/panel/header.js @@ -105,6 +105,7 @@ Volcanos(chat.ONACTION, {_init: function(can) {}, var tool = can._root.Action._conf.tool if (can.Conf(aaa.USERNICK, (msg.Option(aaa.USERNICK)||msg.Option(ice.MSG_USERNICK)||msg.Option(ice.MSG_USERNAME)).slice(0, 8)) || can.misc.Search(can, web.SHARE) || tool && can.base.isIn(tool[0]._command, web.PORTAL, aaa.OFFER, aaa.APPLY)) { return show(msg) } + can.onlayout._init(can) can.user.login(can, function() { can.onengine.signal(can, chat.ONMAIN, msg) }, msg) }) })