Sfoglia il codice sorgente

打通商城任督二脉

1
mo 2 anni fa
parent
commit
f5d39958f0

+ 2 - 1
config/index.js

@@ -11,7 +11,7 @@ module.exports = {
     assetsSubDirectory: 'static',
     assetsPublicPath: '/',
     proxyTable: {
-      '/api-web': {
+      '/api-mall-admin': {
         target: proxyUrl,
         changeOrigin: true
       },
@@ -28,6 +28,7 @@ module.exports = {
 
     // Various Dev Server settings
     host: 'localhost', // can be overwritten by process.env.HOST
+    useLocalIp: true,
     port: 8090, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
     autoOpenBrowser: false,
     errorOverlay: true,

+ 1 - 1
config/prod.env.js

@@ -3,4 +3,4 @@ module.exports = {
   NODE_ENV: '"production"',
 
 }
-// /   BASE_API: '"http://admin-api.macrozheng.com"'
+BASE_API: '"http://dev.colexiu.com"'

+ 1 - 1
index.html

@@ -3,7 +3,7 @@
   <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width,initial-scale=1.0">
-    <title>mall-admin-web</title>
+    <title>酷乐秀-商城</title>
     <!-- Global site tag (gtag.js) - Google Analytics -->
     <script async src="https://www.googletagmanager.com/gtag/js?id=UA-144208445-2"></script>
     <script>

+ 3 - 2
src/api/login.js

@@ -13,11 +13,12 @@ export function login(username, password) {
 
 export function getInfo() {
   return request({
-    url: '/admin/info',
+    url: '/api-mall-admin/admin/info',
     method: 'get',
   })
 }
-
+// /api-mall-admin/admin/info
+// api-admin/teacherAuthEntryRecord/page
 export function logout() {
   return request({
     url: '/admin/logout',

+ 2 - 0
src/permission.js

@@ -15,6 +15,7 @@ router.beforeEach((to, from, next) => {
     } else {
       if (store.getters.roles.length === 0) {
         store.dispatch('GetInfo').then(res => { // 拉取用户信息
+
           let menus=res.data.menus;
           let username=res.data.username;
           store.dispatch('GenerateRoutes', { menus,username }).then(() => { // 生成可访问的路由表
@@ -22,6 +23,7 @@ router.beforeEach((to, from, next) => {
             next({ ...to, replace: true })
           })
         }).catch((err) => {
+          return
           store.dispatch('FedLogOut').then(() => {
             Message.error(err || 'Verification failed, please login again')
             next({ path: '/' })

+ 2 - 2
src/utils/auth.js

@@ -1,9 +1,9 @@
 import Cookies from 'js-cookie'
-
+import {Session} from './storage'
 const TokenKey = 'loginToken'
 
 export function getToken() {
-  return Cookies.get(TokenKey)
+  return  Session.get('token')
 }
 
 export function setToken(token) {

+ 2 - 0
src/utils/request.js

@@ -14,6 +14,8 @@ service.interceptors.request.use(config => {
   if (store.getters.token) {
     config.headers['Authorization'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
   }
+ config.url.indexOf('/api-mall-admin')== -1? config.url = '/api-mall-admin'+config.url:config.url
+
   return config
 }, error => {
   // Do something with request error

+ 53 - 0
src/utils/storage.js

@@ -0,0 +1,53 @@
+/**
+ * window.localStorage 浏览器永久缓存
+ * @method set 设置永久缓存
+ * @method get 获取永久缓存
+ * @method remove 移除永久缓存
+ * @method clear 移除全部永久缓存
+ */
+export const Local = {
+  // 设置永久缓存
+  set(key, val) {
+    window.localStorage.setItem(key, JSON.stringify(val))
+  },
+  // 获取永久缓存
+  get(key) {
+    let json = window.localStorage.getItem(key)
+    return JSON.parse(json)
+  },
+  // 移除永久缓存
+  remove(key) {
+    window.localStorage.removeItem(key)
+  },
+  // 移除全部永久缓存
+  clear() {
+    window.localStorage.clear()
+  }
+}
+
+/**
+ * window.sessionStorage 浏览器临时缓存
+ * @method set 设置临时缓存
+ * @method get 获取临时缓存
+ * @method remove 移除临时缓存
+ * @method clear 移除全部临时缓存
+ */
+export const Session = {
+  // 设置临时缓存
+  set(key, val) {
+    window.sessionStorage.setItem(key, JSON.stringify(val))
+  },
+  // 获取临时缓存
+  get(key) {
+    let json = window.sessionStorage.getItem(key)
+    return JSON.parse(json)
+  },
+  // 移除临时缓存
+  remove(key) {
+    window.sessionStorage.removeItem(key)
+  },
+  // 移除全部临时缓存
+  clear() {
+    window.sessionStorage.clear()
+  }
+}

+ 4 - 4
src/views/login/index.vue

@@ -9,7 +9,7 @@
         <div style="text-align: center">
           <svg-icon icon-class="login-mall" style="width: 56px;height: 56px;color: #409EFF"></svg-icon>
         </div>
-        <h2 class="login-title color-main">mall-admin-web</h2>
+        <h2 class="login-title color-main">酷乐秀-商城管理系统</h2>
         <el-form-item prop="username">
           <el-input name="username"
                     type="text"
@@ -37,12 +37,12 @@
           </el-input>
         </el-form-item>
         <el-form-item style="margin-bottom: 60px;text-align: center">
-          <el-button style="width: 45%" type="primary" :loading="loading" @click.native.prevent="handleLogin">
+          <el-button style="width: 100%" type="primary" :loading="loading" @click.native.prevent="handleLogin">
             登录
           </el-button>
-          <el-button style="width: 45%" type="primary" @click.native.prevent="handleTry">
+          <!-- <el-button style="width: 45%" type="primary" @click.native.prevent="handleTry">
             获取体验账号
-          </el-button>
+          </el-button> -->
         </el-form-item>
       </el-form>
     </el-card>