wu
2025-10-30 3124ce87407fe85f6780b3ba1a219d8d9e8d7475
UI-Project/src/views/LoginView.vue
@@ -20,11 +20,9 @@
  userName: '',
  password: '',
})
if (typeof route.query.id != 'undefined') {
  userForm.userId = <string>route.query.id
}
const validateUser = (rule: any, value: any, callback: any) => {
  if (value === '') {
    callback(new Error(t('login.userErr')))
@@ -32,7 +30,6 @@
    callback()
  }
}
const validatePass = (rule: any, value: any, callback: any) => {
  if (value === '') {
    callback(new Error(t('login.pwErr')))
@@ -40,14 +37,15 @@
    callback()
  }
}
const rules = reactive<FormRules<typeof userForm>>({
  userId: [{validator: validateUser, trigger: 'blur'}],
  pass: [{validator: validatePass, trigger: 'blur'}],
})
//登陆方法
const submitForm = (formEl: FormInstance | undefined) => {
  store.$patch({
              user: null,
              })
  if (!formEl) return
  formEl.validate((valid) => {
    if (valid) {
@@ -58,12 +56,10 @@
          .then((res) => {
            if (res['code'] == 200) {
              store.$patch({user: res.data})
              console.log(res.data)
              router.push('/main')
              ElMessage.success(t('login.loginSuccessful'))
            } else {
              ElMessage.error(res['msg'])
              // ElMessage.error(res['msg'])
              store.$patch({
              user: null,
              })
@@ -82,16 +78,13 @@
    }
  })
}
function register() {
  router.push({
    path: '/register',
  })
}
let loginLoadings = ref(false)
let registerLoadings = ref(false)
const keyDown = (e) => {
  // 回车则执行登录方法 enter键的ASCII是13
  if (e.keyCode == 13 || e.keyCode == 100) {
@@ -105,17 +98,16 @@
  window.removeEventListener('keydown', keyDown)
})
</script>
<template>
  <div class="mainDiv">
    <div id="main-login">
      <!-- <img
        style="width: 100%; height: 99vh"
        src="../../src/assets/background.jpg"
        src="/background.jpg"
      /> -->
      <div>
        <div style="position: absolute; left: 8vw; top: 6vw; ">
          <img src="../../src/assets/3.png">
          <img src="/3.png">
        </div>
        <div style="position: absolute; left: 15vw; top: 22vw; font-size: 55px;color: rgba(29, 33, 41, 1);">
          {{ $t('northglassMESsystem') }}
@@ -129,7 +121,9 @@
            placeholder=" "
            style="float: right;width: 9rem">
          <el-option value="zh"  label="中文" />
          <el-option value="en"  label="Русский язык" />
          <el-option value="kr"  label="한국어" />
          <el-option value="py"  label="Русский язык" />
          <el-option value="en"  label="English" />
        </el-select>
        <el-form @submit.native.prevent
                 ref="ruleFormRef"
@@ -161,38 +155,34 @@
              <el-button :loading="loginLoadings"
                         type="primary"
                         native-type="submit"
                         style="width: 80px;"
                         @click="submitForm(ruleFormRef)"
                         @keyup.enter.native="keyDown(e)"
                         plain>{{ $t('login.login') }}
              </el-button>
              <el-button :loading="registerLoadings"
              <!-- <el-button :loading="registerLoadings"
                         type="primary"
                         @click="register"
                         plain>{{ $t('login.register') }}
              </el-button>
              </el-button> -->
            </el-form-item>
          </div>
        </el-form>
      </div>
    </div>
  </div>
</template>
<style scoped>
.mainDiv {
  overflow: hidden;
  min-width: 718px;
  background-image: url('../../src/assets/background.jpg');
  background-image: url('/background.jpg');
}
#main-login {
  margin: 150px auto 0 auto;
  height: 70vh;
  width: 80vw;
}
#img-div {
  width: 55%;
  height: 100%;
@@ -201,12 +191,10 @@
  align-items: center;
  float: left;
}
#img-pic {
  max-height: 90%;
  max-width: 100%;
}
#div-login {
  margin-top: 5%;
  /* margin-top: 20%; */
@@ -219,22 +207,18 @@
  border-radius: 4px;
  box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0), 0 6px 5px 0 rgba(0, 0, 0, 0.19);
}
#center {
  margin-top: -30px;
}
.el-form {
  width: 60%;
  margin: 20% auto auto;
}
#submitForm {
  display: flex;
  justify-content: space-evenly;
  margin-top: 2rem;
}
:deep(.el-form-item__content) {
  flex: unset;
}