Browse Source

Merge branch 'master' of ssh://10.10.100.21/source/platform-bi-web

zhuth 7 năm trước cách đây
mục cha
commit
8f25eddc8e
4 tập tin đã thay đổi với 75 bổ sung4 xóa
  1. 65 0
      main.js
  2. 7 1
      package.json
  3. 2 2
      src/models/chartDesigner.js
  4. 1 1
      src/models/chartType.json

+ 65 - 0
main.js

@@ -0,0 +1,65 @@
+const {app, BrowserWindow} = require('electron')
+const path = require('path')
+const url = require('url')
+const pkg = require('./package.json')
+
+// 保持一个对于 window 对象的全局引用,如果你不这样做,
+// 当 JavaScript 对象被垃圾回收, window 会被自动地关闭
+let win
+
+function createWindow () {
+  // 创建浏览器窗口。
+  win = new BrowserWindow({width: 800, height: 600})
+
+  // 然后加载应用的 index.html。
+  // package中的DEV为true时,开启调试窗口。为false时使用编译发布版本
+  if(pkg.DEV){
+    win.loadURL('http://localhost:8000/')
+  }else{
+    win.loadURL(url.format({
+      pathname: path.join(__dirname, './build/index.html'),
+      protocol: 'file:',
+      slashes: true
+    }))
+  }
+
+  // 打开开发者工具。
+  // win.webContents.openDevTools()
+
+  // 当 window 被关闭,这个事件会被触发。
+  win.on('closed', () => {
+    // 取消引用 window 对象,如果你的应用支持多窗口的话,
+    // 通常会把多个 window 对象存放在一个数组里面,
+    // 与此同时,你应该删除相应的元素。
+    win = null
+  })
+}
+
+// Electron 会在初始化后并准备
+// 创建浏览器窗口时,调用这个函数。
+// 部分 API 在 ready 事件触发后才能使用。
+app.on('ready', createWindow)
+
+// 当全部窗口关闭时退出。
+app.on('window-all-closed', () => {
+  // 在 macOS 上,除非用户用 Cmd + Q 确定地退出,
+  // 否则绝大部分应用及其菜单栏会保持激活。
+  if (process.platform !== 'darwin') {
+    app.quit()
+  }
+})
+
+app.on('activate', () => {
+  // 在macOS上,当单击dock图标并且没有其他窗口打开时,
+  // 通常在应用程序中重新创建一个窗口。
+  if (win === null) {
+    createWindow()
+  }
+})
+
+// 在这文件,你可以续写应用剩下主进程代码。
+// 也可以拆分成几个文件,然后用 require 导入。
+// 在这里可以添加一些electron相关的其他模块,比如nodejs的一些原生模块
+// 文件模块
+// const BTFile = require('./sys_modules/BTFile')
+// BTFile.getAppPath()

+ 7 - 1
package.json

@@ -1,10 +1,15 @@
 {
   "private": true,
+  "main": "main.js",
+  "DEV": false,
+  "version": "0.0.1",
   "scripts": {
     "start": "roadhog server",
     "build": "roadhog build",
     "lint": "eslint --ext .js src test",
-    "precommit": "npm run lint"
+    "precommit": "npm run lint",
+    "electron": "electron .",
+    "electron-packager": "electron-packager . myClient --win --out ../myClient --arch=x64 --app-version=0.0.1 --electron-version=2.0.0"
   },
   "dependencies": {
     "ant-design-pro": "^2.0.0-beta.2",
@@ -33,6 +38,7 @@
   "devDependencies": {
     "babel-plugin-dva-hmr": "^0.3.2",
     "babel-plugin-import": "^1.8.0",
+    "electron": "^3.0.1",
     "eslint": "^4.19.1",
     "eslint-config-standard": "^11.0.0",
     "eslint-config-umi": "^0.1.4",

+ 2 - 2
src/models/chartDesigner.js

@@ -518,14 +518,14 @@ export default {
                     let option = parseChartOption('dataView', res.data.data, dataViewConfig);
                     yield put({ type: 'silentSetField', name: 'chartOption', value: option });
                 }else {
-                    message.error('请求列表数据失败: ' + (res.err || res.data.msg));
+                    // message.error('请求列表数据失败: ' + (res.err || res.data.msg));
                     // yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
                 }
                 yield put({ type: 'silentSetField', name: 'fetchConfig', value: body });
             }catch(e) {
                 console.error(e);
                 // yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
-                message.error('请求列表数据失败: ' + e);
+                // message.error('请求列表数据失败: ' + e);
             }
         },
         *fetchAggregateTableData(action, { select, call, put }) {

+ 1 - 1
src/models/chartType.json

@@ -3,6 +3,6 @@
     "Line": "line",
     "Pie": "pie",
     "scatter": "scatter",
-    "population": "population",
+    "population": "aggregateTable",
     "individual": "dataView"
 }