Browse Source

修改最长限制--及显示名称

plg 6 months ago
parent
commit
5e3213a6c7
3 changed files with 40 additions and 3 deletions
  1. 12 1
      src/components/CpmdHeader.vue
  2. 2 2
      src/utils/http.ts
  3. 26 0
      src/views/Register.vue

+ 12 - 1
src/components/CpmdHeader.vue

@@ -66,6 +66,17 @@ const comT = () => {
     //跳转到首页
     router.push({ name: 'homeView' })
 }
+//设置显示字段长度
+const formatterName = (val: string) => {
+    if (val == undefined) {
+        return ''
+    }
+    if (val.length > 4) {
+        return val.substring(0, 3) + '...'
+    } else {
+        return val
+    }
+}
 </script>
 
 <template>
@@ -95,7 +106,7 @@ const comT = () => {
         <div class="login_button_bg" @mouseenter="comeMenu" @mouseleave="leaveMenu" v-show="userInfo.userInfo.userName">
             <img width="20px" src="../assets/home/button_login.png" />
             &nbsp;&nbsp;&nbsp;&nbsp;
-            <span>{{ userInfo.userInfo.userName }}</span>
+            <span :title="userInfo.userInfo.userName">{{ formatterName(userInfo.userInfo.userName) }}</span>
             <transition>
                 <div class="login_user" v-show="falgMenu">
                     <div class="update_pass" @click="updatePassFun">

+ 2 - 2
src/utils/http.ts

@@ -11,8 +11,8 @@ const userInfo = userInfoStore()
 //创建axios实例
 
 //创建基础访问路径
-// const base_url = 'http://10.113.248.4:8089/'
-const base_url = 'http://43.143.198.30:8089/'
+const base_url = 'http://10.113.248.4:8089/'
+// const base_url = 'http://43.143.198.30:8089/'
 
 //设置axios 默认访问路径
 axios.defaults.baseURL = base_url

+ 26 - 0
src/views/Register.vue

@@ -80,6 +80,16 @@ const registerFun = async () => {
         isLock.value = false
         return
     }
+    // console.log(account.value)
+    // console.log()
+    if (!/^[A-Za-z0-9]+$/.test(account.value)) {
+        ElMessage({
+            message: '账号只允许输入数字和英文',
+            type: 'warning'
+        })
+        isLock.value = false
+        return
+    }
     if (name.value == '') {
         ElMessage({
             message: '请填写姓名',
@@ -88,6 +98,14 @@ const registerFun = async () => {
         isLock.value = false
         return
     }
+    if (name.value.length > 20) {
+        ElMessage({
+            message: '姓名不能超过20位',
+            type: 'warning'
+        })
+        isLock.value = false
+        return
+    }
     if (sex.value == '') {
         ElMessage({
             message: '请选择性别',
@@ -104,6 +122,14 @@ const registerFun = async () => {
         isLock.value = false
         return
     }
+    if (password.value.length < 6) {
+        ElMessage({
+            message: '密码长度最小6位',
+            type: 'warning'
+        })
+        isLock.value = false
+        return
+    }
     if (comPassword.value == '') {
         ElMessage({
             message: '请填写确认密码',