Browse Source

添加双页面应用

jinsy 7 years ago
parent
commit
de93cf29ff

+ 57 - 0
frontend/saas-portal-web/build/utils.js

@@ -83,6 +83,63 @@ exports.styleLoaders = function (options) {
   return output
   return output
 }
 }
 
 
+/* 这里是添加的部分 ---------------------------- 开始 */
+// glob是webpack安装时依赖的一个第三方模块,还模块允许你使用 *等符号, 例如lib/*.js就是获取lib文件夹下的所有js后缀名的文件
+var glob = require('glob')
+// 页面模板
+var HtmlWebpackPlugin = require('html-webpack-plugin')
+// 取得相应的页面路径,因为之前的配置,所以是src文件夹下的pages文件夹
+var PAGE_PATH = path.resolve(__dirname, '../src/pages')
+// 用于做相应的merge处理
+var merge = require('webpack-merge')
+
+
+//多入口配置
+// 通过glob模块读取pages文件夹下的所有对应文件夹下的js后缀文件,如果该文件存在
+// 那么就作为入口处理
+exports.entries = function () {
+    var entryFiles = glob.sync(PAGE_PATH + '/*/*.js')
+    var map = {}
+    entryFiles.forEach((filePath) => {
+        var filename = filePath.substring(filePath.lastIndexOf('\/') + 1, filePath.lastIndexOf('.'))
+        map[filename] = filePath
+    })
+    return map
+}
+
+//多页面输出配置
+// 与上面的多页面入口配置相同,读取pages文件夹下的对应的html后缀文件,然后放入数组中
+exports.htmlPlugin = function () {
+    let entryHtml = glob.sync(PAGE_PATH + '/*/*.html')
+    let arr = []
+    entryHtml.forEach((filePath) => {
+        let filename = filePath.substring(filePath.lastIndexOf('\/') + 1, filePath.lastIndexOf('.'))
+        let conf = {
+            // 模板来源
+            template: filePath,
+            // 文件名称
+            filename: filename + '.html',
+            // 页面模板需要加对应的js脚本,如果不加这行则每个页面都会引入所有的js脚本
+            chunks: ['manifest', 'vendor', filename],
+            inject: true
+        }
+        if (process.env.NODE_ENV === 'production') {
+            conf = merge(conf, {
+                minify: {
+                    removeComments: true,
+                    collapseWhitespace: true,
+                    removeAttributeQuotes: true
+                },
+                chunksSortMode: 'dependency'
+            })
+        }
+        arr.push(new HtmlWebpackPlugin(conf))
+    })
+    return arr
+}
+/* 这里是添加的部分 ---------------------------- 结束 */
+
+
 exports.createNotifierCallback = () => {
 exports.createNotifierCallback = () => {
   const notifier = require('node-notifier')
   const notifier = require('node-notifier')
 
 

+ 8 - 3
frontend/saas-portal-web/build/webpack.base.conf.js

@@ -12,9 +12,14 @@ function resolve (dir) {
 
 
 module.exports = {
 module.exports = {
   context: path.resolve(__dirname, '../'),
   context: path.resolve(__dirname, '../'),
-  entry: {
-    app: './src/main.js'
-  },
+
+ /* 修改部分 ---------------- 开始 */
+ entry: utils.entries(),
+ /* 修改部分 ---------------- 结束 */
+
+  // entry: {
+  //   app: './src/main.js'
+  // },
   output: {
   output: {
     path: config.build.assetsRoot,
     path: config.build.assetsRoot,
     filename: '[name].js',
     filename: '[name].js',

+ 11 - 6
frontend/saas-portal-web/build/webpack.dev.conf.js

@@ -52,11 +52,15 @@ const devWebpackConfig = merge(baseWebpackConfig, {
     new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
     new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
     new webpack.NoEmitOnErrorsPlugin(),
     new webpack.NoEmitOnErrorsPlugin(),
     // https://github.com/ampedandwired/html-webpack-plugin
     // https://github.com/ampedandwired/html-webpack-plugin
-    new HtmlWebpackPlugin({
-      filename: 'index.html',
-      template: 'index.html',
-      inject: true
-    }),
+
+    /* 注释这个区域的文件 ------------- 开始 */
+    // new HtmlWebpackPlugin({
+    //   filename: 'index.html',
+    //   template: 'index.html',
+    //   inject: true
+    // }),
+     /* 注释这个区域的文件 ------------- 结束 */
+
     // copy custom static assets
     // copy custom static assets
     new CopyWebpackPlugin([
     new CopyWebpackPlugin([
       {
       {
@@ -65,7 +69,8 @@ const devWebpackConfig = merge(baseWebpackConfig, {
         ignore: ['.*']
         ignore: ['.*']
       }
       }
     ])
     ])
-  ]
+     /* 添加 .concat(utils.htmlPlugin()) ------------------ */
+  ].concat(utils.htmlPlugin())
 })
 })
 
 
 module.exports = new Promise((resolve, reject) => {
 module.exports = new Promise((resolve, reject) => {

+ 22 - 17
frontend/saas-portal-web/build/webpack.prod.conf.js

@@ -62,22 +62,26 @@ const webpackConfig = merge(baseWebpackConfig, {
     // generate dist index.html with correct asset hash for caching.
     // generate dist index.html with correct asset hash for caching.
     // you can customize output by editing /index.html
     // you can customize output by editing /index.html
     // see https://github.com/ampedandwired/html-webpack-plugin
     // see https://github.com/ampedandwired/html-webpack-plugin
-    new HtmlWebpackPlugin({
-      filename: process.env.NODE_ENV === 'testing'
-        ? 'index.html'
-        : config.build.index,
-      template: 'index.html',
-      inject: true,
-      minify: {
-        removeComments: true,
-        collapseWhitespace: true,
-        removeAttributeQuotes: true
-        // more options:
-        // https://github.com/kangax/html-minifier#options-quick-reference
-      },
-      // necessary to consistently work with multiple chunks via CommonsChunkPlugin
-      chunksSortMode: 'dependency'
-    }),
+
+    /* 注释这个区域的内容 ---------------------- 开始 */
+    // new HtmlWebpackPlugin({
+    //   filename: process.env.NODE_ENV === 'testing'
+    //     ? 'index.html'
+    //     : config.build.index,
+    //   template: 'index.html',
+    //   inject: true,
+    //   minify: {
+    //     removeComments: true,
+    //     collapseWhitespace: true,
+    //     removeAttributeQuotes: true
+    //     // more options:
+    //     // https://github.com/kangax/html-minifier#options-quick-reference
+    //   },
+    //   // necessary to consistently work with multiple chunks via CommonsChunkPlugin
+    //   chunksSortMode: 'dependency'
+    // }),
+     /* 注释这个区域的内容 ---------------------- 结束 */
+
     // keep module.id stable when vendor modules does not change
     // keep module.id stable when vendor modules does not change
     new webpack.HashedModuleIdsPlugin(),
     new webpack.HashedModuleIdsPlugin(),
     // enable scope hoisting
     // enable scope hoisting
@@ -120,7 +124,8 @@ const webpackConfig = merge(baseWebpackConfig, {
         ignore: ['.*']
         ignore: ['.*']
       }
       }
     ])
     ])
-  ]
+     /* 该位置添加 .concat(utils.htmlPlugin()) ------------------- */
+  ].concat(utils.htmlPlugin())
 })
 })
 
 
 if (config.build.productionGzip) {
 if (config.build.productionGzip) {

+ 5 - 3
frontend/saas-portal-web/config/dev.env.js

@@ -8,9 +8,11 @@ module.exports = merge(prodEnv, {
     // 前端地址
     // 前端地址
     web: '"http://192.168.0.181"',
     web: '"http://192.168.0.181"',
     // 后端接口网关
     // 后端接口网关
-    // api: '"http://192.168.253.31:8560"',
-    api: '"http://192.168.0.181:8560"',
+    // api: '"http://192.168.0.181:8560"',
+    //api:'"http://192.168.253.58:8560"',
+    api: '"https://saas-api.usoftchina.com"',
     // 账户中心接口
     // 账户中心接口
-    sso: '"http://192.168.253.12:32323"'
+    // sso: '"http://192.168.253.12:32323"'
+    sso: '"https://sso.ubtob.com"'
   }
   }
 })
 })

