测试 用electron + springboot 构建桌面应用
he wei
2022-03-18 b6861e1ae7f114737a7b383fc4ab0dba3653b01e
src/main/demo/src/views/selectFile.vue
@@ -6,13 +6,12 @@
      drag
      :auto-upload="false"
      :on-change="change"
      @drop.native="drop"
      accept=".fbx"
    >
      <!-- <i class="icon el-icon-plus"></i> -->
      <div class="el-upload__text">将文件拖到此处,或点击此处选择文件</div>
      <div class="el-upload__tip" slot="tip">
        只能解析.fbx文件
      </div>
      <div class="el-upload__text">将.fbx文件拖到此处,或点击此处选择文件</div>
      <div class="el-upload__tip" slot="tip">只能解析.fbx文件</div>
    </el-upload>
  </div>
</template>
@@ -33,26 +32,29 @@
    change(file) {
      // let $el = this.$refs.input;
      // console.log($el.files[0].path);
      if (!file || !file.raw || !file.raw.path) {
      if (!file || !file.raw) {
        return false;
      }
      console.log(file);
      if (!/\.fbx$/.test(file.raw.name.toLowerCase().trim())) {
        this.$layer.msg('类型错误');
      this.loadFile(file.raw);
    },
    loadFile(file) {
      if (!/\.fbx$/.test(file.name.toLowerCase().trim())) {
        this.$layer.msg("类型错误");
        return false;
      }
      axios({
        url: "readFboFile",
        method: "POST",
        params: {
          filePath: file.raw.path,
          filePath: file.path,
        },
      }).then((res) => {
        res = res.data;
        console.log(res, res.code, "=========res");
        if (res.code) {
          let data = res.data;
          data.filePath = file.raw.path;
          data.filePath = file.path;
          // 解析成功 跳转到结果页面
          this.$router.push({
            path: "/result",
@@ -63,6 +65,20 @@
        }
      });
    },
    drop(e) {
      // console.log(e);
      //必须要阻止拖拽的默认事件
      e.preventDefault();
      e.stopPropagation();
      //获得拖拽的文件集合
      var files = e.dataTransfer.files;
      console.log(files);
      if (!files) {
        return false;
      }
      this.loadFile(files[0]);
    },
  },
  mounted() {},