reghao 2 vuotta sitten
vanhempi
commit
30e0a10627

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 15457
package-lock.json


+ 6 - 1
src/api/user/account.js

@@ -4,7 +4,8 @@ const accountApi = {
   checkUsernameApi: '/api/user/account/check/username',
   selectUsernameApi: '/api/user/account/select/username',
   checkEmailApi: '/api/user/account/check/email',
-  verifyCodeApi: '/api/account/verifyCode',
+  verifyCodeApi: '/api/account/code/verify',
+  captchaCodeApi: '/api/account/code/captcha',
   registerApi: '/api/account/user/register',
   resetPasswordApi: '/api/account/user/reset'
 }
@@ -30,6 +31,10 @@ export function getVerifyCode(verifyCode) {
   return $axios.post(accountApi.verifyCodeApi, verifyCode)
 }
 
+export function getCaptchaCode(captchaCodeApi) {
+  return $axios.get(accountApi.captchaCodeApi)
+}
+
 export function register(userRegistry) {
   return $axios.post(accountApi.registerApi, userRegistry)
 }

+ 1 - 1
src/api/user/auth.js

@@ -1,7 +1,7 @@
 import $axios from '../index'
 
 const authApi = {
-  pubkeyApi: '/api/account/pubkey',
+  pubkeyApi: '/api/account/code/pubkey',
   loginApi: '/api/account/auth/signin',
   logoutApi: '/api/account/auth/signout'
 }

+ 3 - 3
src/components/comment/components/CommentList.js

@@ -2,11 +2,11 @@ export default {
   props: {
     sub: {
       type: Boolean,
-      default: false,
-    },
+      default: false
+    }
   },
   render(h) {
     const className = this.sub ? 'sub-comment-list' : 'comment-list'
     return h('div', { class: className }, this.$slots.default)
-  },
+  }
 }

+ 18 - 13
src/components/login-form-mobile.vue

@@ -31,7 +31,7 @@
     </v-row>
     <v-row justify="center">
       <v-col cols="5">
-        <img :src="captchaUrl" alt="图形验证码" title="点击刷新" style="cursor:pointer;" @click="getCaptcha">
+        <img :src="captchaCode" alt="图形验证码" title="点击刷新" style="cursor:pointer;" @click="getCaptcha">
       </v-col>
       <v-col cols="5">
         <v-text-field
@@ -68,8 +68,7 @@
 </template>
 
 <script>
-import { randomString, getCaptchaUrl } from '@/utils'
-import { getVerifyCode } from '@/api/user/account'
+import { getVerifyCode, getCaptchaCode } from '@/api/user/account'
 import { getPubkey } from '@/api/user/auth'
 import { JSEncrypt } from 'jsencrypt'
 