+ 1 - 1
frontend/saas-portal-web/config/index.js

@@ -44,7 +44,7 @@ module.exports = {
     // Paths
     // Paths
     assetsRoot: path.resolve(__dirname, '../dist'),
     assetsRoot: path.resolve(__dirname, '../dist'),
     assetsSubDirectory: 'static',
     assetsSubDirectory: 'static',
-    assetsPublicPath: '/',
+    assetsPublicPath: './',
 
 
     /**
     /**
      * Source Maps
      * Source Maps

+ 1 - 0
frontend/saas-portal-web/package.json

@@ -42,6 +42,7 @@
     "extract-text-webpack-plugin": "^3.0.0",
     "extract-text-webpack-plugin": "^3.0.0",
     "file-loader": "^1.1.4",
     "file-loader": "^1.1.4",
     "friendly-errors-webpack-plugin": "^1.6.1",
     "friendly-errors-webpack-plugin": "^1.6.1",
+    "glob": "^7.1.3",
     "html-webpack-plugin": "^2.30.1",
     "html-webpack-plugin": "^2.30.1",
     "jest": "^22.0.4",
     "jest": "^22.0.4",
     "jest-serializer-vue": "^0.3.0",
     "jest-serializer-vue": "^0.3.0",

+ 5 - 2
frontend/saas-portal-web/src/components/conenter/company.vue

@@ -107,7 +107,8 @@
         },
         },
         computed :{
         computed :{
             setTokenPage() {
             setTokenPage() {
-                return this.$url.web + '/set-token.html'
+                return 'http://192.168.253.39/set-token.html'
+                //return this.$url.web + '/set-token.html'
             }
             }
         },
         },
         watch:{
         watch:{
@@ -204,8 +205,10 @@
                     session.account.companyId=id;
                     session.account.companyId=id;
                     session.span = session.timestamp - new Date().getTime();
                     session.span = session.timestamp - new Date().getTime();
                     session.token=mytoken;
                     session.token=mytoken;
+                    // frame.postMessage(JSON.stringify(session), '*');
+                    // window.location.href = this.$url.web
                     frame.postMessage(JSON.stringify(session), '*');
                     frame.postMessage(JSON.stringify(session), '*');
-                    window.location.href = this.$url.web
+                    window.open('http://192.168.253.39:1841/#main','_blank');
                 })
                 })
                 .catch(err=>{
                 .catch(err=>{
                     // console.log('请求失败',err)
                     // console.log('请求失败',err)

+ 2 - 1
frontend/saas-portal-web/src/components/conenter/home.vue

@@ -430,7 +430,8 @@
                 session.account = account
                 session.account = account
                 const frame = window.frames[window.frames.length - 1]
                 const frame = window.frames[window.frames.length - 1]
                 frame.postMessage(JSON.stringify(session), '*')
                 frame.postMessage(JSON.stringify(session), '*')
-                window.location.href = me.$url.web
+                // window.location.href = me.$url.web
+                    window.open('http://192.168.253.39:1841/#main','_blank');
                 // console.log("请求成功",res)
                 // console.log("请求成功",res)
                 phone = ''
                 phone = ''
             })
             })

+ 25 - 0
frontend/saas-portal-web/src/pages/cell/cell.html

@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta http-equiv="X-UA-Compatible" content="ie=edge">
+    <title>Document</title>
+</head>
+<body>
+    <div id="app">hello</div>
+    <script>
+        // iframe接收消息
+        window.addEventListener('message', function(e) {
+            if (e.data == 'removeToken') {
+                if (e.source != window.parent) {
+                    return;
+                }
+                var storeKey = 'app-state-session';
+                localStorage.removeItem(storeKey);
+                window.parent.postMessage("success", "*");
+            }
+        });
+    </script>
+</body>
+</html>

+ 0 - 0
frontend/saas-portal-web/src/pages/cell/cell.js


+ 15 - 0
frontend/saas-portal-web/src/pages/cell/cell.vue

@@ -0,0 +1,15 @@
+<template>
+    <div>
+
+    </div>
+</template>
+
+<script>
+    export default {
+        
+    }
+</script>
+
+<style scoped>
+
+</style>

+ 2 - 1
frontend/saas-portal-web/index.html → frontend/saas-portal-web/src/pages/index/index.html

@@ -15,7 +15,8 @@
         <meta name="author" content="优软科技">
         <meta name="author" content="优软科技">
         <meta name="Robots" content="all|index|follow">
         <meta name="Robots" content="all|index|follow">
         
         
-        <link rel="icon" type="image/x-icon" href="./static/img/logo.png"/>
+        <!-- <link rel="icon" type="image/x-icon" href="./static/img/logo.png"/> -->
+        <link rel="icon" type="image/x-icon" href="../../../static/img/logo.png"/>
 
 
         <link rel="stylesheet" href="./static/css/animate.css">
         <link rel="stylesheet" href="./static/css/animate.css">
         <link rel="stylesheet" href="./static/css/bootstrap.min.css">
         <link rel="stylesheet" href="./static/css/bootstrap.min.css">

+ 3 - 3
frontend/saas-portal-web/src/main.js → frontend/saas-portal-web/src/pages/index/index.js

@@ -1,9 +1,9 @@
 
 
 import Vue from 'vue'
 import Vue from 'vue'
-import App from './App'
-import router from './router'
+import App from './index.vue'
+import router from '../../router'
 import Axios from 'axios'
 import Axios from 'axios'
-import store from './store'
+import store from '../../store'
 
 
 Vue.prototype.$ajax = Axios;
 Vue.prototype.$ajax = Axios;
 Vue.config.productionTip = false
 Vue.config.productionTip = false

+ 2 - 1
frontend/saas-portal-web/src/App.vue → frontend/saas-portal-web/src/pages/index/index.vue

@@ -5,7 +5,8 @@
   </div>
   </div>
 </template>
 </template>
 <script>
 <script>
-import footers from './components/footer/footer.vue';
+// import footers from './components/footer/footer.vue';
+import footers from '../../components/footer/footer.vue';
 export default {
 export default {
   name: 'App',
   name: 'App',
   components: {
   components: {