Explorar o código

修改成vite启动。

yangzhijie1488@163.com %!s(int64=4) %!d(string=hai) anos
pai
achega
9feccb6390

+ 6 - 0
bat/debug-fast.bat

@@ -0,0 +1,6 @@
+title dev
+set current_path="%~dp0"
+cd %current_path%
+cd ..
+npm run dev-vite
+pause

+ 0 - 7
config/dev.env.js

@@ -1,7 +0,0 @@
-'use strict'
-const merge = require('webpack-merge')
-const prodEnv = require('./prod.env')
-
-module.exports = merge(prodEnv, {
-  NODE_ENV: '"development"'
-})

+ 0 - 79
config/index.js

@@ -1,79 +0,0 @@
-'use strict'
-// Template version: 1.3.1
-// see http://vuejs-templates.github.io/webpack for documentation.
-
-const path = require('path')
-
-module.exports = {
-  dev: {
-
-    // Paths
-    assetsSubDirectory: 'static',
-    assetsPublicPath: '/',
-    proxyTable: {},
-
-    // Various Dev Server settings
-    host: 'localhost', // can be overwritten by process.env.HOST
-    port: 8091, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
-    autoOpenBrowser: false,
-    errorOverlay: true,
-    notifyOnErrors: true,
-    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
-
-    // Use Eslint Loader?
-    // If true, your code will be linted during bundling and
-    // linting errors and warnings will be shown in the console.
-    // useEslint: true,
-    useEslint: false,
-    // If true, eslint errors and warnings will also be shown in the error overlay
-    // in the browser.
-    showEslintErrorsInOverlay: false,
-
-    /**
-     * Source Maps
-     */
-
-    // https://webpack.js.org/configuration/devtool/#development
-    devtool: 'cheap-module-eval-source-map',
-
-    // If you have problems debugging vue-files in devtools,
-    // set this to false - it *may* help
-    // https://vue-loader.vuejs.org/en/options.html#cachebusting
-    cacheBusting: true,
-
-    cssSourceMap: true,
-    
-  },
-
-  
-  build: {
-    // Template for index.html
-    index: path.resolve(__dirname, '../dist/index.html'),
-
-    // Paths
-    assetsRoot: path.resolve(__dirname, '../dist'),
-    assetsSubDirectory: 'static',
-    assetsPublicPath: '/child/client-trace/',
-
-    /**
-     * Source Maps
-     */
-
-    productionSourceMap: true,
-    // https://webpack.js.org/configuration/devtool/#production
-    devtool: '#source-map',
-
-    // Gzip off by default as many popular static hosts such as
-    // Surge or Netlify already gzip all static assets for you.
-    // Before setting to `true`, make sure to:
-    // npm install --save-dev compression-webpack-plugin
-    productionGzip: false,
-    productionGzipExtensions: ['js', 'css'],
-
-    // Run the build command with an extra argument to
-    // View the bundle analyzer report after build finishes:
-    // `npm run build --report`
-    // Set to `true` or `false` to always turn it on or off
-    bundleAnalyzerReport: process.env.npm_config_report
-  }
-}

+ 0 - 4
config/prod.env.js

@@ -1,4 +0,0 @@
-'use strict'
-module.exports = {
-  NODE_ENV: '"production"'
-}

+ 46 - 0
index.html

