fix: 导出凭据时弹出另存为窗口
This commit is contained in:
+7
-8
@@ -153,6 +153,7 @@ const token = ref("");
|
||||
const profile = ref<Profile | null>(null);
|
||||
const dramaboxLoggedIn = computed(() => profile.value?.has_login === "1");
|
||||
const dramaboxDeviceReady = computed(() => devices.value.some((item) => item.state === "device"));
|
||||
const credentialNote = ref("");
|
||||
const credentialFile = ref<HTMLInputElement | null>(null);
|
||||
const page = ref<"download" | "profile" | "progress" | "settings" | "play">("download");
|
||||
const playing = ref<{ id: string | number; title: string; image: string } | null>(null);
|
||||
@@ -1098,21 +1099,17 @@ async function loginDramaboxAdb() {
|
||||
function exportDramaboxCredential() {
|
||||
const target = token.value ? profileError : error;
|
||||
target.value = "";
|
||||
credentialNote.value = "";
|
||||
accountBusy.value = Boolean(token.value);
|
||||
busy.value = !token.value;
|
||||
fetch("/api/dramabox/login/credential")
|
||||
fetch("/api/dramabox/login/credential/save", { method: "POST" })
|
||||
.then(async (response) => {
|
||||
const payload = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
throw new Error(typeof payload.detail === "string" ? payload.detail : "导出失败");
|
||||
}
|
||||
const blob = new Blob([JSON.stringify(payload, null, 2)], { type: "application/json" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = "dramabox-login.json";
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
const path = typeof payload.path === "string" ? payload.path : "";
|
||||
credentialNote.value = path ? `已保存到 ${path}` : "已取消";
|
||||
})
|
||||
.catch((exc) => {
|
||||
target.value = exc instanceof Error ? exc.message : "导出失败";
|
||||
@@ -1644,6 +1641,7 @@ onUnmounted(stopLive);
|
||||
<n-button size="tiny" secondary :loading="accountBusy" @click="pickDramaboxCredential">导入凭据</n-button>
|
||||
</span>
|
||||
</div>
|
||||
<n-alert v-if="credentialNote" class="hint" type="success" :show-icon="false">{{ credentialNote }}</n-alert>
|
||||
<n-alert v-if="profileError" class="hint" type="error" :show-icon="false">{{ profileError }}</n-alert>
|
||||
<div v-for="item in accountFields" :key="item.key" class="profile-row">
|
||||
<span class="profile-row-label">{{ item.label }}</span>
|
||||
@@ -1751,6 +1749,7 @@ onUnmounted(stopLive);
|
||||
<n-button :loading="devicesBusy" @click="probeMumu">探测 MuMu</n-button>
|
||||
</div>
|
||||
</n-form-item>
|
||||
<n-alert v-if="credentialNote && platform === 'dramabox'" class="hint" type="success" :show-icon="false">{{ credentialNote }}</n-alert>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user