mirror of
https://github.com/v2rayA/v2rayA.git
synced 2026-11-20 23:02:25 +03:00
fix(gui): keep node fields intact on edit and hide the burger on desktop
- a shadowsocks userinfo arrives percent-escaped, and js-base64 decoded those escapes as data, so opening a node for editing rewrote its password; - the simple-obfs path is exported as obfs-uri, which the dialog did not read, so saving an edited node dropped it; - a plain trojan ws/h2 node lost its Host header, because the model never read the host parameter although the serializer writes it; - the plugin options were decoded twice, which turned %2F into a separator and threw on a literal percent sign; - the selection is remapped by what a row points at instead of its id, which a subscription update reassigns; - the burger set its display for every width, so a desktop window showed it next to the full menu.
This commit is contained in:
3 files changed
+40
-7
No files matched your search
+15
-2
@@ -855,9 +855,10 @@ html {
|
||||
}
|
||||
|
||||
// The burger is a Lucide glyph, not Bulma's three spans; centre it and give
|
||||
// it the navbar's text colour.
|
||||
// it the navbar's text colour. Keep Bulma's breakpoint: this block used to
|
||||
// set display unconditionally, which showed the burger next to the full menu
|
||||
// on a desktop screen.
|
||||
.navbar-burger {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: inherit;
|
||||
@@ -868,6 +869,18 @@ html {
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1023px) {
|
||||
.navbar-burger {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1024px) {
|
||||
.navbar-burger {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
// Bulma pins .modal-close to the top-right of the viewport, far from the
|
||||
// card it closes. Put it on the card instead, at every width; the card is
|
||||
// position: relative so the button lands on its corner.
|
||||
|
||||
@@ -1363,6 +1363,14 @@ export default {
|
||||
} else if (url.toLowerCase().startsWith("ss://")) {
|
||||
let u = parseURL(url);
|
||||
let userinfo = u.username;
|
||||
// The backend percent-escapes the base64 userinfo ("=" becomes %3D),
|
||||
// and js-base64 decodes those escapes as data, which corrupted the
|
||||
// password of every shadowsocks node opened for editing.
|
||||
try {
|
||||
userinfo = decodeURIComponent(userinfo);
|
||||
} catch (_) {
|
||||
// a literal "%" in the userinfo: use it as it came
|
||||
}
|
||||
// Handle SIP002 format: ss://BASE64URL@host:port vs legacy ss://BASE64
|
||||
let method = "", password = "";
|
||||
try {
|
||||
@@ -1375,7 +1383,9 @@ export default {
|
||||
} catch (e) {
|
||||
method = userinfo;
|
||||
}
|
||||
const ssPlugin = decodeURIComponent(u.params.plugin || "");
|
||||
// parseURL already decoded the query values; decoding again turns
|
||||
// %2F into a path separator and throws on a literal percent sign
|
||||
const ssPlugin = u.params.plugin || "";
|
||||
const opts = ssPlugin.split(";");
|
||||
let o = {
|
||||
method: method,
|
||||
@@ -1413,6 +1423,7 @@ export default {
|
||||
break;
|
||||
case "path":
|
||||
case "obfs-path":
|
||||
case "obfs-uri":
|
||||
o.path = v;
|
||||
break;
|
||||
case "mode":
|
||||
@@ -1471,6 +1482,7 @@ export default {
|
||||
verifyPeerCertByName: u.params.verifyPeerCertByName || "",
|
||||
method: "origin",
|
||||
net: u.params.type || "tcp",
|
||||
host: u.params.host || "",
|
||||
obfs: "none",
|
||||
ssCipher: "2022-blake3-aes-128-gcm",
|
||||
path: u.params.path || u.params.serviceName || "",
|
||||
@@ -1791,7 +1803,7 @@ export default {
|
||||
plugin.push("obfs=" + srcObj.obfs);
|
||||
plugin.push("obfs-host=" + srcObj.host);
|
||||
if (srcObj.obfs === "http") {
|
||||
plugin.push("obfs-path=" + srcObj.path);
|
||||
plugin.push("obfs-uri=" + srcObj.path);
|
||||
}
|
||||
if (srcObj.impl) {
|
||||
plugin.push("impl=" + srcObj.impl);
|
||||
|
||||
+11
-3
@@ -1025,15 +1025,23 @@ export default {
|
||||
});
|
||||
// re-point the selection at the replacement row objects so a refresh
|
||||
// neither drops the user's selection nor leaves stale rows behind
|
||||
// identify a row by what it points at, not by its position: a
|
||||
// subscription update reorders nodes and reuses the ids, so an
|
||||
// id-based key would move the selection onto a different server
|
||||
const keyOf = (data, row) => {
|
||||
const sub = data.subscriptions.findIndex((s) => s.servers.includes(row));
|
||||
return `${row._type}|${sub}|${row.id}`;
|
||||
return `${row._type}|${sub}|${row.address}|${row.name}|${row.net}`;
|
||||
};
|
||||
const selected = this.checkedRows.map((x) => keyOf(this.tableData, x));
|
||||
this.tableData = touch;
|
||||
const byKey = new Map();
|
||||
touch.servers.forEach((v) => byKey.set(keyOf(touch, v), v));
|
||||
touch.subscriptions.forEach((s) => s.servers.forEach((v) => byKey.set(keyOf(touch, v), v)));
|
||||
const remember = (v) => {
|
||||
const k = keyOf(touch, v);
|
||||
// two identical rows: keep the first, so the selection cannot jump
|
||||
if (!byKey.has(k)) byKey.set(k, v);
|
||||
};
|
||||
touch.servers.forEach(remember);
|
||||
touch.subscriptions.forEach((s) => s.servers.forEach(remember));
|
||||
this.checkedRows = selected.map((k) => byKey.get(k)).filter(Boolean);
|
||||
if (running !== undefined) {
|
||||
Object.assign(this.runningState, {
|
||||
|
||||
Reference in new issue
Block a user