@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<html>
+
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width,initial-scale=1.0">
+  <title>client-trace</title>
+
+  <link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap.min.css">
+  <link rel="stylesheet" type="text/css" href="./bootstrap/css/bootstrap-dialog.min.css">
+  <link rel="stylesheet" type="text/css" href="./bootstrap-treeview/bootstrap-treeview.css">
+  <!-- 由于字体不能正常的加载,已经使用require css的方式,在main.js中,使用webpack加载css -->
+  <link rel="stylesheet" type="text/css" href="./summernote-0.8.18/summernote.min.css">
+
+  <link rel="stylesheet" type="text/css" href="./dhtmlxgantt/dhtmlxgantt.css">
+
+  <script src="./bootstrap/js/jquery.min.js"></script>
+  <script src="./bootstrap/js/jquery.cookie.js"></script>
+
+  <script src="./moment/moment.min.js"></script>
+  <script src="./moment/moment.zh-cn.js"></script>
+
+  <script src="./bootstrap/js/bootstrap.js"></script>
+  <script src="./bootstrap/js/bootstrap-dialog.min.js"></script>
+
+  <script src="./bootstrap-treeview/bootstrap-treeview.js"></script>
+  <script src="./summernote-0.8.18/summernote.min.js"></script>
+  <script src="./summernote-0.8.18/lang/summernote-zh-CN.min.js"></script>
+
+  <script src="./dhtmlxgantt/dhtmlxgantt.js"></script>
+  <script src="./dhtmlxgantt/locale/locale_cn.js"></script>
+  <script src="./dhtmlxgantt/ext/dhtmlxgantt_auto_scheduling.js"></script>
+  <script src="./dhtmlxgantt/ext/dhtmlxgantt_smart_rendering.js"></script>
+  <script src="./dhtmlxgantt/ext/dhtmlxgantt_undo.js"></script>
+  <script src="./dhtmlxgantt/ext/dhtmlxgantt_fullscreen.js"></script>
+  <script src="./dhtmlxgantt/ext/api.js"></script>
+  
+</head>
+
+<body>
+  <div id="app-client-trace"></div>
+  <!-- built files will be auto injected -->
+  <script type="module" src="/src/main.js"></script>
+</body>
+
+</html>

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 867 - 21
package-lock.json


+ 5 - 0
package.json

@@ -5,6 +5,7 @@
   "author": "yangzhijie <yangzhijie1488@163.com>",
   "private": true,
   "scripts": {
+    "dev-vite": "vite",
     "dev": "webpack serve --config ./webpack.dev.js",
     "build": "cross-env NODE_ENV=production webpack --mode=production --config ./webpack.prod.js --progress"
   },
@@ -24,6 +25,7 @@
     "@babel/core": "^7.17.5",
     "@babel/eslint-parser": "^7.17.0",
     "@babel/preset-env": "^7.16.11",
+    "@vitejs/plugin-vue": "^2.3.3",
     "babel-loader": "^8.2.3",
     "cross-env": "^7.0.3",
     "css-loader": "^6.7.0",
@@ -34,6 +36,9 @@
     "html-webpack-plugin": "^5.5.0",
     "mini-css-extract-plugin": "^2.6.0",
     "style-loader": "^3.3.1",
+    "vite": "^2.9.9",
+    "vite-plugin-externals": "^0.5.0",
+    "vite-plugin-qiankun": "^1.0.14",
     "vue-loader": "^17.0.0",
     "webpack": "^5.70.0",
     "webpack-cli": "^4.9.2",

+ 2 - 2
src/common/Common.js

