Browse Source

添加商城访问限制

huxz 8 years ago
parent
commit
dbce415a4d
7 changed files with 56 additions and 2 deletions
  1. 14 0
      layouts/login.vue
  2. 9 0
      middleware/authenticated.js
  3. 1 1
      pages/auth/login.vue
  4. 1 1
      pages/auth/logout.vue
  5. 15 0
      pages/user/index.vue
  6. 15 0
      pages/vendor/index.vue
  7. 1 0
      plugins/axios.js

+ 14 - 0
layouts/login.vue

@@ -0,0 +1,14 @@
+<template>
+  <div id="app">
+    <nuxt/>
+  </div>
+</template>
+<script>
+
+  export default {
+    name: 'login'
+  }
+</script>
+<style>
+
+</style>

+ 9 - 0
middleware/authenticated.js

@@ -0,0 +1,9 @@
+
+export default function ({ isServer, store, req, redirect }) {
+  // If nuxt generate, pass this middleware
+  if (isServer && !req) return
+
+  if (!store.state.option.user.logged) {
+    redirect('/auth/login')
+  }
+}

+ 1 - 1
pages/auth/login.vue

@@ -1,12 +1,12 @@
 <template>
   <!-- Login 代理页面 -->
   <div>
-    <h1>Login 代理页面</h1>
   </div>
 </template>
 <script>
 
 export default {
+  layout: 'login',
   mounted () {
     this.crossBefore()
   },

+ 1 - 1
pages/auth/logout.vue

@@ -1,12 +1,12 @@
 <template>
   <!-- Login 代理页面 -->
   <div>
-    <h1>Login 代理页面</h1>
   </div>
 </template>
 <script>
 
 export default {
+  layout: 'login',
   mounted () {
     this.crossBefore()
   },

+ 15 - 0
pages/user/index.vue

@@ -0,0 +1,15 @@
+<template>
+  <div class="container" style="height: 300px;line-height: 300px;text-align: center;font-size: 24px;">
+    暂未开放买家中心SSR版
+  </div>
+</template>
+<script>
+
+export default {
+  layout: 'main',
+  middleware: 'authenticated'
+}
+</script>
+<style>
+
+</style>

+ 15 - 0
pages/vendor/index.vue

@@ -0,0 +1,15 @@
+<template>
+  <div class="container" style="height: 300px;line-height: 300px;text-align: center;font-size: 24px;">
+    暂未开放卖家中心SSR版
+  </div>
+</template>
+<script>
+
+export default {
+  layout: 'main',
+  middleware: 'authenticated'
+}
+</script>
+<style>
+
+</style>

+ 1 - 0
plugins/axios.js

@@ -19,6 +19,7 @@ service.interceptors.request.use(config => {
 })
 
 service.interceptors.response.use(response => {
+  // console.log('SESSIONID', response.headers)
   return response
 }, error => {
   return Promise.reject(error)