测试 用electron + springboot 构建桌面应用
he wei
2022-03-19 f33d9a4db3d9d1b7956153cbf42d3e506301fddd
U 导出时添加实际容量的图
1个文件已删除
6个文件已修改
1个文件已添加
204 ■■■■ 已修改文件
src/main/demo/123.txt 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/demo/package.json 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/demo/public/icon/1.png 补丁 | 查看 | 原始文档 | blame | 历史
src/main/demo/public/lib/app.jar 补丁 | 查看 | 原始文档 | blame | 历史
src/main/demo/src/background.js 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/demo/src/components/myCharts/NormalLines.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/demo/src/views/result.vue 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/testElectronJ/TestController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/demo/123.txt
File was deleted
src/main/demo/package.json
@@ -1,6 +1,8 @@
{
  "name": "demo",
  "name": "fbx",
  "version": "0.1.0",
  "author": "whychw",
  "description": "解析本地fbx文件 支持导出excel",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
src/main/demo/public/icon/1.png
src/main/demo/public/lib/app.jar
Binary files differ
src/main/demo/src/background.js
@@ -19,7 +19,7 @@
    let pathArr = app.getPath('exe').split('\\');
    pathArr.length = pathArr.length - 1;
    let path = pathArr.join('\\');
    require('child_process').spawn('cmd.exe', ['/c', 'echo '+path+' > 123.txt']);
    // require('child_process').spawn('cmd.exe', ['/c', 'echo '+path+' > 123.txt']);
    serverProcess = require('child_process').spawn('cmd.exe', ['/c', 'testElectronJ.bat'], {
      cwd: path + '/bundled/bin'
@@ -34,12 +34,15 @@
    }))
  }
}
// Menu.setApplicationMenu(null);
if (!isDevelopment) {
  Menu.setApplicationMenu(null);
}
async function createWindow() {
  // Create the browser window.
  const win = new BrowserWindow({
    width: 800,
    height: 600,
    icon: `${__static}/icon/1.png`,
    webPreferences: {
      webSecurity: false,
      // Use pluginOptions.nodeIntegration, leave this alone
@@ -64,7 +67,7 @@
  if (process.env.WEBPACK_DEV_SERVER_URL) {
    // Load the url of the dev server if in development mode
    await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
    if (!process.env.IS_TEST) win.webContents.openDevTools()
    // if (!process.env.IS_TEST) win.webContents.openDevTools()
  } else {
    createProtocol('app')
    // Load the index.html when not in development
@@ -105,7 +108,7 @@
const startUp = function () {
  const requestPromise = require('minimal-request-promise')
  requestPromise.get(appUrl).then(function (response) {
    require('child_process').spawn('cmd.exe', ['/c', 'echo '+JSON.stringify(response)+' success >> 123.txt'])
    // require('child_process').spawn('cmd.exe', ['/c', 'echo '+JSON.stringify(response)+' success >> 123.txt'])
    console.log(response);
    console.log('Server started!');
    createWindow();
@@ -113,7 +116,7 @@
  }, function (response) {
    console.log(response)
    console.log('Waiting for the server start...');
    require('child_process').spawn('cmd.exe', ['/c', 'echo '+JSON.stringify(response)+' error >> 123.txt'])
    // require('child_process').spawn('cmd.exe', ['/c', 'echo '+JSON.stringify(response)+' error >> 123.txt'])
    setTimeout(function () {
      startUp()
    }, 500)
@@ -121,7 +124,7 @@
}
app.on('ready', async () => {
  require('child_process').spawn('cmd.exe', ['/c', 'echo ready >> 123.txt'])
  // require('child_process').spawn('cmd.exe', ['/c', 'echo ready >> 123.txt'])
  startUp()
})
// Exit cleanly on request from parent process in development mode.
src/main/demo/src/components/myCharts/NormalLines.vue
@@ -25,7 +25,7 @@
        type: "line",
        data: []
      }];
      let unit = this.unit;
      let unit = (data ? data.unit : '') || this.unit;
      return {
        animation: false,
        tooltip:{
src/main/demo/src/views/result.vue
@@ -36,6 +36,10 @@
        </flex-box>
      </div>
    </div>
    <!-- 导出用的图表 可变的那组图 -->
    <div class="hideContain">
      <normal-lines id="hideChart" ref="hideChart"></normal-lines>
    </div>
  </flex-layout>
</template>
@@ -86,6 +90,7 @@
      actualCapOption: null,
      residualCapOption: null,
      residualTimeOption: null,
      unit: ''
    };
  },
  methods: {
@@ -174,6 +179,7 @@
        series: SingleVol,
      };
      let testCapOption = {
          unit: 'AH',
          xData: times,
          series: [
            {
@@ -186,6 +192,7 @@
          ],
        },
        actualCapOption = {
          unit: 'AH',
          xData: times,
          series: [
            {
@@ -198,6 +205,7 @@
          ],
        },
        residualCapOption = {
          unit: 'AH',
          xData: times,
          series: [
            {
@@ -210,6 +218,7 @@
          ],
        },
        residualTimeOption = {
          unit: '',
          xData: times,
          series: [
            {
@@ -241,23 +250,22 @@
    },
    // 导出报表
    exportExcel() {
      // axios({
      //   url: 'export',
      //   method: 'POST',
      //   params: {
      //     filePath: this.info.filePath
      //   }
      // }).then((res) => {
      //   res = res.data;
      //   console.log(res, '======res');
      // });
      // 容量折线图
      let arr = ['testCap', 'actualCap'];
      let o_pic = {};
      arr.forEach((v) => {
        let option = this[v + 'Option'];
        this.unit = option.unit;
        this.$refs.hideChart.setData(option);
        o_pic[v] = this.$refs.hideChart.getDataURL();
      });
      let params = {
        filePath: this.info.filePath,
        groupVol_echart: this.$refs.groupVol.getDataURL(),
        curr_echart: this.$refs.groupCurr.getDataURL(),
        vol_echart: this.$refs.vol.getDataURL(),
        cap_echart: this.$refs.cap.getDataURL(),
        cap_echart: o_pic.testCap,
        actualCap_echart: o_pic.actualCap
      };
      let baseURL = axios.defaults.baseURL;
      baseURL = baseURL ? baseURL : "";
@@ -326,4 +334,10 @@
.flex-row + .flex-row {
  margin-top: 8px;
}
.hideContain {
  position: absolute;
  width: 0;
  height: 0;
  display: none;
}
</style>
src/main/java/testElectronJ/TestController.java
@@ -140,7 +140,7 @@
        //属性栏
        String[] rowName = {"测试时间","总电压","测试容量","剩余容量"};
        HSSFRow row = sheet1.createRow(rowNum);
        for (int i=0;i<rowName.length;){
        for (int i=0;i<rowName.length;i++){
            row.createCell(i).setCellValue(rowName[i]);
        }
        //row.createCell(0).setCellValue("测试时间"); //创建单元格