-
-
-
{{ create ? '注册' : '登陆' }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{{ create ? '注册' : '登陆' }}
+
+
+
{{ create ? "注册" : "登陆" }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{
+ create ? "注册" : "登陆"
+ }}
+ {{
+ create ? "返回" : "注册"
+ }}
+
-
+
+
+ },
+ methods: {
+ login() {
+ if (this.form.username === "" || this.form.password === "") {
+ ElMessage.error("账号或密码不能为空");
+ } else {
+ // this.$router.push('/index')
+ this.query.account = this.form.username;
+ this.query.password = this.form.password;
+ userLogin(this.query).then((response) => {
+ console.log(response);
+ ElMessage({
+ message: response.msg,
+ type: "success",
+ });
+ // 登录成功后重定向到主页
+ router.push('/index');
+ });
+ }
+ },
+ remenber(data) {
+ this.checked = data;
+ if (this.checked) {
+ localStorage.setItem("news", JSON.stringify(this.form));
+ } else {
+ localStorage.removeItem("news");
+ }
+ },
+ forgetpas() {
+ ElMessage({
+ message: "请联系管理员更改密码",
+ type: "warning",
+ });
+ },
+ register() {
+ if (this.create) {
+ // 从注册切换到登录清空表单内容
+ this.form.username = "";
+ this.form.password = "";
+ this.form.repassword = "";
+ } else if (
+ this.form.username ||
+ this.form.password ||
+ this.form.repassword
+ ) {
+ // 从登录切换到注册清空表单内容
+ this.form.username = "";
+ this.form.password = "";
+ this.form.repassword = "";
+ }
+ this.create = !this.create;
+ // 清除字段的验证错误
+ this.$refs.form.clearValidate("username");
+ this.$refs.form.clearValidate("password");
+ this.$refs.form.clearValidate("repassword");
+ },
+ },
+};
+
+
\ No newline at end of file
diff --git a/src/views/index.vue b/src/views/index.vue
new file mode 100644
index 0000000..0b631d8
--- /dev/null
+++ b/src/views/index.vue
@@ -0,0 +1,206 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ userName }}
+
登陆
+
+
+
+

+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/vite.config.js b/vite.config.js
index 049dfee..75e65d1 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -14,5 +14,18 @@ export default defineConfig({
Components({
resolvers: [ElementPlusResolver()],
}),
- ],
+ ],
+ css: {
+ preprocessorOptions: {
+ less: {
+ // Less 配置项
+ modifyVars: {
+ 'primary-color': '#1DA57A',
+ 'link-color': '#1DA57A',
+ 'border-radius-base': '2px',
+ },
+ javascriptEnabled: true,
+ },
+ },
+ },
})