@@ -77,8 +76,7 @@ export default {
   name: 'Register',
   data() {
     return {
-      captchaUrl: '',
-      captchaBase64: '',
+      captchaCode: '',
       userLogin: {
         accountType: 1,
         loginType: 1,
@@ -86,7 +84,7 @@ export default {
         password: null,
         captchaCode: null,
         r: null,
-        plat: 'web'
+        plat: 1
       },
       pubkey: '',
       pubkeyR: '',
@@ -95,7 +93,6 @@ export default {
     }
   },
   created() {
-    this.getCaptcha()
     this.fetchPubkey()
   },
   methods: {
@@ -121,21 +118,29 @@ export default {
       this.$emit('login', this.userLogin)
     },
     getCaptcha() {
-      const randomStr = randomString(10)
-      this.userLogin.r = randomStr
-      // 图片上发送点击事件时,captchaUrl 的值发生变化,然后才去请求后端
-      this.captchaUrl = getCaptchaUrl(randomStr)
+      getCaptchaCode().then(res => {
+        if (res.code === 0) {
+          this.captchaCode = 'data:image/jpeg;base64,' + res.data
+        } else {
+          this.message = '获取图形验证码失败, 请重新刷新页面'
+          this.showMessage = true
+        }
+      })
     },
     fetchPubkey() {
       getPubkey().then(res => {
         if (res.code === 0) {
           this.pubkey = res.data.pubkey
           this.pubkeyR = res.data.r
+
+          this.getCaptcha()
         } else {
-          alert(res.data)
+          this.message = res.msg
+          this.showMessage = true
         }
       }).catch(error => {
-        console.error(error.message)
+        this.message = error.message
+        this.showMessage = true
       })
     },
     encryptPassword(password, pubkey, pubkeyR) {

+ 1 - 1
src/components/player/player.vue

@@ -139,7 +139,7 @@ export default {
     }
   },
   mounted() {
-    SocketInstance.connect()
+    // SocketInstance.connect()
     const videoId = this.videoProp.videoId
     if (this.getUrl) {
       this.getVideoUrl(videoId)

+ 11 - 21
src/components/register-form.vue

@@ -59,8 +59,7 @@
     </v-row>
     <v-row justify="center">
       <v-col cols="5">
-        <img :src="captchaUrl" alt="图形验证码" title="点击刷新" style="cursor:pointer;" @click="getCaptcha">
-        <!--<img :src="captchaBase64" alt="验证码" title="点击刷新" style="cursor:pointer;" @click="getCaptcha">-->
+        <img :src="captchaCode" alt="图形验证码" title="点击刷新" style="cursor:pointer;" @click="getCaptcha">
       </v-col>
       <v-col cols="5">
         <v-text-field
@@ -79,15 +78,13 @@
 </template>
 
 <script>
-import { randomString, getCaptchaUrl } from '@/utils'
-import { getVerifyCode, isUsernameExist, selectUsername, isEmailExist } from '@/api/user/account'
+import { getVerifyCode, isUsernameExist, selectUsername, isEmailExist, getCaptchaCode } from '@/api/user/account'
 
 export default {
   name: 'Register',
   data() {
     return {
-      captchaUrl: '',
-      captchaBase64: '',
+      captchaCode: '',
       userRegistry: {
         regType: 1,
         email: '',
@@ -169,21 +166,14 @@ export default {
       this.$emit('register', this.userRegistry)
     },
     getCaptcha() {
-      const randomStr = randomString(10)
-      this.userRegistry.r = randomStr
-      // 图片上发送点击事件时,captchaUrl 的值发生变化,然后才去请求后端
-      this.captchaUrl = getCaptchaUrl(randomStr)
-      /* getBase64Captcha(this.captchaUrl)
-        .then(res => {
-          if (res.code === 0) {
-            this.captchaBase64 = 'data:image/jpg;base64,' + res.data
-          } else {
-            alert(res.data)
-          }
-        })
-        .catch(error => {
-          console.error(error.message)
-        })*/
+      getCaptchaCode().then(res => {
+        if (res.code === 0) {
+          this.captchaCode = 'data:image/jpeg;base64,' + res.data
+        } else {
+          this.showMessage = true
+          this.message = '获取图形验证码失败, 请重新刷新页面'
+        }
+      })
     },
     getVerifyCode() {
       const email = this.userRegistry.email

+ 2 - 2
src/components/setting/user-password-setting.vue

@@ -102,7 +102,7 @@ export default {
         verifyCode: ''
       },
       temp: '',
-      captchaUrl: process.env.VUE_APP_BASE_API + '/api/account/captcha',
+      captchaUrl: process.env.VUE_APP_BASE_API + '/api/account/code/captcha',
       showMessage: false,
       message: ''
     }
@@ -111,7 +111,7 @@ export default {
   },
   methods: {
     getCaptcha() {
-      this.captchaUrl = process.env.VUE_APP_BASE_API + '/api/account/captcha?t=' + new Date().getTime()
+      this.captchaUrl = process.env.VUE_APP_BASE_API + '/api/account/code/captcha?t=' + new Date().getTime()
     },
     save() {
       if (this.passoword.oldPassword === '') {

+ 1 - 1
src/store/modules/user.js

@@ -84,7 +84,7 @@ const actions = {
               commit('SET_USER_INFO', userInfo)
               resolve()
             } else {
-              reject(res.data)
+              reject(res.msg)
             }
           }).catch(error => {
             reject(error)

+ 1 - 1
src/utils/index.js

@@ -11,5 +11,5 @@ export function randomString(len) {
 // 获取 captcha url
 export function getCaptchaUrl(r) {
   // 图片上发送点击事件时,captchaUrl 的值发生变化,然后才去请求后端
-  return process.env.VUE_APP_BASE_API + '/api/account/captcha?r=' + r
+  return process.env.VUE_APP_BASE_API + '/api/account/code/captcha?r=' + r
 }

+ 1 - 1
src/views/home/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <v-container fill-height fluid style="padding-left: 24px; padding-right: 24px">
+  <v-container fill-height fluid style="padding-left: 20px; padding-right: 20px">
     <div v-infinite-scroll="loadMore" infinite-scroll-disabled="true" infinite-scroll-distance="10">
       <v-row no-gutters>
         <v-col

+ 7 - 4
src/views/login.vue

@@ -93,17 +93,19 @@ export default {
         // 登录成功后返回到首页
         this.$router.push('/')
       }).catch(error => {
-        this.message = error.data
+        console.log(error)
+        this.message = error.message
         this.showMessage = true
       })
     },
     resetPassword(value) {
       this.$store.dispatch('user/register', value).then(() => {
-        this.message = '注册成功,即将为你跳转到登录页面!'
+        this.message = '重置密码成功,即将为你跳转到登录页面!'
         this.showMessage = true
         this.moveRegister()
       }).catch(() => {
-        alert('用户注册失败')
+        this.message = '重置密码失败'
+        this.showMessage = true
       })
     },
     userRegister(value) {
@@ -112,7 +114,8 @@ export default {
         this.showMessage = true
         this.moveRegister()
       }).catch(() => {
-        alert('用户注册失败')
+        this.message = '用户注册失败'
+        this.showMessage = true
       })
     },
     moveResetPassword() {

+ 28 - 5
src/views/user/home.vue

@@ -124,6 +124,23 @@
         />
       </v-row>
     </v-container>
+    <v-snackbar
+        v-model="showMessage"
+        :top="true"
+        :timeout="1000"
+    >
+      {{ message }}
+      <template v-slot:action="{ attrs }">
+        <v-btn
+            color="pink"
+            text
+            v-bind="attrs"
+            @click="showMessage = false"
+        >
+          关闭
+        </v-btn>
+      </template>
+    </v-snackbar>
   </div>
 </template>
 
@@ -160,7 +177,9 @@ export default {
       currentPage: 1,
       page: 1,
       length: 0,
-      type: 0
+      type: 0,
+      showMessage: false,
+      message: ''
     }
   },
   created() {
@@ -217,7 +236,8 @@ export default {
           this.userInfo = res.data
           document.title = this.userInfo.screenName + ' 的主页'
         } else {
-          alert(res.data)
+          this.message = res.msg
+          this.showMessage = true
         }
       }).catch(error => {
         console.error(error.message)
@@ -237,7 +257,8 @@ export default {
           this.currentPage = pageList.currentPage
           this.length = pageList.totalPages
         } else {
-          alert(res.data)
+          this.message = res.msg
+          this.showMessage = true
         }
       }).catch(error => {
         console.error(error.message)
@@ -257,7 +278,8 @@ export default {
           this.currentPage = pageList.currentPage
           this.length = pageList.totalPages
         } else {
-          alert(res.data)
+          this.message = res.msg
+          this.showMessage = true
         }
       }).catch(error => {
         console.error(error.message)
@@ -277,7 +299,8 @@ export default {
           this.currentPage = pageList.currentPage
           this.length = pageList.totalPages
         } else {
-          alert(res.data)
+          this.message = res.msg
+          this.showMessage = true
         }
       }).catch(error => {
         console.error(error.message)

+ 26 - 4
src/views/user/user-home.vue

@@ -112,6 +112,23 @@
         </v-card-actions>
       </v-card>
     </v-dialog>
+    <v-snackbar
+        v-model="showMessage"
+        :top="true"
+        :timeout="1000"
+    >
+      {{ message }}
+      <template v-slot:action="{ attrs }">
+        <v-btn
+            color="pink"
+            text
+            v-bind="attrs"
+            @click="showMessage = false"
+        >
+          关闭
+        </v-btn>
+      </template>
+    </v-snackbar>
   </div>
 </template>
 
@@ -138,7 +155,9 @@ export default {
       page: 1,
       type: 1,
       isFollowed: false,
-      showDialog: false
+      showDialog: false,
+      showMessage: false,
+      message: ''
     }
   },
   created() {
@@ -177,7 +196,8 @@ export default {
           this.userInfo = res.data
           document.title = this.userInfo.screenName + ' 的主页'
         } else {
-          alert(res.data)
+          this.message = res.msg
+          this.showMessage = true
         }
       }).catch(error => {
         console.error(error.message)
@@ -194,7 +214,8 @@ export default {
             this.cardList.push(item)
           }
         } else {
-          alert(res.data)
+          this.message = res.msg
+          this.showMessage = true
         }
       }).catch(error => {
         console.error(error.message)
@@ -214,7 +235,8 @@ export default {
         if (res.code === 0) {
           this.isFollowed = res.data
         } else {
-          alert(res.data)
+          this.message = res.msg
+          this.showMessage = true
         }
       })
     },

+ 2 - 1
src/views/video/video.vue

@@ -468,7 +468,8 @@ export default {
         if (res.code === 0) {
           this.isFollowed = res.data
         } else {
-          alert(res.data)
+          this.message = res.msg
+          this.showMessage = true
         }
       })
     },

Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä