fix: 黄豆按站点方式保持登录并自动切换播放线路
This commit is contained in:
+3
-62
@@ -100,7 +100,6 @@ const ACCOUNTS_KEY = "rapt-accounts";
|
||||
const PLATFORM_KEY = "rapt-platform";
|
||||
const DRAMABOX_LANG_KEY = "dramabox-language";
|
||||
const HUANGDOU_HOST_KEY = "huangdou-host";
|
||||
const HUANGDOU_LINE_KEY = "huangdou-line";
|
||||
const HUANGDOU_ACCOUNTS_KEY = "huangdou-accounts";
|
||||
const HUANGDOU_REMEMBER_KEY = "huangdou-remember";
|
||||
const DRAMABOX_DEVICE_KEY = "dramabox-device";
|
||||
@@ -130,9 +129,6 @@ const platformLabel = computed(() => {
|
||||
});
|
||||
const dramaboxLang = ref("th");
|
||||
const huangdouHost = ref(readHuangdouHost());
|
||||
const huangdouLine = ref(readHuangdouLine());
|
||||
const huangdouLines = ref<{ name: string; label: string }[]>([]);
|
||||
const huangdouLinesBusy = ref(false);
|
||||
const huangdouUser = ref("");
|
||||
const huangdouPassword = ref("");
|
||||
const huangdouRemember = ref(readHuangdouRemember());
|
||||
@@ -267,14 +263,6 @@ function readHuangdouRemember() {
|
||||
}
|
||||
}
|
||||
|
||||
function readHuangdouLine() {
|
||||
try {
|
||||
return localStorage.getItem(HUANGDOU_LINE_KEY) || "";
|
||||
} catch {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function readHuangdouHost() {
|
||||
try {
|
||||
const value = localStorage.getItem(HUANGDOU_HOST_KEY) || "";
|
||||
@@ -304,41 +292,7 @@ function selectPlatform(key: string) {
|
||||
void loadDramaboxLanguages();
|
||||
void loadDevices();
|
||||
}
|
||||
if (key === "huangdou") {
|
||||
void sendHuangdouFingerprint();
|
||||
void loadHuangdouLines();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadHuangdouLines() {
|
||||
huangdouLinesBusy.value = true;
|
||||
try {
|
||||
const host = huangdouHost.value.trim() || "https://pmihlvee.cc";
|
||||
const response = await fetch("/api/huangdou/lines", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ host }),
|
||||
});
|
||||
const payload = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
throw new Error(typeof payload.detail === "string" ? payload.detail : "没有读到线路");
|
||||
}
|
||||
const rows = Array.isArray(payload.lines) ? payload.lines : [];
|
||||
huangdouLines.value = rows
|
||||
.map((item: { name?: string; label?: string }) => ({
|
||||
name: String(item?.name || "").trim(),
|
||||
label: String(item?.label || item?.name || "").trim(),
|
||||
}))
|
||||
.filter((item: { name: string }) => item.name);
|
||||
if (!huangdouLines.value.some((item) => item.name === huangdouLine.value)) {
|
||||
huangdouLine.value = huangdouLines.value[0]?.name || "";
|
||||
}
|
||||
} catch (exc) {
|
||||
huangdouLines.value = [];
|
||||
error.value = exc instanceof Error ? exc.message : "没有读到线路";
|
||||
} finally {
|
||||
huangdouLinesBusy.value = false;
|
||||
}
|
||||
if (key === "huangdou") void sendHuangdouFingerprint();
|
||||
}
|
||||
|
||||
function tokenKey() {
|
||||
@@ -1062,13 +1016,11 @@ async function loginHuangdou(asGuest = false) {
|
||||
const host = huangdouHost.value.trim() || "https://pmihlvee.cc";
|
||||
huangdouHost.value = host;
|
||||
localStorage.setItem(HUANGDOU_HOST_KEY, host);
|
||||
localStorage.setItem(HUANGDOU_LINE_KEY, huangdouLine.value);
|
||||
const response = await fetch("/api/huangdou/login", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
host,
|
||||
line: huangdouLine.value,
|
||||
username: asGuest ? "" : huangdouUser.value.trim(),
|
||||
password: asGuest ? "" : huangdouPassword.value,
|
||||
}),
|
||||
@@ -1363,10 +1315,7 @@ onMounted(async () => {
|
||||
await loadDramaboxLanguages();
|
||||
void loadDevices();
|
||||
}
|
||||
if (platform.value === "huangdou") {
|
||||
void sendHuangdouFingerprint();
|
||||
void loadHuangdouLines();
|
||||
}
|
||||
if (platform.value === "huangdou") void sendHuangdouFingerprint();
|
||||
let saved = readSavedToken();
|
||||
if (!saved && isolated.value) {
|
||||
try {
|
||||
@@ -1584,15 +1533,7 @@ onUnmounted(stopLive);
|
||||
<n-form label-placement="left" label-width="96" size="small" :show-feedback="false" @submit.prevent="login">
|
||||
<template v-if="platform === 'huangdou'">
|
||||
<n-form-item label="域名">
|
||||
<n-input v-model:value="huangdouHost" placeholder="https://pmihlvee.cc" @blur="loadHuangdouLines" />
|
||||
</n-form-item>
|
||||
<n-form-item label="线路">
|
||||
<n-select
|
||||
v-model:value="huangdouLine"
|
||||
:options="huangdouLines.map((item) => ({ label: item.label, value: item.name }))"
|
||||
:loading="huangdouLinesBusy"
|
||||
placeholder="选择线路"
|
||||
/>
|
||||
<n-input v-model:value="huangdouHost" placeholder="https://pmihlvee.cc" />
|
||||
</n-form-item>
|
||||
<n-form-item v-if="huangdouAccounts.length" label="已保存">
|
||||
<div class="device-line">
|
||||
|
||||
Reference in New Issue
Block a user