123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- const Path = require('path');
- const Fs = require('fs');
- const Util = Editor.require('packages://hot-update-tools/core/Util.js');
- const OutPut = Editor.require('packages://hot-update-tools/core/OutPut.js');
- Vue.component('serve-tool', {
- template: Fs.readFileSync(Editor.url('packages://hot-update-tools/panel/serve-tool.html'), 'utf-8'),
- mixins: [Editor.require('packages://hot-update-tools/panel/mixin.js')],
- data () {
- return {
- staticFileServer: null,
- staticFileDir: null,
- staticFileUrl: null,
- };
- },
- created () {
- this.$nextTick(() => {
- this.staticFileDir = OutPut.testServerDir;
- });
- },
- methods: {
- onBtnClickSelectHttpDir () {
- let selectPath = [
- OutPut.testServerDir,
- this.staticFileDir,
- Path.join(Editor.projectInfo.path, 'build'),
- Editor.projectInfo.path,
- ];
- for (let i = 0; i < selectPath.length; i++) {
- let item = selectPath[i];
- if (item && Fs.existsSync(item)) {
- selectPath = item;
- break;
- }
- }
- let res = Editor.Dialog.openFile({
- title: '选择目录',
- defaultPath: selectPath,
- properties: ['openDirectory'],
- });
- if (res !== -1) {
- this.staticFileDir = res[0];
- }
- },
- onBtnClickHttpDir () {
- this.openDir(this.staticFileDir);
- },
- },
- });
|