@@ -1,7 +1,7 @@
-var Notify = require('pc-component-v3').default.Notify;
+import { Notify } from 'pc-component-v3';
 
 
-module.exports = {
+export default{
   pageSize: 20,
 
 

+ 1 - 1
src/lang/Language.js

@@ -1,4 +1,4 @@
-module.exports = {
+export default{
     /**
      * 获取国际化的菜单名称
      */

+ 10 - 4
src/lang/en-US.js

@@ -1,6 +1,12 @@
-export const lang = {
-  login: {
-    login: 'Login',
+const langEnUs = {
+  lang: {
+    login: {
+      login: 'Login',
+    },
   },
-    
+};
+
+
+export {
+  langEnUs,
 };

+ 10 - 4
src/lang/zh-CN.js

@@ -1,6 +1,12 @@
-export const lang = {
-  login: {
-    login: '登陆',
+const langZhCn = {
+  lang : {
+    login: {
+      login: '登陆',
+    },
   },
+};
 
-};
+
+export {
+  langZhCn,
+} ;

+ 44 - 9
src/main.js

@@ -1,6 +1,8 @@
 // The Vue build version to load with the `import` command
 // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
 import './public-path.js';
+import { renderWithQiankun, qiankunWindow } from 'vite-plugin-qiankun/dist/helper';
+
 import { createApp } from 'vue';
 import { createRouter, createWebHashHistory } from 'vue-router';
 import { createI18n } from 'vue-i18n';
@@ -13,6 +15,9 @@ import VueDOMPurifyHTML from 'vue-dompurify-html';
 
 import Antd from 'ant-design-vue';
 
+import 'jquery';
+
+
 // bug fixed by jack 
 // 在加载 css 的时候 font 不能被正确的加载
 // import './assets/summernote.css';
@@ -20,12 +25,15 @@ import Antd from 'ant-design-vue';
 import 'ant-design-vue/dist/antd.css';
 
 
+import { langZhCn } from './lang/zh-CN.js';
+import { langEnUs } from './lang/en-US.js';
+
 let instance = null;
 let i18n = createI18n({
   locale: 'zh-CN',
   messages: {
-    'zh-CN': require('./lang/zh-CN.js'),
-    'en-US': require('./lang/en-US.js'),
+    'zh-CN': langZhCn,
+    'en-US': langEnUs,
   },
 });
 
@@ -46,12 +54,6 @@ function render(props = {}) {
   instance.mount(container ? container.querySelector('#app-client-trace') : '#app-client-trace');
 }
 
-
-// 独立运行时
-if (!window.__POWERED_BY_QIANKUN__) {
-  render();
-}
-
 /**
  * bootstrap 只会在微应用初始化的时候调用一次,下次微应用重新进入时会直接调用 mount 钩子,不会再重复触发 bootstrap。
  * 通常我们可以在这里做一些全局变量的初始化,比如不会在 unmount 阶段被销毁的应用级别的缓存等。
@@ -78,4 +80,37 @@ export async function unmount() {
   instance.unmount();
   instance._container.innerHTML = '';
   instance = null;
-}
+}
+
+
+
+
+// vite 环境下 
+renderWithQiankun({
+  mount(props) {
+    console.log('[client-eam-v3] props from main framework', props);
+    render(props);
+    instance.config.globalProperties.$onGlobalStateChange = props.onGlobalStateChange;
+    instance.config.globalProperties.$setGlobalState = props.setGlobalState;
+  },
+  bootstrap() {
+    console.log('[client-eam-v3] bootstraped');
+  },
+  unmount(props) {
+    instance.unmount();
+    instance._container.innerHTML = '';
+    instance = null;
+  },
+});
+
+
+if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
+  // vite 环境下
+  render({});
+}
+
+// webpack 环境下
+// 独立运行时
+// if (!window.__POWERED_BY_QIANKUN__) {
+//   render();
+// }

+ 29 - 29
src/trace/ProjectManagement.vue

@@ -21,11 +21,18 @@
 <script>
 import Common from '../common/Common.js';
 
-
+import gantt from 'gantt';
 import GanttScale from '../widget/GanttScale2.vue';
 
 
 export default {
+
+  components: {
+    
+    
+    
+    GanttScale,
+  },
   data: function () {
     return {
       title: '',
@@ -35,11 +42,27 @@ export default {
     };
   },
 
-  components: {
-    
-    
-    
-    GanttScale,
+
+  mounted: function () {
+    var _self = this;
+    _self.projectId = this.$route.params.projectId;
+    console.log(_self.projectId);
+    _self.initData();
+    _self.personnelJurisdictionSet();
+
+    // window.ganttTimer = setInterval(() => {
+    // 	// 某些定时器操作  
+    // 	_self.runSaveGantt();
+    // }, 60000);
+
+
+  },
+
+  beforeUnmount: function () {
+    // if (window.ganttTimer != null) {
+    //   window.clearInterval(ganttTimer);
+    //   window.ganttTimer = null;
+    // }
   },
 
   methods: {
@@ -548,28 +571,5 @@ export default {
       _self.showTaskDtos();
     },
   },
-
-
-  mounted: function () {
-    var _self = this;
-    _self.projectId = this.$route.params.projectId;
-    console.log(_self.projectId);
-    _self.initData();
-    _self.personnelJurisdictionSet();
-
-    // window.ganttTimer = setInterval(() => {
-    // 	// 某些定时器操作  
-    // 	_self.runSaveGantt();
-    // }, 60000);
-
-
-  },
-
-  beforeUnmount: function () {
-    // if (window.ganttTimer != null) {
-    //   window.clearInterval(ganttTimer);
-    //   window.ganttTimer = null;
-    // }
-  },
 };
 </script>

+ 2 - 2
src/trace/TraceResource.js

@@ -1,6 +1,6 @@
-var Common = require('../common/Common.js');
+import Common from '../common/Common.js';
 
-module.exports = {
+export default{
 
   /**
      * 查询Trace

+ 27 - 26
src/widget/GanttScale2.vue

@@ -50,9 +50,15 @@
 
 import Common from '../common/Common.js';
 
+import gantt from 'gantt';
 
 
 export default {
+
+  components: {
+    
+    
+  },
   /**
 		 * ganttDivId : 甘特图DIV的id
 		 */
@@ -71,10 +77,27 @@ export default {
       create: false,
     };
   },
-
-  components: {
-    
-    
+  watch: {
+    scale: function(newValue, oldValue) {
+      this.setScaleConfig(newValue);
+    },
+    showGantt: function(newValue, oldValue) {
+      if (newValue == 1) {
+        gantt.config.undo = true;
+        gantt.config.redo = true;
+        gantt.config.auto_scheduling = true;
+        gantt.autoSchedule();
+      } else if (newValue == 2) {
+        gantt.config.undo = false;
+        gantt.config.redo = false;
+        gantt.config.auto_scheduling = false;
+      }
+    },
+  },
+  mounted: function() {
+    var _self = this;
+    _self.getTemplate();
+    _self.personnelJurisdictionSet();
   },
 
   methods: {
@@ -439,28 +462,6 @@ export default {
       });
     },
   },
-  watch: {
-    scale: function(newValue, oldValue) {
-      this.setScaleConfig(newValue);
-    },
-    showGantt: function(newValue, oldValue) {
-      if (newValue == 1) {
-        gantt.config.undo = true;
-        gantt.config.redo = true;
-        gantt.config.auto_scheduling = true;
-        gantt.autoSchedule();
-      } else if (newValue == 2) {
-        gantt.config.undo = false;
-        gantt.config.redo = false;
-        gantt.config.auto_scheduling = false;
-      }
-    },
-  },
-  mounted: function() {
-    var _self = this;
-    _self.getTemplate();
-    _self.personnelJurisdictionSet();
-  },
 };
 </script>
 

+ 1 - 1
src/widget/UpladFile.js

@@ -1,4 +1,4 @@
-module.exports = {
+export default{
   /**
 	 *三个参数
 	 *  file:一个是文件(类型是图片格式),

+ 75 - 0
vite.config.js

@@ -0,0 +1,75 @@
+import { defineConfig } from 'vite';
+import vue from '@vitejs/plugin-vue';
+import qiankun from 'vite-plugin-qiankun';
+import { viteExternalsPlugin } from 'vite-plugin-externals';
+
+// useDevMode 开启时与热更新插件冲突,使用变量切换
+const useDevMode = true;
+
+// https://vitejs.dev/config/
+export default defineConfig({
+  plugins: [
+    vue(),
+    viteExternalsPlugin({
+      jquery: 'jquery',
+      moment: 'moment',
+      gantt: 'gantt',
+      // 支持值链式取值,会转换成 window['jquery']['jgrid']
+      //jgrid: ['jQuery', 'jgrid']
+    }),
+    qiankun('client-trace-v3', {
+      useDevMode,
+    }),
+  ],
+  //base: './',
+
+  base: 'http://127.0.0.1:8091/',
+
+  resolve: {
+    extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json'],
+    //alias: [{ find: '@/', replacement: '/src/' }],
+  },
+  // build: {
+  //   target: "esnext",
+  //   lib: {
+  //     name: `client-eam-v3-[name]`,
+  //     entry: path.resolve(__dirname, "src/main.js"),
+  //     formats: ["umd"],
+  //   },
+  // },
+  server: {
+    port: 8091,
+    host: 'localhost',
+    open: '/',
+    headers: {
+      'Access-Control-Allow-Origin': '*',
+    },
+    proxy: {
+      '/api': {
+        target: 'http://localhost:83/',
+        ws: false,
+        changeOrigin: true,
+      },
+      '/authApi': {
+        target: 'http://localhost:83/',
+        ws: false,
+        changeOrigin: true,
+      },
+      '/Dictionary': {
+        target: 'http://localhost:83/',
+        ws: false,
+        changeOrigin: true,
+      },
+      '/Files': {
+        target: 'http://localhost:83/',
+        ws: false,
+        changeOrigin: true,
+      },
+      '/WebSocket': {
+        target: 'http://localhost:83/',
+        ws: true,
+        changeOrigin: true,
+      },
+    },
+  },
+});

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio