管理端配置 (商家中心 后台管理)

  1. 修改nginx配置,示例
    server {
        listen       9000;
        server_name  localhost;
        location /mall/seller {
            alias /Users/yangpei/work/shuidichou_b2b2c_ui/manager-seller/dist;
            try_files $uri $uri/ /index.html $uri/ =404;
            index index.html index.htm;
        }
        location /mall/admin {
            alias /Users/yangpei/work/shuidichou_b2b2c_ui/manager-admin/dist;
            try_files $uri $uri/ /index.html $uri/ =404;
            index index.html index.htm;
        }
    }
  1. 在项目根目录下找到config 下的 index.js文件 修改如下:

     build: {
     // /mall/admin/为你配置的虚拟目录,此处需写绝对路径
     assetsPublicPath: '/mall/admin/'
    
  2. 在项目根目录下找到build 下的 utils.js文件 修改如下:

     if (options.extract) {
       return ExtractTextPlugin.extract({
         use: loaders,
         fallback: 'vue-style-loader',
         // 修改此处 添加或修改publicPath属性如下:
         publicPath: '../../'
       })
     } else {
       return ['vue-style-loader'].concat(loaders)
     }
    
  3. 将项目中的index.html文件中的所有src引入加入虚拟目录前缀,需为绝对路径,示例如下:

image-20190313183526538

  1. 找到项目下router下的index.js文件(即你的路由文件):修改如下:

    // 引入公共方法
    import { Foundation } from '~/ui-utils'
    // 在此处加入base选项,此处Foundation.getAbsolutePath()作用为计算虚拟目录路径
    export default new Router({
     mode: 'history',
     scrollBehavior: () => ({ y: 0 }),
     routes: constantRouterMap,
     base: Foundation.getAbsolutePath()
    })
    
  2. 找到项目中的permission文件,修改其中的跳转 譬如location.replace() 或者next(),修改如下:

    1.next()跳转:
       const _path = location.pathname.substring(12)
       next(`/login?forward=${_path}`)
    2. location.replace()跳转:
       const _path = location.pathname.substring(12)
       window.location.replace(`/mall/admin/login?forward=${_path}`)
    

买家端配置 (pc wap)

  1. 在项目根目录下找到nuxt.config.js文件,找到其中的router选项,添加配置base选项,示例:
    router: {
       base: '/mall/wap/', // base属性值为虚拟目录
     middleware: 'auth-site',
     scrollBehavior: function (to, from, savedPosition) {
       return { x: 0, y: 0 }
     }
    },
    
  2. 修改nuxt.config.js文件中的静态引入,比如script,link,示例如下图所示:

image

  1. 项目中所有href跳转路径需为相对路径。

域名地址修改

上述配置完成之后需要更改项目根目录(ui目录)下的domian文件夹下的domain.js文件,将pro对象下的各个地址后均添加上要配置的虚拟目录路径,示例:

  // 生产环境 /mall/pc等是配置的虚拟目录
  pro: {
    buyer_pc : env.DOMAIN_BUYER_PC || 'https://buyer.javashop.cn/mall/pc',
    buyer_wap: env.DOMAIN_BUYER_WAP || 'https://buyer.javashop.cn/mall/wap',
    seller   : env.DOMAIN_SELLER || 'https://admin.javashop.cn/mall/seller',
    admin    : env.DOMAIN_ADMIN || 'https://admin.javashop.cn/mall/admin'
  }

results matching ""

    No results matching ""