feat(desktop): implement phase 1 tauri client

This commit is contained in:
Cheng Zhou
2026-06-30 17:25:03 +08:00
parent 4654a812a0
commit d1a6c957f7
45 changed files with 5473 additions and 27 deletions
+15 -6
View File
@@ -198,6 +198,9 @@
<!-- 注册与忘记密码左右分立 -->
<div class="forgot-register-row">
<RouterLink to="/forgot-password" class="forgot-link">忘记密码</RouterLink>
<RouterLink v-if="showDesktopServerSettings" to="/desktop/server-settings" class="server-settings-link">
服务器设置
</RouterLink>
<RouterLink to="/register" class="register-link">新用户注册</RouterLink>
</div>
</el-form>
@@ -257,6 +260,7 @@ import { useAuthStore } from "../store/auth";
import { useStudyStore } from "../store/study";
import { fetchEmailDomains } from "../api/auth";
import { TEXT, requiredMessage } from "../locales";
import { isTauriRuntime } from "../runtime/platform";
import {
consumeLogoutReason,
LOGOUT_REASON_AUTH_EXPIRED,
@@ -287,6 +291,7 @@ const protocolDialogVisible = ref(false);
const logoutNotice = ref<{ type: "info" | "warning"; title: string; message: string } | null>(null);
const loginError = ref<{ title: string; message?: string } | null>(null);
const protocolSections = authProtocolSections;
const showDesktopServerSettings = isTauriRuntime();
const normalizeDomain = (value: string) => value.trim().toLowerCase().replace(/^@/, "");
const availableEmailDomains = computed(() => Array.from(new Set([
@@ -353,7 +358,7 @@ onMounted(async () => {
form.agreeProtocol = localStorage.getItem(AGREE_PROTOCOL_KEY) === "true";
});
watch(() => form.agreeProtocol, (v) => localStorage.setItem(AGREE_PROTOCOL_KEY, String(v)));
watch(() => form.agreeProtocol, (checked) => localStorage.setItem(AGREE_PROTOCOL_KEY, String(checked)));
watch(() => [form.emailLocal, form.emailDomain], syncEmailFromParts);
const openProtocolDialog = () => { protocolDialogVisible.value = true; };
@@ -371,7 +376,11 @@ const onSubmit = async () => {
const studyStore = useStudyStore();
const userKey = auth.user?.email || form.email;
await studyStore.restoreStudyForUser(userKey, { preferActive: !!auth.user?.is_admin });
router.push(studyStore.currentStudy ? "/project/overview" : auth.user?.is_admin ? "/admin/users" : "/admin/projects");
if (studyStore.currentStudy) {
router.push("/project/overview");
} else {
router.push(auth.user?.is_admin ? "/admin/users" : "/admin/projects");
}
} catch (error: any) {
const status = error?.response?.status;
const detail: string = error?.response?.data?.detail || error?.response?.data?.message || "";
@@ -704,8 +713,8 @@ const onSubmit = async () => {
/* 卡片容器 */
.login-card-container {
width: 100%;
max-width: 380px;
width: clamp(480px, 34vw, 560px);
max-width: calc(100vw - 40px);
display: flex;
flex-direction: column;
}
@@ -1040,7 +1049,7 @@ const onSubmit = async () => {
margin-top: 20px;
}
.forgot-link, .register-link {
.forgot-link, .register-link, .server-settings-link {
font-size: 13px;
color: #2563eb;
text-decoration: none;
@@ -1048,7 +1057,7 @@ const onSubmit = async () => {
transition: color 0.15s;
}
.forgot-link:hover, .register-link:hover {
.forgot-link:hover, .register-link:hover, .server-settings-link:hover {
color: #1d4ed8;
text-decoration: underline;
}