From c5f08a07a1d37f7316f1eaecc70d7e71850a278a Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 18 Aug 2023 17:37:01 +0800 Subject: [PATCH] add some --- lib/misc.js | 2 +- plugin/state.js | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/misc.js b/lib/misc.js index b614e298..6d3c8e87 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -87,7 +87,7 @@ Volcanos("misc", { }, POST: function(can, msg, url, form, cb, cbs) { var xhr = new XMLHttpRequest(), begin = new Date(); msg._xhr = xhr var data = can.core.ItemForm(form, function(v, i, k) { return k+mdb.EQ+encodeURIComponent(v) }).join("&") - if (msg._method == web.GET) { url += (url.indexOf("?") == -1? "?": "&")+data, data = "" } + if (can.base.isIn(msg._method, web.GET, web.DELETE)) { url += (url.indexOf("?") == -1? "?": "&")+data, data = "" } xhr.open(msg._method||web.POST, url), xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return } try { var res = JSON.parse(xhr.responseText) } catch (e) { var res = {result: [xhr.responseText]} } msg.Option("_cost", new Date() - begin) if (xhr.status == 200) { return msg.detail || (msg.detail = res.detail), can.base.isFunc(cb) && cb(msg.Copy(res)) } diff --git a/plugin/state.js b/plugin/state.js index 67cd8f1f..d74ffa01 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -4,10 +4,7 @@ Volcanos(chat.ONIMPORT, { }, _location: function(can, msg, arg) { can.user.jumps(arg) }, _replace: function(can, msg, arg) { location.replace(arg) }, - _history: function(can, msg) { - var what = history.back() - what || can.user.close() - }, + _history: function(can, msg) { history.length == 1? can.user.close(): history.back() }, _confirm: function(can, msg, arg) { can.user.toastConfirm(can, arg, "", function() { can.runAction(can.request({}, msg), "confirm") }) }, _refresh: function(can, msg, arg) { can.core.Timer(parseInt(arg||"30"), function() { can.Update(can.request({}, {_count: parseInt(msg.Option("_count")||"3")-1})) }) }, _rewrite: function(can, msg) { var arg = msg._arg; for (var i = 0; i < arg.length; i += 2) { can.Option(arg[i], arg[i+1]), can.Action(arg[i], arg[i+1]) } can.Update() },