feat(登录): 登录框改成点名字:打开就是这个班的名单,点自己再输密码;老师和往届写用户名,这台电脑上次怎么登下次就怎么开;注册完直接登上
Deploy / deploy (push) Canceled after 0s

- 学生登录 / 管理员登录两个页签和「没有我所在的班级」合成一条「写用户名」,入口是名单底下的「名单里没有我」「老师登录」
- 名单按拼音排、可打拼音缩写筛,只剩一个人时回车就选中;这台电脑没登过时先列出全部班级
- 密码错就地标在密码框下面(「密码不对,再试一次」),错太多次按钮灰掉写清 15 分钟
- 注册保留邮箱,错在哪个框标在哪个框下面,按钮改「注册并登录」
- name / autocomplete 原来写在 n-input 上、落在外层 div,没到真正的 input;改走 input-props,点名字时的密码框才真的不会让浏览器填上一个人的密码
- 登法和班级一样跨退出登录保留;authModal store 只管开关,表单回到组件里

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-13 21:48:30 +08:00
1 parent 127bd6e5ce
commit 801d84c53b
6 files changed
+859 -505

No files matched your search

+2 -112
View File
@@ -1,157 +1,47 @@
import { defineStore } from "pinia"
/**
* 认证状态管理 Store
* 统一管理登录、注册相关的模态框状态和表单状态
* 登录框、注册框开没开。表单本身在两个组件里:每次打开都从干净的表单开始
* (机房一台电脑轮流坐人,别把上一个人的名字和密码留在框里),不需要跨组件共享。
*/
export const useAuthModalStore = defineStore("authModal", () => {
// ==================== 模态框状态 ====================
const loginModalOpen = ref(false)
const signupModalOpen = ref(false)
// ==================== 登录表单状态 ====================
// class 为 null 表示还没选,别用空串 —— 空串是「没有我所在的班级」那一项的值。
// username 同理用 null:空串在 n-select 里是「选了一个空值」,占位符不显示。
const loginForm = reactive({
class: null as string | null,
username: null as string | null,
password: "",
})
const loginLoading = ref(false)
const loginError = ref("")
// ==================== 注册表单状态 ====================
const signupForm = reactive({
username: "",
email: "",
password: "",
passwordAgain: "",
})
const signupLoading = ref(false)
const signupError = ref("")
// ==================== 模态框操作 ====================
/**
* 打开登录模态框
*/
function openLoginModal() {
loginModalOpen.value = true
}
/**
* 关闭登录模态框
*/
function closeLoginModal() {
loginModalOpen.value = false
}
/**
* 打开注册模态框
*/
function openSignupModal() {
signupModalOpen.value = true
}
/**
* 关闭注册模态框
*/
function closeSignupModal() {
signupModalOpen.value = false
}
/**
* 从登录切换到注册
*/
function switchToSignup() {
closeLoginModal()
openSignupModal()
}
/**
* 从注册切换到登录
*/
function switchToLogin() {
closeSignupModal()
openLoginModal()
}
// ==================== 登录表单操作 ====================
/**
* 设置登录加载状态
*/
function setLoginLoading(loading: boolean) {
loginLoading.value = loading
}
/**
* 设置登录错误信息
*/
function setLoginError(error: string) {
loginError.value = error
}
/**
* 清空登录错误
*/
function clearLoginError() {
loginError.value = ""
}
// ==================== 注册表单操作 ====================
/**
* 设置注册加载状态
*/
function setSignupLoading(loading: boolean) {
signupLoading.value = loading
}
/**
* 设置注册错误信息
*/
function setSignupError(error: string) {
signupError.value = error
}
/**
* 清空注册错误
*/
function clearSignupError() {
signupError.value = ""
}
return {
// 模态框状态
loginModalOpen,
signupModalOpen,
// 登录表单状态
loginForm,
loginLoading,
loginError,
// 注册表单状态
signupForm,
signupLoading,
signupError,
// 模态框操作
openLoginModal,
closeLoginModal,
openSignupModal,
closeSignupModal,
switchToSignup,
switchToLogin,
// 登录表单操作
setLoginLoading,
setLoginError,
clearLoginError,
// 注册表单操作
setSignupLoading,
setSignupError,
clearSignupError,
}
})