This commit is contained in:
吕才卓 2024-04-06 18:02:03 +08:00
parent 4af1a40d96
commit f4a26c5b69
3 changed files with 80 additions and 20 deletions

View File

@ -2,7 +2,7 @@ import request from "@/utils/request";
// 统一管理接口
const API = {
LOGIN_URL: "/api/user",
udaiu: "/user",
};
export const reqUser = () => request.get(API.LOGIN_URL);
export const reqUser = (data) => request.post(API.LOGIN_URL, data);
// export const reqUser = (data) => request.post(API.LOGIN_URL, data);

View File

@ -35,6 +35,8 @@
</t-form-item>
<t-form-item>
<t-button theme="primary" type="submit" block>登录</t-button>
<button @click.prevent="showForgotPasswordModal">忘记密码</button>
</t-form-item>
</t-form>
</div>
@ -45,9 +47,10 @@
<script setup>
import { MessagePlugin } from "tdesign-vue-next";
import { reactive, ref } from "vue";
import { reactive, ref, onMounted } from "vue";
import { reqUser } from "@/api/login";
// import {login} from "@/api/login";
import router from "@/router";
// import { TForm, TFormItem, TInput, TButton } from "tdesign-vue-next";
// import { DesktopIcon, LockOnIcon } from "tdesign-icons-vue";
const INITIAL_DATA = {
@ -91,24 +94,49 @@ const rules = reactive({
});
const onReset = () => {
//
formData.account = "";
formData.password = "";
MessagePlugin.success("重置成功");
};
const onSubmit = () => {
this.$refs.form.validateResult((valid,errors) => {
console.log(valid);
if (valid) {
// const onSubmit = () => {
// this.$refs.form.validateResult((valid,errors) => {
// console.log(valid);
// if (valid) {
// MessagePlugin.success("");
// } else {
// MessagePlugin.error("");
// console.log("Errors: ", errors);
// return false;
// }
// });
// };
const onSubmit = async () => {
try {
const validateResult = await this.$refs.form.validate();
if (validateResult.result) {
await reqUser();
MessagePlugin.success("提交成功");
await router.push("/");
} else {
MessagePlugin.error("提交失败");
console.log("Errors: ", errors);
return false;
const firstError = validateResult.errors[0]?.message || "未知错误";
console.log("Errors: ", validateResult.errors);
MessagePlugin.warning(firstError);
}
});
} catch (error) {
console.error("请求失败:", error);
MessagePlugin.error("提交失败");
}
};
const Login = async () => {
await reqLogin();
};
// const Login = async () => {
// await reqUser();
// };
onMounted(() => {
reqUser();
});
</script>
<style lang="less" scoped>

View File

@ -1,13 +1,45 @@
<template>
<div>
students
</div>
<div>
students
<t-space direction="vertical">
<!-- 按钮操作区域 -->
<div>
<t-radio-group v-model="size" variant="default-filled">
<t-radio-button value="small">小尺寸</t-radio-button>
<t-radio-button value="medium">中尺寸</t-radio-button>
<t-radio-button value="large">大尺寸</t-radio-button>
</t-radio-group>
</div>
<t-space>
<t-checkbox v-model="stripe">显示斑马纹</t-checkbox>
<t-checkbox v-model="bordered">显示表格边框</t-checkbox>
<t-checkbox v-model="hover">显示悬浮效果</t-checkbox>
<t-checkbox v-model="tableLayout">宽度自适应</t-checkbox>
<t-checkbox v-model="showHeader">显示表头</t-checkbox>
</t-space>
<!-- 当数据为空需要占位时会显示 cellEmptyContent -->
<t-table
rowKey="index"
:data="data"
:columns="columns"
:stripe="stripe"
:bordered="bordered"
:hover="hover"
:size="size"
:table-layout="tableLayout ? 'auto' : 'fixed'"
:pagination="pagination"
:showHeader="showHeader"
cellEmptyContent="-"
resizable
></t-table>
</t-space>
</div>
</template>
<script setup>
</script>
<style lang="scss" scoped>
</style>