feat: 架构调整

This commit is contained in:
2026-07-23 11:27:33 +08:00
parent 6f37264047
commit 3b5a908ee4
25 changed files with 653 additions and 245 deletions
+13 -10
View File
@@ -1,7 +1,6 @@
import { defineComponent, reactive, ref } from 'vue';
import { Button, Card, Form, FormItem, Input, message } from 'ant-design-vue';
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue';
import { useRouter } from 'vue-router';
import { auth } from '@/hooks/useAuth';
import styles from './index.module.less';
@@ -12,11 +11,11 @@ interface LoginForm {
/**
* 登录页
* auth.login() 内部会自动:保存 token → 拉取菜单+权限 → 动态注册路由 → 跳转首页
*/
export default defineComponent({
name: 'LoginPage',
setup() {
const router = useRouter();
const loading = ref(false);
const form = reactive<LoginForm>({
@@ -37,16 +36,20 @@ export default defineComponent({
loading.value = true;
// TODO: 替换为真实登录接口
// const res = await post<LoginResult>('/login', { ...form });
// auth.login(res.token);
try {
// TODO: 替换为真实登录接口
// const res = await post<LoginResult>('/auth/login', { username: form.username, password: form.password });
// await auth.login(res.token);
setTimeout(() => {
auth.login('mock_token_' + Date.now());
// Mock:模拟登录
await new Promise((r) => setTimeout(r, 600));
await auth.login('mock_token_' + Date.now());
message.success('登录成功');
} catch (err) {
message.error('登录失败,请重试');
} finally {
loading.value = false;
router.push('/dashboard');
}, 600);
}
};
return () => (
@@ -71,7 +74,7 @@ export default defineComponent({
/>
</FormItem>
<FormItem>
<Button type="primary" html-type="submit" size="large" block loading={loading.value}>
<Button type="primary" htmlType="submit" size="large" block loading={loading.value}>
</Button>
</FormItem>