修复Nebula APP.JS
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
const theme = window.NEBULA_THEME || {};
|
const theme = window.NEBULA_THEME || {};
|
||||||
const app = document.getElementById('app');
|
const app = document.getElementById('app');
|
||||||
const loader = document.getElementById('nebula-loader');
|
let loader = document.getElementById('nebula-loader');
|
||||||
const themeMediaQuery = getThemeMediaQuery();
|
const themeMediaQuery = getThemeMediaQuery();
|
||||||
|
|
||||||
if (!app) {
|
if (!app) {
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (state.authToken) {
|
if (state.authToken) {
|
||||||
var loaded = await loadDashboard();
|
const loaded = await loadDashboard();
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
state.loading = false;
|
state.loading = false;
|
||||||
}
|
}
|
||||||
@@ -652,40 +652,64 @@
|
|||||||
|
|
||||||
function findNodeLinkByName(links, name) {
|
function findNodeLinkByName(links, name) {
|
||||||
if (!name) return null;
|
if (!name) return null;
|
||||||
var target = name.trim();
|
const target = name.trim();
|
||||||
|
const targetLower = target.toLowerCase();
|
||||||
|
|
||||||
console.log("Nebula: Searching for node '" + name + "' among " + links.length + " links (Strict Match)");
|
console.log('Nebula: Searching for node \'' + name + '\' among ' + links.length + ' links');
|
||||||
|
|
||||||
for (var i = 0; i < links.length; i++) {
|
let fuzzyMatch = null;
|
||||||
var link = links[i].trim();
|
|
||||||
var remark = "";
|
|
||||||
|
|
||||||
if (link.indexOf("#") !== -1) {
|
for (let i = 0; i < links.length; i++) {
|
||||||
var parts = link.split("#");
|
const link = links[i].trim();
|
||||||
var rawRemark = parts[parts.length - 1];
|
let remark = '';
|
||||||
|
|
||||||
|
if (link.indexOf('#') !== -1) {
|
||||||
|
const parts = link.split('#');
|
||||||
|
const rawRemark = parts[parts.length - 1];
|
||||||
try {
|
try {
|
||||||
remark = decodeURIComponent(rawRemark.replace(/\+/g, "%20"));
|
remark = decodeURIComponent(rawRemark.replace(/\+/g, '%20'));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
remark = rawRemark;
|
remark = rawRemark;
|
||||||
}
|
}
|
||||||
} else if (link.indexOf("vmess://") === 0) {
|
} else if (link.indexOf('vmess://') === 0) {
|
||||||
try {
|
try {
|
||||||
var jsonStr = utf8Base64Decode(link.slice(8));
|
const jsonStr = utf8Base64Decode(link.slice(8));
|
||||||
var json = JSON.parse(jsonStr);
|
const json = JSON.parse(jsonStr);
|
||||||
remark = json.ps || "";
|
remark = json.ps || '';
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
} else if (link.indexOf("name:") !== -1) {
|
} else if (link.indexOf('name:') !== -1) {
|
||||||
var yamlMatch = link.match(/name:\s*["']?([^"']+)["']?/);
|
const yamlMatch = link.match(/name:\s*["']?([^"']+)["']?/);
|
||||||
if (yamlMatch) remark = yamlMatch[1];
|
if (yamlMatch) remark = yamlMatch[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strict exact match after trimming
|
const normalizedRemark = (remark || '').trim();
|
||||||
if ((remark || "").trim() === target) {
|
const normalizedLower = normalizedRemark.toLowerCase();
|
||||||
|
|
||||||
|
// Exact match
|
||||||
|
if (normalizedRemark === target) {
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Case-insensitive match as candidate
|
||||||
|
if (!fuzzyMatch && normalizedLower === targetLower) {
|
||||||
|
fuzzyMatch = link;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If one contains the other (very common with emojis or plan prefixes)
|
||||||
|
if (!fuzzyMatch && (normalizedLower.indexOf(targetLower) !== -1 || targetLower.indexOf(normalizedLower) !== -1)) {
|
||||||
|
// Only use this if it's a "strong" enough match (at least 50% length overlap)
|
||||||
|
if (Math.abs(normalizedLower.length - targetLower.length) < Math.max(normalizedLower.length, targetLower.length) * 0.4) {
|
||||||
|
fuzzyMatch = link;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.warn("Nebula: No exact match found for node '" + name + "'");
|
if (fuzzyMatch) {
|
||||||
|
console.log('Nebula: Using fuzzy match for node \'' + name + '\'');
|
||||||
|
return fuzzyMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.warn('Nebula: No match found for node \'' + name + '\'');
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2635,13 +2659,42 @@
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navigator.clipboard.writeText(value).then(function () {
|
|
||||||
showMessage(successMessage || "内容已复制到剪贴板", "success");
|
const resolve = () => {
|
||||||
|
showMessage(successMessage || '内容已复制到剪贴板', 'success');
|
||||||
render();
|
render();
|
||||||
}).catch(function () {
|
};
|
||||||
showMessage("复制失败,请尝试手动复制", "error");
|
|
||||||
|
const reject = () => {
|
||||||
|
showMessage('复制失败,请尝试手动复制', 'error');
|
||||||
render();
|
render();
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
navigator.clipboard.writeText(value).then(resolve).catch(reject);
|
||||||
|
} else {
|
||||||
|
// Fallback for non-secure contexts or unsupported browsers
|
||||||
|
try {
|
||||||
|
const textArea = document.createElement('textarea');
|
||||||
|
textArea.value = value;
|
||||||
|
textArea.style.position = 'fixed';
|
||||||
|
textArea.style.left = '-9999px';
|
||||||
|
textArea.style.top = '0';
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
textArea.focus();
|
||||||
|
textArea.select();
|
||||||
|
const successful = document.execCommand('copy');
|
||||||
|
document.body.removeChild(textArea);
|
||||||
|
if (successful) {
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Fallback copy failed', err);
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTraffic(value) {
|
function formatTraffic(value) {
|
||||||
|
|||||||
Reference in New Issue
Block a user