666 lines
22 KiB
Vue
666 lines
22 KiB
Vue
<script setup lang="ts">
|
|
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
|
|
import { NAlert, NButton, NForm, NFormItem, NIcon, NInput, NInputNumber, NModal, NProgress, NSelect, NTimePicker, NTooltip } from "naive-ui";
|
|
import { GlobeOutline, PlayOutline, RefreshOutline, StopOutline, WarningOutline } from "@vicons/ionicons5";
|
|
import { dayOptions, workerOptions } from "../../shared/studyFields";
|
|
|
|
interface HomeSummary {
|
|
name: string;
|
|
avatar: string;
|
|
department: string;
|
|
level: string;
|
|
year_hours: string;
|
|
month_hours: string;
|
|
today_hours: string | number | null;
|
|
total_hours: string;
|
|
total_score: string;
|
|
points: string | number | null;
|
|
}
|
|
|
|
interface StudyWorker {
|
|
id: number;
|
|
course: string;
|
|
progress: number;
|
|
interval: number;
|
|
heartbeat_at: number;
|
|
ok: boolean;
|
|
}
|
|
|
|
type SectionState = "loading" | "ready" | "error";
|
|
|
|
const props = defineProps<{ employeeId: string }>();
|
|
const summary = ref<HomeSummary | null>(null);
|
|
const summaryState = ref<SectionState>("loading");
|
|
const summaryError = ref("");
|
|
const refreshing = ref(false);
|
|
let refreshRunning = false;
|
|
let busy = false;
|
|
let studyPoll = 0;
|
|
const nowTick = ref(Date.now());
|
|
|
|
const monthlyTarget = ref<number | null>(null);
|
|
const targetLoaded = ref(false);
|
|
let targetSaveTimer: ReturnType<typeof setTimeout> | undefined;
|
|
|
|
const studyControl = ref({
|
|
started: false,
|
|
paused: false,
|
|
ignore_window: false,
|
|
window_open: false,
|
|
active: false,
|
|
state: "",
|
|
course: "",
|
|
message: "",
|
|
workers: [] as StudyWorker[],
|
|
});
|
|
const studyBusy = ref(false);
|
|
const studyError = ref("");
|
|
|
|
const studyLabel = computed(() => {
|
|
const state = studyControl.value.state;
|
|
const course = studyControl.value.course;
|
|
if (state === "已达标") return "本月目标已达到";
|
|
if (state === "已停止" || studyControl.value.paused) return "任务已停止";
|
|
if (studyControl.value.active) {
|
|
return `正在学习:${course || state || "准备中"}`;
|
|
}
|
|
if (studyControl.value.started) return "任务已开始,等待执行";
|
|
if (studyControl.value.message) return studyControl.value.message;
|
|
return "未到开始时间";
|
|
});
|
|
|
|
function amount(value: string | number | null | undefined) {
|
|
if (value === null || value === undefined || value === "") return "—";
|
|
const numeric = Number(value);
|
|
if (!Number.isFinite(numeric)) return String(value);
|
|
if (Number.isInteger(numeric)) return String(numeric);
|
|
return String(value);
|
|
}
|
|
|
|
const facts = computed(() => {
|
|
const current = summary.value;
|
|
return [
|
|
{ label: "本年学时", value: current ? amount(current.year_hours) : "" },
|
|
{ label: "本月学时", value: current ? amount(current.month_hours) : "" },
|
|
{ label: "今日学时", value: current ? amount(current.today_hours) : "" },
|
|
{ label: "累计学时", value: current ? amount(current.total_hours) : "" },
|
|
{ label: "累计学分", value: current ? amount(current.total_score) : "" },
|
|
{ label: "可用积分", value: current ? amount(current.points) : "" },
|
|
];
|
|
});
|
|
|
|
function failureText(payload: { detail?: unknown }, fallback: string) {
|
|
return typeof payload.detail === "string" ? payload.detail : fallback;
|
|
}
|
|
|
|
function pad(value: number) {
|
|
return String(value).padStart(2, "0");
|
|
}
|
|
|
|
function asWorkers(value: unknown): StudyWorker[] {
|
|
if (!Array.isArray(value)) return [];
|
|
const rows: StudyWorker[] = [];
|
|
for (const item of value) {
|
|
if (!item || typeof item !== "object") continue;
|
|
const row = item as Record<string, unknown>;
|
|
rows.push({
|
|
id: typeof row.id === "number" ? row.id : rows.length + 1,
|
|
course: typeof row.course === "string" ? row.course : "",
|
|
progress: typeof row.progress === "number" ? row.progress : 0,
|
|
interval: typeof row.interval === "number" ? row.interval : 0,
|
|
heartbeat_at: typeof row.heartbeat_at === "number" ? row.heartbeat_at : 0,
|
|
ok: row.ok !== false,
|
|
});
|
|
}
|
|
return rows;
|
|
}
|
|
|
|
function workerPercent(row: StudyWorker) {
|
|
return Math.min(100, Math.max(0, Math.round(row.progress)));
|
|
}
|
|
|
|
function workerTitle(row: StudyWorker) {
|
|
if (row.course) return row.course;
|
|
if (workerPercent(row) >= 100) return "空闲";
|
|
return "准备";
|
|
}
|
|
|
|
function heartbeatLeft(row: StudyWorker) {
|
|
void nowTick.value;
|
|
if (!row.heartbeat_at) return "—";
|
|
const left = Math.max(0, Math.ceil(row.heartbeat_at - Date.now() / 1000));
|
|
return `${left}s`;
|
|
}
|
|
|
|
async function loadSummary() {
|
|
if (busy) return;
|
|
busy = true;
|
|
const hadData = summary.value !== null;
|
|
if (!hadData) summaryState.value = "loading";
|
|
try {
|
|
const response = await fetch("/api/home/summary");
|
|
const payload = await response.json().catch(() => ({}));
|
|
if (!response.ok) {
|
|
if (!hadData) {
|
|
summaryError.value = failureText(payload, "个人学习信息没有获取到。");
|
|
summaryState.value = "error";
|
|
}
|
|
return;
|
|
}
|
|
summary.value = payload;
|
|
summaryError.value = "";
|
|
summaryState.value = "ready";
|
|
} catch {
|
|
if (!hadData) {
|
|
summaryError.value = "个人学习信息没有获取到。";
|
|
summaryState.value = "error";
|
|
}
|
|
} finally {
|
|
busy = false;
|
|
}
|
|
}
|
|
|
|
function refresh() {
|
|
if (refreshRunning) return;
|
|
refreshRunning = true;
|
|
refreshing.value = true;
|
|
void Promise.all([loadSummary(), loadStudyControl()]).finally(() => {
|
|
refreshRunning = false;
|
|
refreshing.value = false;
|
|
});
|
|
}
|
|
|
|
async function loadTarget() {
|
|
try {
|
|
const res = await fetch("/api/settings/monthly-target");
|
|
if (res.ok) {
|
|
const data = await res.json();
|
|
monthlyTarget.value = data.monthly_target ?? 600;
|
|
targetLoaded.value = true;
|
|
}
|
|
} catch { /* 静默 */ }
|
|
}
|
|
|
|
function saveTarget(value: number | null) {
|
|
if (value == null || !Number.isInteger(value) || value < 0 || value > 9999) return;
|
|
clearTimeout(targetSaveTimer);
|
|
targetSaveTimer = setTimeout(async () => {
|
|
try {
|
|
await fetch("/api/settings/monthly-target", {
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ monthly_target: value }),
|
|
});
|
|
} catch { /* 静默 */ }
|
|
}, 600);
|
|
}
|
|
|
|
watch(monthlyTarget, (v) => { if (targetLoaded.value) saveTarget(v); });
|
|
|
|
const startLoaded = ref(false);
|
|
const startDay = ref<number | null>(1);
|
|
const startHour = ref<number | null>(0);
|
|
const startMinute = ref<number | null>(0);
|
|
const startSecond = ref<number | null>(0);
|
|
let startSaveTimer: ReturnType<typeof setTimeout> | undefined;
|
|
|
|
const startTime = computed({
|
|
get() {
|
|
return `${pad(startHour.value ?? 0)}:${pad(startMinute.value ?? 0)}:${pad(startSecond.value ?? 0)}`;
|
|
},
|
|
set(value: string | null) {
|
|
if (!value) return;
|
|
const [hour, minute, second] = value.split(":").map((part) => Number(part));
|
|
if (![hour, minute, second].every((part) => Number.isInteger(part))) return;
|
|
startHour.value = hour;
|
|
startMinute.value = minute;
|
|
startSecond.value = second;
|
|
},
|
|
});
|
|
|
|
async function loadStart() {
|
|
try {
|
|
const res = await fetch("/api/settings/study-start");
|
|
if (res.ok) {
|
|
const data = await res.json();
|
|
startDay.value = typeof data.day === "number" ? data.day : 1;
|
|
startHour.value = typeof data.hour === "number" ? data.hour : 0;
|
|
startMinute.value = typeof data.minute === "number" ? data.minute : 0;
|
|
startSecond.value = typeof data.second === "number" ? data.second : 0;
|
|
startLoaded.value = true;
|
|
}
|
|
} catch { /* 静默 */ }
|
|
}
|
|
|
|
function saveStart() {
|
|
const day = startDay.value;
|
|
const hour = startHour.value;
|
|
const minute = startMinute.value;
|
|
const second = startSecond.value;
|
|
if (
|
|
day == null || hour == null || minute == null || second == null
|
|
|| !Number.isInteger(day) || !Number.isInteger(hour) || !Number.isInteger(minute) || !Number.isInteger(second)
|
|
) return;
|
|
clearTimeout(startSaveTimer);
|
|
startSaveTimer = setTimeout(async () => {
|
|
try {
|
|
await fetch("/api/settings/study-start", {
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ day, hour, minute, second }),
|
|
});
|
|
} catch { /* 静默 */ }
|
|
}, 600);
|
|
}
|
|
|
|
watch([startDay, startHour, startMinute, startSecond], () => { if (startLoaded.value) saveStart(); });
|
|
|
|
const workersLoaded = ref(false);
|
|
const courseWorkers = ref<number | null>(1);
|
|
let workersSaveTimer: ReturnType<typeof setTimeout> | undefined;
|
|
|
|
async function loadWorkers() {
|
|
try {
|
|
const res = await fetch("/api/settings/course-workers");
|
|
if (res.ok) {
|
|
const data = await res.json();
|
|
courseWorkers.value = typeof data.workers === "number" ? data.workers : 1;
|
|
workersLoaded.value = true;
|
|
}
|
|
} catch { /* 静默 */ }
|
|
}
|
|
|
|
function saveWorkers(value: number | null) {
|
|
if (value == null || !Number.isInteger(value) || value < 1 || value > 8) return;
|
|
clearTimeout(workersSaveTimer);
|
|
workersSaveTimer = setTimeout(async () => {
|
|
try {
|
|
await fetch("/api/settings/course-workers", {
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ workers: value }),
|
|
});
|
|
} catch { /* 静默 */ }
|
|
}, 600);
|
|
}
|
|
|
|
watch(courseWorkers, (v) => { if (workersLoaded.value) saveWorkers(v); });
|
|
|
|
const proxyOpen = ref(false);
|
|
const proxyLoaded = ref(false);
|
|
const proxySaving = ref(false);
|
|
const proxyError = ref("");
|
|
const proxyScheme = ref("off");
|
|
const proxyHost = ref("");
|
|
const proxyPort = ref<number | null>(null);
|
|
const proxyUser = ref("");
|
|
const proxyPassword = ref("");
|
|
const proxyHasPassword = ref(false);
|
|
const proxyManual = computed(() => proxyScheme.value !== "off" && proxyScheme.value !== "pool");
|
|
const savedProxy = {
|
|
scheme: "off",
|
|
host: "",
|
|
port: null as number | null,
|
|
username: "",
|
|
hasPassword: false,
|
|
};
|
|
|
|
function rememberProxy() {
|
|
savedProxy.scheme = proxyScheme.value;
|
|
savedProxy.host = proxyHost.value;
|
|
savedProxy.port = proxyPort.value;
|
|
savedProxy.username = proxyUser.value;
|
|
savedProxy.hasPassword = proxyHasPassword.value;
|
|
}
|
|
|
|
function restoreProxy() {
|
|
proxyScheme.value = savedProxy.scheme;
|
|
proxyHost.value = savedProxy.host;
|
|
proxyPort.value = savedProxy.port;
|
|
proxyUser.value = savedProxy.username;
|
|
proxyPassword.value = "";
|
|
proxyHasPassword.value = savedProxy.hasPassword;
|
|
proxyError.value = "";
|
|
}
|
|
const proxyOptions = [
|
|
{ label: "关闭", value: "off" },
|
|
{ label: "自动", value: "pool" },
|
|
{ label: "HTTP", value: "http" },
|
|
{ label: "HTTPS", value: "https" },
|
|
{ label: "SOCKS4", value: "socks4" },
|
|
{ label: "SOCKS5", value: "socks5" },
|
|
];
|
|
|
|
async function loadProxy() {
|
|
try {
|
|
const res = await fetch("/api/settings/proxy");
|
|
const data = await res.json().catch(() => ({}));
|
|
if (!res.ok) return;
|
|
proxyScheme.value = typeof data.scheme === "string" && data.scheme ? data.scheme : "off";
|
|
proxyHost.value = typeof data.host === "string" ? data.host : "";
|
|
proxyPort.value = typeof data.port === "number" ? data.port : null;
|
|
proxyUser.value = typeof data.username === "string" ? data.username : "";
|
|
proxyPassword.value = "";
|
|
proxyHasPassword.value = data.has_password === true;
|
|
proxyLoaded.value = true;
|
|
rememberProxy();
|
|
} catch { /* 静默 */ }
|
|
}
|
|
|
|
function proxyPasswordPayload() {
|
|
if (proxyPassword.value !== "") return proxyPassword.value;
|
|
if (!proxyUser.value.trim()) return "";
|
|
return proxyHasPassword.value ? null : "";
|
|
}
|
|
|
|
async function saveProxy() {
|
|
if (proxySaving.value) return;
|
|
proxyError.value = "";
|
|
if (proxyManual.value) {
|
|
if (!proxyHost.value.trim()) {
|
|
proxyError.value = "请填写代理地址";
|
|
return;
|
|
}
|
|
if (proxyPort.value == null || !Number.isInteger(proxyPort.value)) {
|
|
proxyError.value = "请填写代理端口";
|
|
return;
|
|
}
|
|
}
|
|
proxySaving.value = true;
|
|
try {
|
|
const res = await fetch("/api/settings/proxy", {
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify(
|
|
proxyManual.value
|
|
? {
|
|
scheme: proxyScheme.value,
|
|
host: proxyHost.value.trim(),
|
|
port: proxyPort.value,
|
|
username: proxyUser.value.trim(),
|
|
password: proxyPasswordPayload(),
|
|
}
|
|
: { scheme: proxyScheme.value },
|
|
),
|
|
});
|
|
const data = await res.json().catch(() => ({}));
|
|
if (!res.ok) {
|
|
proxyError.value = failureText(data, "没有保存。");
|
|
return;
|
|
}
|
|
proxyPassword.value = "";
|
|
proxyHasPassword.value = data.has_password === true;
|
|
if (!proxyManual.value) {
|
|
proxyHost.value = "";
|
|
proxyPort.value = null;
|
|
proxyUser.value = "";
|
|
proxyHasPassword.value = false;
|
|
}
|
|
rememberProxy();
|
|
proxyOpen.value = false;
|
|
} catch {
|
|
proxyError.value = "没有保存。";
|
|
} finally {
|
|
proxySaving.value = false;
|
|
}
|
|
}
|
|
|
|
function applyStudyControl(payload: Record<string, unknown>) {
|
|
studyControl.value = {
|
|
started: payload.started === true,
|
|
paused: payload.paused === true,
|
|
ignore_window: payload.ignore_window === true,
|
|
window_open: payload.window_open === true,
|
|
active: payload.active === true,
|
|
state: typeof payload.state === "string" ? payload.state : "",
|
|
course: typeof payload.course === "string" ? payload.course : "",
|
|
message: typeof payload.message === "string" ? payload.message : "",
|
|
workers: asWorkers(payload.workers),
|
|
};
|
|
}
|
|
|
|
async function loadStudyControl() {
|
|
try {
|
|
const res = await fetch("/api/settings/study-control");
|
|
const data = await res.json().catch(() => ({}));
|
|
if (res.ok) applyStudyControl(data);
|
|
} catch { /* 静默 */ }
|
|
}
|
|
|
|
function startStudyPoll() {
|
|
if (studyPoll) return;
|
|
studyPoll = window.setInterval(() => {
|
|
nowTick.value = Date.now();
|
|
void loadStudyControl();
|
|
}, 1000);
|
|
}
|
|
|
|
function stopStudyPoll() {
|
|
if (studyPoll) {
|
|
window.clearInterval(studyPoll);
|
|
studyPoll = 0;
|
|
}
|
|
}
|
|
|
|
watch(proxyOpen, (open, wasOpen) => {
|
|
if (wasOpen && !open) restoreProxy();
|
|
});
|
|
|
|
watch(
|
|
() => studyControl.value.started,
|
|
(started) => {
|
|
if (started) startStudyPoll();
|
|
else stopStudyPoll();
|
|
},
|
|
);
|
|
|
|
async function toggleStudy() {
|
|
if (studyBusy.value) return;
|
|
studyBusy.value = true;
|
|
studyError.value = "";
|
|
const action = studyControl.value.started ? "stop" : "start";
|
|
try {
|
|
const res = await fetch("/api/settings/study-control", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ action }),
|
|
});
|
|
const data = await res.json().catch(() => ({}));
|
|
if (!res.ok) {
|
|
studyError.value = failureText(data, action === "start" ? "没有开始。" : "没有停止。");
|
|
return;
|
|
}
|
|
applyStudyControl(data);
|
|
} catch {
|
|
studyError.value = action === "start" ? "没有开始。" : "没有停止。";
|
|
} finally {
|
|
studyBusy.value = false;
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
refresh();
|
|
loadTarget();
|
|
loadStart();
|
|
loadWorkers();
|
|
loadProxy();
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
stopStudyPoll();
|
|
clearTimeout(targetSaveTimer);
|
|
clearTimeout(startSaveTimer);
|
|
clearTimeout(workersSaveTimer);
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<section class="page home-page">
|
|
<div class="home">
|
|
<section class="panel-card home-summary" :aria-busy="summaryState === 'loading'">
|
|
<div class="home-top">
|
|
<div class="home-top-main">
|
|
<n-alert v-if="summaryState === 'error'" class="summary-error" type="error">{{ summaryError }}</n-alert>
|
|
<div v-else class="profile">
|
|
<template v-if="summary">
|
|
<img v-if="summary.avatar" class="avatar" :src="summary.avatar" alt="" referrerpolicy="no-referrer" />
|
|
<div v-else class="brand-mark avatar-fallback" aria-hidden="true">{{ summary.name.slice(0, 1) || "E" }}</div>
|
|
<div>
|
|
<strong>{{ summary.name || props.employeeId }}</strong>
|
|
<span>{{ summary.department }}<template v-if="summary.level"> · {{ summary.level }}</template></span>
|
|
</div>
|
|
</template>
|
|
<template v-else>
|
|
<div class="bone bone-avatar"></div>
|
|
<div class="bone-copy">
|
|
<div class="bone bone-name"></div>
|
|
<div class="bone bone-meta"></div>
|
|
</div>
|
|
<div class="spin" role="status" aria-label="正在获取"></div>
|
|
</template>
|
|
</div>
|
|
</div>
|
|
<n-tooltip placement="bottom">
|
|
<template #trigger>
|
|
<n-button
|
|
class="home-refresh"
|
|
quaternary
|
|
circle
|
|
size="small"
|
|
aria-label="刷新数据"
|
|
:loading="refreshing"
|
|
@click="refresh"
|
|
>
|
|
<template #icon><n-icon><RefreshOutline /></n-icon></template>
|
|
</n-button>
|
|
</template>
|
|
刷新数据
|
|
</n-tooltip>
|
|
</div>
|
|
<dl class="facts">
|
|
<div v-for="item in facts" :key="item.label">
|
|
<dt>{{ item.label }}</dt>
|
|
<dd>
|
|
<span v-if="summaryState === 'loading'" class="bone bone-value"></span>
|
|
<template v-else>{{ item.value || "—" }}</template>
|
|
</dd>
|
|
</div>
|
|
</dl>
|
|
</section>
|
|
|
|
<section class="panel-card study-card">
|
|
<header class="panel-card-head">
|
|
<h3>自动学习</h3>
|
|
<n-button
|
|
:type="studyControl.started ? 'error' : 'primary'"
|
|
size="small"
|
|
:loading="studyBusy"
|
|
@click="toggleStudy"
|
|
>
|
|
<template #icon>
|
|
<n-icon><StopOutline v-if="studyControl.started" /><PlayOutline v-else /></n-icon>
|
|
</template>
|
|
{{ studyControl.started ? "停止" : "立即开始" }}
|
|
</n-button>
|
|
</header>
|
|
<n-alert v-if="studyError" class="summary-error" type="error">{{ studyError }}</n-alert>
|
|
<n-form class="compact-nform" label-placement="left" label-align="left" :label-width="96" :show-feedback="false" size="small">
|
|
<n-form-item v-if="targetLoaded" label="每月目标">
|
|
<div class="target-control">
|
|
<n-input-number
|
|
id="monthly-target"
|
|
v-model:value="monthlyTarget"
|
|
button-placement="both"
|
|
:min="0"
|
|
:max="9999"
|
|
:precision="0"
|
|
size="small"
|
|
/>
|
|
<span class="target-unit">分钟</span>
|
|
</div>
|
|
</n-form-item>
|
|
<n-form-item v-if="startLoaded" label="定时启动">
|
|
<div class="target-control start-control">
|
|
<n-select id="study-start-day" v-model:value="startDay" size="small" :options="dayOptions" class="day-select" />
|
|
<n-tooltip v-if="startDay === 1" placement="top">
|
|
<template #trigger>
|
|
<n-icon class="day-warn"><WarningOutline /></n-icon>
|
|
</template>
|
|
不推荐使用
|
|
</n-tooltip>
|
|
<n-time-picker v-model:formatted-value="startTime" value-format="HH:mm:ss" size="small" :actions="null" />
|
|
</div>
|
|
</n-form-item>
|
|
<n-form-item v-if="workersLoaded" label="线程数量">
|
|
<n-select id="course-workers" v-model:value="courseWorkers" size="small" :options="workerOptions" />
|
|
</n-form-item>
|
|
</n-form>
|
|
<div class="home-study-status">
|
|
<span class="study-indicator" :class="{ active: studyControl.started || studyControl.active }"></span>
|
|
<span class="study-text" :class="{ muted: !studyControl.active }">{{ studyLabel }}</span>
|
|
</div>
|
|
<ul v-if="studyControl.started && studyControl.workers.length" class="study-workers">
|
|
<li v-for="row in studyControl.workers" :key="row.id" class="study-worker">
|
|
<div class="study-worker-main">
|
|
<span class="study-worker-title">{{ workerTitle(row) }}</span>
|
|
<n-progress type="line" :percentage="workerPercent(row)" :show-indicator="false" :height="8" />
|
|
</div>
|
|
<div class="study-worker-meta">
|
|
<span class="study-worker-pct">{{ workerPercent(row) }}%</span>
|
|
<span class="study-heartbeat">{{ heartbeatLeft(row) }}</span>
|
|
<span class="study-dot" :class="row.ok ? 'up' : 'down'"></span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
<div class="study-card-foot">
|
|
<n-button v-if="proxyLoaded" size="small" quaternary @click="proxyOpen = true">
|
|
<template #icon><n-icon><GlobeOutline /></n-icon></template>
|
|
代理
|
|
</n-button>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
<n-modal
|
|
:show="proxyOpen"
|
|
preset="card"
|
|
title="代理"
|
|
:style="{ width: 'min(420px, calc(100vw - 32px))' }"
|
|
@update:show="(show) => (proxyOpen = show)"
|
|
>
|
|
<n-alert v-if="proxyError" class="summary-error" type="error">{{ proxyError }}</n-alert>
|
|
<n-form class="compact-nform" label-placement="left" label-align="left" :label-width="72" :show-feedback="false" size="small">
|
|
<n-form-item label="类型">
|
|
<n-select v-model:value="proxyScheme" size="small" :options="proxyOptions" />
|
|
</n-form-item>
|
|
<template v-if="proxyManual">
|
|
<n-form-item label="地址">
|
|
<n-input v-model:value="proxyHost" size="small" placeholder="例如 127.0.0.1" />
|
|
</n-form-item>
|
|
<n-form-item label="端口">
|
|
<n-input-number v-model:value="proxyPort" size="small" button-placement="both" :min="1" :max="65535" :precision="0" placeholder="请输入" />
|
|
</n-form-item>
|
|
<n-form-item label="账号">
|
|
<n-input v-model:value="proxyUser" size="small" placeholder="可不填" autocomplete="off" />
|
|
</n-form-item>
|
|
<n-form-item label="密码">
|
|
<n-input
|
|
v-model:value="proxyPassword"
|
|
size="small"
|
|
type="password"
|
|
show-password-on="click"
|
|
:placeholder="proxyHasPassword ? '已保存,留空则保持' : '可不填'"
|
|
autocomplete="new-password"
|
|
/>
|
|
</n-form-item>
|
|
</template>
|
|
</n-form>
|
|
<template #footer>
|
|
<div class="modal-actions">
|
|
<n-button @click="proxyOpen = false">取消</n-button>
|
|
<n-button type="primary" :loading="proxySaving" @click="saveProxy">保存</n-button>
|
|
</div>
|
|
</template>
|
|
</n-modal>
|
|
</section>
|
|
</template>
|