work-order-monitor/src/views/AccountPage.vue

84 lines
2.7 KiB
Vue
Raw Normal View History

2026-03-10 14:41:13 +08:00
<script setup lang="ts">
2026-04-17 08:58:20 +08:00
import { storeToRefs } from "pinia";
2026-03-31 17:08:30 +08:00
import { ref } from "vue";
import { useMonitorStore } from "@/stores/monitor";
2026-03-10 14:41:13 +08:00
const store = useMonitorStore();
2026-04-17 08:58:20 +08:00
const { loginMode, isMonitoring, username, password, tokenSessionId, rememberPassword } = storeToRefs(store);
2026-03-31 17:08:30 +08:00
/** 表单操作加载状态 */
const isLoading = ref(false);
async function handleSaveSettings() {
isLoading.value = true;
await store.saveSettings();
isLoading.value = false;
}
async function handleStartMonitoring() {
isLoading.value = true;
await store.startMonitoring();
isLoading.value = false;
}
async function handleStopMonitoring() {
isLoading.value = true;
2026-04-17 08:58:20 +08:00
store.stopMonitoring();
2026-03-31 17:08:30 +08:00
isLoading.value = false;
}
2026-03-10 14:41:13 +08:00
</script>
<template>
<a-form layout="vertical">
<a-form-item>
2026-04-17 08:58:20 +08:00
<a-radio-group v-model:value="loginMode" :disabled="isMonitoring">
2026-03-31 17:08:30 +08:00
<a-radio-button value="password"> 账号密码登录 </a-radio-button>
<a-radio-button value="token"> Token 登录 </a-radio-button>
2026-03-10 14:41:13 +08:00
</a-radio-group>
</a-form-item>
2026-04-17 08:58:20 +08:00
<template v-if="loginMode === 'password'">
2026-03-10 14:41:13 +08:00
<a-form-item label="用户名">
2026-04-17 08:58:20 +08:00
<a-input v-model:value="username" placeholder="请输入用户名" :disabled="isLoading" />
2026-03-10 14:41:13 +08:00
</a-form-item>
<a-form-item label="密码">
2026-04-17 08:58:20 +08:00
<a-input-password v-model:value="password" placeholder="请输入密码" :disabled="isLoading" />
2026-03-10 14:41:13 +08:00
</a-form-item>
</template>
<template v-else>
<a-form-item label="ASP.NET_SessionId">
<a-input
2026-04-17 08:58:20 +08:00
v-model:value="tokenSessionId"
2026-03-10 14:41:13 +08:00
placeholder="请输入 ASP.NET_SessionId"
2026-03-31 17:08:30 +08:00
:disabled="isLoading"
2026-03-10 14:41:13 +08:00
allow-clear
/>
</a-form-item>
2026-03-31 17:08:30 +08:00
<a-typography-text type="secondary" style="font-size: 12px; display: block; margin-bottom: 12px">
2026-03-10 14:41:13 +08:00
从浏览器开发者工具 (F12) Application Cookies 中复制 ASP.NET_SessionId 的值
</a-typography-text>
</template>
<a-form-item>
2026-04-17 08:58:20 +08:00
<a-checkbox v-model:checked="rememberPassword">
记住{{ loginMode === "password" ? "密码" : "Token" }}
2026-03-10 14:41:13 +08:00
</a-checkbox>
</a-form-item>
<a-form-item>
<a-space>
2026-03-31 17:08:30 +08:00
<a-button type="primary" :loading="isLoading" @click="handleSaveSettings()"> 保存设置 </a-button>
<a-button
type="primary"
:loading="isLoading"
2026-04-17 08:58:20 +08:00
:disabled="isMonitoring"
2026-03-31 17:08:30 +08:00
style="background: #52c41a; border-color: #52c41a"
@click="handleStartMonitoring()"
>
2026-03-23 09:10:32 +08:00
开始监测
2026-03-10 14:41:13 +08:00
</a-button>
2026-04-17 08:58:20 +08:00
<a-button danger :disabled="isLoading || !isMonitoring" @click="handleStopMonitoring()"> 停止监测 </a-button>
2026-03-10 14:41:13 +08:00
</a-space>
</a-form-item>
</a-form>
</template>