feat: 将工具更名为 VideosDownTools,并完善黄豆登录与清单
This commit is contained in:
+297
-12
@@ -30,6 +30,7 @@ interface Profile {
|
||||
balance?: string | number;
|
||||
is_vip?: string | number;
|
||||
has_login?: string;
|
||||
host?: string;
|
||||
country?: string;
|
||||
language?: string;
|
||||
native?: string;
|
||||
@@ -51,6 +52,12 @@ interface SavedAccount {
|
||||
uid: string;
|
||||
}
|
||||
|
||||
interface HuangdouAccount {
|
||||
username: string;
|
||||
password: string;
|
||||
nickname: string;
|
||||
}
|
||||
|
||||
interface DeviceProfile {
|
||||
brand: string;
|
||||
model: string;
|
||||
@@ -92,6 +99,9 @@ const SESSION_DEVICE_KEY = "rapt-device";
|
||||
const ACCOUNTS_KEY = "rapt-accounts";
|
||||
const PLATFORM_KEY = "rapt-platform";
|
||||
const DRAMABOX_LANG_KEY = "dramabox-language";
|
||||
const HUANGDOU_HOST_KEY = "huangdou-host";
|
||||
const HUANGDOU_ACCOUNTS_KEY = "huangdou-accounts";
|
||||
const HUANGDOU_REMEMBER_KEY = "huangdou-remember";
|
||||
const DRAMABOX_DEVICE_KEY = "dramabox-device";
|
||||
|
||||
const themeOverrides: GlobalThemeOverrides = {
|
||||
@@ -113,11 +123,19 @@ const apiBase = computed(() => {
|
||||
return "/api";
|
||||
});
|
||||
const platformLabel = computed(() => {
|
||||
const name = platforms.find((item) => item.key === platform.value)?.label || "RaptDrama";
|
||||
const name = platforms.find((item) => item.key === platform.value)?.label || "VideosDownTools";
|
||||
if (platform.value === "dramabox" && profile.value?.nickname) return `${name} · ${profile.value.nickname}`;
|
||||
return name;
|
||||
});
|
||||
const dramaboxLang = ref("th");
|
||||
const huangdouHost = ref(readHuangdouHost());
|
||||
const huangdouUser = ref("");
|
||||
const huangdouPassword = ref("");
|
||||
const huangdouRemember = ref(readHuangdouRemember());
|
||||
const huangdouAccounts = ref<HuangdouAccount[]>([]);
|
||||
const huangdouSelected = ref<string | null>(null);
|
||||
const huangdouFingerprintBusy = ref(false);
|
||||
const huangdouFingerprintNote = ref("");
|
||||
const dramaboxLangs = ref<{ label: string; value: string }[]>([]);
|
||||
const accountBusy = ref(false);
|
||||
const activeProxyUrl = ref("");
|
||||
@@ -193,6 +211,68 @@ const menuValue = computed(() => {
|
||||
return page.value;
|
||||
});
|
||||
|
||||
function currentBrowserFingerprint() {
|
||||
const ua = navigator.userAgent || "";
|
||||
let browserName = "Chrome";
|
||||
if (ua.includes("Edg/")) browserName = "Edge";
|
||||
else if (ua.includes("Firefox/")) browserName = "Firefox";
|
||||
else if (ua.includes("Safari/") && !ua.includes("Chrome/")) browserName = "Safari";
|
||||
return {
|
||||
browserName,
|
||||
language: navigator.language || "zh-CN",
|
||||
userAgent: ua,
|
||||
platform: navigator.platform || "Win32",
|
||||
};
|
||||
}
|
||||
|
||||
async function sendHuangdouFingerprint() {
|
||||
try {
|
||||
await fetch("/api/huangdou/fingerprint", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(currentBrowserFingerprint()),
|
||||
});
|
||||
} catch {
|
||||
// 首次指纹沿用代码里的默认值
|
||||
}
|
||||
}
|
||||
|
||||
async function rollHuangdouFingerprint() {
|
||||
huangdouFingerprintNote.value = "";
|
||||
error.value = "";
|
||||
huangdouFingerprintBusy.value = true;
|
||||
try {
|
||||
const response = await fetch("/api/huangdou/fingerprint/roll", { method: "POST" });
|
||||
const payload = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
throw new Error(typeof payload.detail === "string" ? payload.detail : "更换失败");
|
||||
}
|
||||
huangdouFingerprintNote.value = "已更换设备指纹";
|
||||
} catch (exc) {
|
||||
error.value = exc instanceof Error ? exc.message : "更换失败";
|
||||
} finally {
|
||||
huangdouFingerprintBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function readHuangdouRemember() {
|
||||
try {
|
||||
return localStorage.getItem(HUANGDOU_REMEMBER_KEY) !== "0";
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function readHuangdouHost() {
|
||||
try {
|
||||
const value = localStorage.getItem(HUANGDOU_HOST_KEY) || "";
|
||||
if (value.trim()) return value.trim();
|
||||
} catch {
|
||||
// 沿用默认域名
|
||||
}
|
||||
return "https://pmihlvee.cc";
|
||||
}
|
||||
|
||||
function readPlatform(): Platform {
|
||||
try {
|
||||
const value = localStorage.getItem(PLATFORM_KEY);
|
||||
@@ -212,6 +292,7 @@ function selectPlatform(key: string) {
|
||||
void loadDramaboxLanguages();
|
||||
void loadDevices();
|
||||
}
|
||||
if (key === "huangdou") void sendHuangdouFingerprint();
|
||||
}
|
||||
|
||||
function tokenKey() {
|
||||
@@ -310,6 +391,18 @@ const methods: { id: Method; label: string }[] = [
|
||||
{ id: "adb", label: "ADB" },
|
||||
];
|
||||
|
||||
const profileSub = computed(() => {
|
||||
if (!profile.value) return "";
|
||||
if (platform.value === "huangdou") {
|
||||
if (profile.value.has_login === "1") {
|
||||
return profile.value.username || profile.value.phone || profile.value.email || "";
|
||||
}
|
||||
return "访客";
|
||||
}
|
||||
if (platform.value === "dramabox") return profile.value.native || profile.value.email || "";
|
||||
return profile.value.email || "未绑定邮箱";
|
||||
});
|
||||
|
||||
const accountFields = computed(() => {
|
||||
if (platform.value === "huangdou") {
|
||||
return [
|
||||
@@ -631,6 +724,13 @@ const accountOptions = computed(() =>
|
||||
})),
|
||||
);
|
||||
|
||||
const huangdouAccountOptions = computed(() =>
|
||||
huangdouAccounts.value.map((item) => ({
|
||||
label: item.nickname ? `${item.nickname} · ${item.username}` : item.username,
|
||||
value: item.username,
|
||||
})),
|
||||
);
|
||||
|
||||
function readList<T>(key: string): T[] {
|
||||
try {
|
||||
const data = JSON.parse(localStorage.getItem(key) || "[]");
|
||||
@@ -678,6 +778,91 @@ function saveAccount(info: Profile) {
|
||||
selectedAccount.value = next.email;
|
||||
}
|
||||
|
||||
let huangdouAccountsReady = false;
|
||||
let huangdouAccountTimer = 0;
|
||||
|
||||
function writeHuangdouAccounts() {
|
||||
window.clearTimeout(huangdouAccountTimer);
|
||||
huangdouAccountTimer = window.setTimeout(() => {
|
||||
const accounts = huangdouAccounts.value.map((item) => ({
|
||||
username: item.username,
|
||||
password: item.password,
|
||||
nickname: item.nickname || "",
|
||||
}));
|
||||
void fetch("/api/huangdou/accounts", {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ accounts }),
|
||||
});
|
||||
}, 200);
|
||||
}
|
||||
|
||||
function usableHuangdouAccounts(rows: HuangdouAccount[]) {
|
||||
return rows.filter((item) => Boolean(item?.username) && typeof item.password === "string" && item.password);
|
||||
}
|
||||
|
||||
async function loadHuangdouAccounts() {
|
||||
const local = usableHuangdouAccounts(readList<HuangdouAccount>(HUANGDOU_ACCOUNTS_KEY));
|
||||
let remote: HuangdouAccount[] = [];
|
||||
try {
|
||||
const response = await fetch("/api/huangdou/accounts");
|
||||
if (response.ok) {
|
||||
const payload = await response.json();
|
||||
remote = usableHuangdouAccounts(Array.isArray(payload.accounts) ? payload.accounts : []);
|
||||
}
|
||||
} catch {
|
||||
remote = [];
|
||||
}
|
||||
huangdouAccounts.value = remote.length ? remote : local;
|
||||
if (!remote.length && local.length) writeHuangdouAccounts();
|
||||
if (huangdouAccounts.value[0]) applyHuangdouAccount(huangdouAccounts.value[0].username);
|
||||
}
|
||||
|
||||
function applyHuangdouAccount(username: string) {
|
||||
const found = huangdouAccounts.value.find((item) => item.username === username);
|
||||
if (!found) return;
|
||||
huangdouSelected.value = found.username;
|
||||
huangdouUser.value = found.username;
|
||||
huangdouPassword.value = found.password;
|
||||
huangdouRemember.value = true;
|
||||
}
|
||||
|
||||
function removeHuangdouAccount() {
|
||||
if (!huangdouSelected.value) return;
|
||||
const removing = huangdouSelected.value;
|
||||
huangdouAccounts.value = huangdouAccounts.value.filter((item) => item.username !== removing);
|
||||
writeHuangdouAccounts();
|
||||
if (huangdouUser.value === removing) {
|
||||
huangdouUser.value = "";
|
||||
huangdouPassword.value = "";
|
||||
}
|
||||
huangdouSelected.value = huangdouAccounts.value[0]?.username ?? null;
|
||||
if (huangdouSelected.value) applyHuangdouAccount(huangdouSelected.value);
|
||||
}
|
||||
|
||||
function saveHuangdouAccount(info: Profile) {
|
||||
const username = huangdouUser.value.trim();
|
||||
if (!username || !huangdouPassword.value) return;
|
||||
const next: HuangdouAccount = {
|
||||
username,
|
||||
password: huangdouPassword.value,
|
||||
nickname: info.nickname || info.username || "",
|
||||
};
|
||||
huangdouAccounts.value = [next, ...huangdouAccounts.value.filter((item) => item.username !== username)];
|
||||
writeHuangdouAccounts();
|
||||
huangdouSelected.value = username;
|
||||
}
|
||||
|
||||
function forgetHuangdouAccount(username: string) {
|
||||
const name = username.trim();
|
||||
if (!name) return;
|
||||
const next = huangdouAccounts.value.filter((item) => item.username !== name);
|
||||
if (next.length === huangdouAccounts.value.length) return;
|
||||
huangdouAccounts.value = next;
|
||||
writeHuangdouAccounts();
|
||||
if (huangdouSelected.value === name) huangdouSelected.value = next[0]?.username ?? null;
|
||||
}
|
||||
|
||||
function profileText(key: keyof Profile) {
|
||||
if (key === "loginType") {
|
||||
const kind = String(profile.value?.loginType || "").trim().toLowerCase();
|
||||
@@ -772,15 +957,82 @@ watch(method, (value) => {
|
||||
if (value === "adb") loadDevices();
|
||||
});
|
||||
|
||||
async function loginHuangdou() {
|
||||
watch(huangdouRemember, (value) => {
|
||||
try {
|
||||
localStorage.setItem(HUANGDOU_REMEMBER_KEY, value ? "1" : "0");
|
||||
} catch {
|
||||
// 勾选状态只影响本机
|
||||
}
|
||||
});
|
||||
|
||||
watch(huangdouUser, (value) => {
|
||||
const found = huangdouAccounts.value.find((item) => item.username === value.trim());
|
||||
huangdouSelected.value = found ? found.username : null;
|
||||
});
|
||||
|
||||
watch([huangdouRemember, huangdouUser, huangdouPassword], () => {
|
||||
if (!huangdouAccountsReady) return;
|
||||
const username = huangdouUser.value.trim();
|
||||
if (!username) return;
|
||||
if (huangdouRemember.value && huangdouPassword.value) {
|
||||
const existing = huangdouAccounts.value.find((item) => item.username === username);
|
||||
if (
|
||||
existing &&
|
||||
existing.password === huangdouPassword.value &&
|
||||
huangdouAccounts.value[0]?.username === username
|
||||
) {
|
||||
huangdouSelected.value = username;
|
||||
return;
|
||||
}
|
||||
huangdouAccounts.value = [
|
||||
{
|
||||
username,
|
||||
password: huangdouPassword.value,
|
||||
nickname: existing?.nickname || "",
|
||||
},
|
||||
...huangdouAccounts.value.filter((item) => item.username !== username),
|
||||
];
|
||||
huangdouSelected.value = username;
|
||||
writeHuangdouAccounts();
|
||||
return;
|
||||
}
|
||||
if (!huangdouRemember.value) {
|
||||
const next = huangdouAccounts.value.filter((item) => item.username !== username);
|
||||
if (next.length === huangdouAccounts.value.length) return;
|
||||
huangdouAccounts.value = next;
|
||||
if (huangdouSelected.value === username) huangdouSelected.value = next[0]?.username ?? null;
|
||||
writeHuangdouAccounts();
|
||||
}
|
||||
});
|
||||
|
||||
async function loginHuangdou(asGuest = false) {
|
||||
error.value = "";
|
||||
if (!asGuest && (!huangdouUser.value.trim() || !huangdouPassword.value)) {
|
||||
error.value = "请填写账号和密码";
|
||||
return;
|
||||
}
|
||||
busy.value = true;
|
||||
try {
|
||||
const response = await fetch("/api/huangdou/login/device", { method: "POST" });
|
||||
const host = huangdouHost.value.trim() || "https://pmihlvee.cc";
|
||||
huangdouHost.value = host;
|
||||
localStorage.setItem(HUANGDOU_HOST_KEY, host);
|
||||
const response = await fetch("/api/huangdou/login", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
host,
|
||||
username: asGuest ? "" : huangdouUser.value.trim(),
|
||||
password: asGuest ? "" : huangdouPassword.value,
|
||||
}),
|
||||
});
|
||||
const payload = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error(typeof payload.detail === "string" ? payload.detail : "登录失败");
|
||||
}
|
||||
if (!asGuest) {
|
||||
if (huangdouRemember.value) saveHuangdouAccount(payload.profile || {});
|
||||
else forgetHuangdouAccount(huangdouUser.value);
|
||||
}
|
||||
token.value = payload.token;
|
||||
profile.value = payload.profile;
|
||||
writeSavedToken(payload.token);
|
||||
@@ -868,7 +1120,7 @@ async function loginDramabox() {
|
||||
|
||||
async function login() {
|
||||
if (platform.value === "huangdou") {
|
||||
await loginHuangdou();
|
||||
await loginHuangdou(false);
|
||||
return;
|
||||
}
|
||||
if (platform.value === "dramabox") {
|
||||
@@ -974,6 +1226,9 @@ async function logout() {
|
||||
token.value = "";
|
||||
profile.value = null;
|
||||
page.value = "download";
|
||||
if (platform.value === "huangdou" && huangdouAccounts.value.length) {
|
||||
applyHuangdouAccount(huangdouSelected.value || huangdouAccounts.value[0].username);
|
||||
}
|
||||
forgetSavedToken();
|
||||
sessionStorage.removeItem(SESSION_DEVICE_KEY);
|
||||
try {
|
||||
@@ -1043,7 +1298,7 @@ async function confirmQuit() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
document.title = "RaptDrama Download Tools";
|
||||
document.title = "VideosDownTools";
|
||||
void watchClose();
|
||||
await loadDeviceDefaults();
|
||||
loadSettings();
|
||||
@@ -1054,10 +1309,13 @@ onMounted(async () => {
|
||||
}
|
||||
savedAccounts.value = readList<SavedAccount>(ACCOUNTS_KEY);
|
||||
if (savedAccounts.value[0]) applyAccount(savedAccounts.value[0].email);
|
||||
await loadHuangdouAccounts();
|
||||
huangdouAccountsReady = true;
|
||||
if (platform.value === "dramabox") {
|
||||
await loadDramaboxLanguages();
|
||||
void loadDevices();
|
||||
}
|
||||
if (platform.value === "huangdou") void sendHuangdouFingerprint();
|
||||
let saved = readSavedToken();
|
||||
if (!saved && isolated.value) {
|
||||
try {
|
||||
@@ -1182,6 +1440,7 @@ onUnmounted(stopLive);
|
||||
:device="sessionDevice()"
|
||||
:api-base="apiBase"
|
||||
:remote-search="isolated"
|
||||
:show-point-download="platform === 'huangdou'"
|
||||
@started="page = 'progress'"
|
||||
@play="openPlay"
|
||||
/>
|
||||
@@ -1205,8 +1464,9 @@ onUnmounted(stopLive);
|
||||
<div class="profile-name-row">
|
||||
<span class="profile-name">{{ profile.nickname || "未命名" }}</span>
|
||||
<n-tag v-if="profile.badge" size="small" :bordered="false" type="success">{{ profile.badge }}</n-tag>
|
||||
<n-tag v-if="platform === 'huangdou'" size="small" :bordered="false" :type="profile.has_login === '1' ? 'success' : 'default'">{{ profile.has_login === "1" ? "已登录" : "访客" }}</n-tag>
|
||||
</div>
|
||||
<span class="profile-sub">{{ profile.email || (platform === "dramabox" ? profile.native || "" : "未绑定邮箱") }}</span>
|
||||
<span class="profile-sub">{{ profileSub }}</span>
|
||||
</div>
|
||||
<n-tooltip placement="bottom">
|
||||
<template #trigger>
|
||||
@@ -1271,6 +1531,35 @@ onUnmounted(stopLive);
|
||||
<n-tab v-for="item in methods" :key="item.id" :name="item.id">{{ item.label }}</n-tab>
|
||||
</n-tabs>
|
||||
<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" />
|
||||
</n-form-item>
|
||||
<n-form-item v-if="huangdouAccounts.length" label="已保存">
|
||||
<div class="device-line">
|
||||
<n-select
|
||||
:value="huangdouSelected"
|
||||
:options="huangdouAccountOptions"
|
||||
placeholder="选择已保存的账号"
|
||||
@update:value="applyHuangdouAccount"
|
||||
/>
|
||||
<n-button attr-type="button" :disabled="!huangdouSelected" @click="removeHuangdouAccount">删除</n-button>
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-form-item label="账号">
|
||||
<n-input v-model:value="huangdouUser" placeholder="手机号或邮箱" autocomplete="username" />
|
||||
</n-form-item>
|
||||
<n-form-item label="密码">
|
||||
<n-input v-model:value="huangdouPassword" type="password" show-password-on="click" placeholder="密码" autocomplete="current-password" />
|
||||
</n-form-item>
|
||||
<n-form-item label="记住">
|
||||
<n-checkbox v-model:checked="huangdouRemember">记住账号密码</n-checkbox>
|
||||
</n-form-item>
|
||||
<n-form-item label="指纹">
|
||||
<n-button attr-type="button" secondary :loading="huangdouFingerprintBusy" @click="rollHuangdouFingerprint">更换新设备指纹</n-button>
|
||||
</n-form-item>
|
||||
<n-text v-if="huangdouFingerprintNote" class="hint" depth="3">{{ huangdouFingerprintNote }}</n-text>
|
||||
</template>
|
||||
<n-form-item v-if="platform === 'dramabox'" label="地区">
|
||||
<n-select v-model:value="dramaboxLang" filterable :options="dramaboxLangs" placeholder="选择国家 / 语言" />
|
||||
</n-form-item>
|
||||
@@ -1315,15 +1604,11 @@ onUnmounted(stopLive);
|
||||
<n-button :loading="devicesBusy" @click="probeMumu">探测 MuMu</n-button>
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-text v-if="platform === 'dramabox' && !devicesBusy && devices.length === 0" class="hint" depth="3">当前没有可用设备,可先访客进入。</n-text>
|
||||
<n-text v-if="platform === 'dramabox'" class="hint" depth="3">选好地区后点访客进入即可浏览。解锁内容和下载请先从设备登录。</n-text>
|
||||
<n-text v-if="platform === 'rapt' && method === 'guest'" class="hint" depth="3">将注册一个新的游客账号,并读取它的个人信息。</n-text>
|
||||
<n-text v-if="platform === 'rapt' && method === 'adb' && !devicesBusy && devices.length === 0" class="hint" depth="3">没有检测到已连接的设备。</n-text>
|
||||
<n-text v-if="platform === 'rapt' && method === 'adb'" class="hint" depth="3">从已 root 的设备读取当前登录账号。未 root 的设备无法获取登录信息。默认同时读取这台设备的品牌、型号和系统版本,可在右下角设置里修改。</n-text>
|
||||
<n-alert v-if="error" class="hint" type="error" :show-icon="false">{{ error }}</n-alert>
|
||||
<div class="login-actions">
|
||||
<n-button v-if="platform === 'dramabox'" attr-type="button" secondary :loading="busy" :disabled="!dramaboxDeviceReady" @click="loginDramaboxAdb">从设备登录</n-button>
|
||||
<n-button type="primary" attr-type="submit" :loading="busy">{{ platform === "dramabox" ? "访客进入" : isolated ? "进入" : "登录" }}</n-button>
|
||||
<n-button v-if="platform === 'huangdou'" attr-type="button" secondary :loading="busy" @click="loginHuangdou(true)">访客进入</n-button>
|
||||
<n-button type="primary" attr-type="submit" :loading="busy">{{ platform === "dramabox" ? "访客进入" : platform === "huangdou" ? "登录" : isolated ? "进入" : "登录" }}</n-button>
|
||||
</div>
|
||||
</n-form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user