liujq 2 år sedan
förälder
incheckning
cdce5e9b34

+ 1 - 1
src/layout/components/Navbar.vue

@@ -75,7 +75,7 @@ export default {
     async logout() {
       this.$msg('退出登录?', 'confirm', () => {
         window.sessionStorage.clear()
-        window.localStorage.clear()
+        // window.localStorage.clear()
         this.$router.go(0)
       })
       // await this.$store.dispatch('user/logout')

+ 2 - 0
src/store/modules/user.js

@@ -10,6 +10,7 @@ import {
   setStorageMenu,
   getNotify,
   setNotify,
+  setLoginPhone,
 } from '@/utils/auth'
 
 const getDefaultState = () => {
@@ -57,6 +58,7 @@ const actions = {
       Vue.$api.base.admLogin({ phone: username.trim(), password: password }).then(res => {
         if (res.token) {
           setToken(res.token)
+          setLoginPhone(username.trim())
           commit('SET_TOKEN', res.token)
           commit('SYS_USER', res.data)
           setStorageUser(res.data)

+ 4 - 0
src/utils/auth.js

@@ -39,3 +39,7 @@ export function getNotify() {
 export function setNotify(data) {
   return window.sessionStorage.setItem('fp_notify', JSON.stringify(data))
 }
+
+export function setLoginPhone(data) {
+  return window.localStorage.setItem('fp_login_phone', data)
+}

+ 1 - 1
src/utils/request.js

@@ -69,7 +69,7 @@ service.interceptors.response.use(
     if (res.errno !== 0) {
       if (res.errno === 405 || res.errno === 404) {
         window.sessionStorage.clear()
-        window.localStorage.clear()
+        // window.localStorage.clear()
         if (loadingInit) {
           loadingInit.close()
         }

+ 2 - 0
src/views/login/index.vue

@@ -126,6 +126,8 @@ export default {
   },
   created() {
     // window.addEventListener('storage', this.afterQRScan)
+    console.log(this.$localStorage('fp_login_phone'))
+    this.loginForm.username = this.$localStorage('fp_login_phone') || ''
   },
   mounted() {
     if (this.loginForm.username === '') {

+ 1 - 1
vue.config.js

@@ -13,7 +13,7 @@ const name = defaultSettings.title || 'vue Admin Template' // page title
 // For example, Mac: sudo npm run
 // You can change the port by the following methods:
 // port = 9528 npm run dev OR npm run dev --port = 9528
-const port = process.env.port || process.env.npm_config_port || 9528 // dev port
+const port = process.env.port || process.env.npm_config_port || 9001 // dev port
 
 // All configuration item explanations can be find in https://cli.vuejs.org/config/
 module.exports = {