litian
2024-05-28 4e1859708f3c00c9a7b79a3489ac9a6640f8f7b7
src/App.vue
@@ -99,18 +99,36 @@
      .catch(() => {})
  })
}
const getUrlParam = (paraName) => {
  var url = window.location.toString()
  var arrObj = url.split('?')
  if (arrObj.length > 1) {
    var arrPara = arrObj[1].split('&')
    var arr
    for (var i = 0; i < arrPara.length; i++) {
      arr = arrPara[i].split('=')
      if (arr != null && arr[0] == paraName) {
        return arr[1]
      }
    }
    return ''
  } else {
    return ''
  }
}
const token = localStorage.getItem('token')
if (token) {
let tokens = getUrlParam('token')
let bookId = getUrlParam('bookId')
let tryPageCount = getUrlParam('tryPageCount')
localStorage.setItem('bookId', bookId)
localStorage.setItem('tryPageCount', tryPageCount)
const token = localStorage.getItem('token') || tokens
localStorage.setItem('token', token)
if (tokens && bookId) {
  router.replace({
    path: '/home'
    path: '/home',
    query: { bookId: bookId }
  })
  // request({
  //   url: '/identity/User/GetCurrentUser',
  //   method: 'post'
  // }).then((res) => {
  //   // console.log(res)
  // })
} else {
  router.replace({
    path: '/login'