Commit 73794e8c authored by rockyl's avatar rockyl

过程、脚本、自定义模块代码抽离功能

parent c4b1baed
......@@ -34,8 +34,7 @@ content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, u
<body>
<div id="$CONTAINER_ID$" style="line-height:0;font-size:0"></div>
<script src="${process.env.NODE_ENV === 'development' ? 'http://10.10.94.134:4002/dist/index.js' : 'http://yun.duiba.com.cn/editor/zeroing/libs/engine.b0b81ba7872b4ffaa3cdbe5d440cdb4617b86c5c.js'}"></script>
<script src="http://yun.duiba.com.cn/editor/zeroing/libs/tslib.js"></script>
<script src="${process.env.NODE_ENV === 'development' ? 'http://10.10.94.134:4002/dist/index.js' : 'http://yun.duiba.com.cn/editor/zeroing/libs/engine.a913456caee2ee40c20108a1c4571f61479e54a1.js'}"></script>
<script src="$PROCESSES_URL$"></script>
<script src="$SCRIPTS_URL$"></script>
<script src="$CUSTOMS_URL$"></script>
......
......@@ -130,3 +130,15 @@ export function selectFile(callback, {accept, multiple} = {}) {
}
input.click();
}
export function openPreview(packResult){
setTimeout(() => {
let url;
if(location.host.startsWith('localhost')){
url = packResult.tplUrl;
}else{
url = '/preview?url=http:' + packResult.tplUrl;
}
window.open(url, 'blank');
}, 500);
}
......@@ -260,5 +260,12 @@ export default {
type: 'inputNumber',
value: 20,
},
},
htmlView: {
groupName: 'HTML视图',
htmlElement: {
title: 'HTML内容',
type: 'input',
},
}
}
......@@ -25,7 +25,7 @@
import Playground from "./Editor/Playground";
import Assets from "./Editor/Assets";
import DetailsDialog from "./Editor/dialogs/DetailsDialog";
import {playWaiting} from "../utils";
import {openPreview, playWaiting} from "../utils";
import i18n from "../i18n";
import PackResultDialog from "./Editor/dialogs/PackResultDialog";
......@@ -50,7 +50,7 @@
},
watch: {
$route: {
handler: function(val, oldVal){
handler: function (val, oldVal) {
console.log('router changed');
this.loadProject();
},
......@@ -63,21 +63,22 @@
async mounted() {
document.addEventListener('keydown', this.onKeyPress);
await playWaiting(this.prepare(), this.$t('Preparing')).catch(e => {});
await playWaiting(this.prepare(), this.$t('Preparing')).catch(e => {
});
this.loadProject();
},
destroyed(){
destroyed() {
document.removeEventListener('keydown', this.onKeyPress)
},
methods: {
prepare(){
prepare() {
return Promise.all([
this.updateEnv(),
])
},
onKeyPress(e){
if(e.key === 's' && (e.ctrlKey||e.metaKey)){
onKeyPress(e) {
if (e.key === 's' && (e.ctrlKey || e.metaKey)) {
e.preventDefault();
this.saveProject();
......@@ -85,7 +86,7 @@
return false;
}
},
async loadProject(){
async loadProject() {
const {projectID} = this.$route.params;
if (await this.localVersionExist(projectID)) {
this.$confirm(this.$t('Unsaved version found locally'), this.$t('Alert'), {
......@@ -111,7 +112,7 @@
loadLocalVersion(projectID) {
this.ready = false;
this.loadFromLocal(projectID);
this.$nextTick(()=>{
this.$nextTick(() => {
this.ready = true;
});
},
......@@ -121,7 +122,7 @@
await playWaiting(this.loadFromRemote(projectID), this.$t('Preparing')).catch(e => {
this.$alert(this.$t('Project does not exist'), this.$t('Alert'), {
confirmButtonText: this.$t('Confirm'),
callback: action=>{
callback: action => {
this.$router.replace({name: 'home'});
}
});
......@@ -191,23 +192,22 @@
break;
}
},
async pack(debug = false){
async pack(debug = false) {
const loading = this.$loading({
lock: true,
text: this.$t('Packing'),
});
try{
try {
await this.saveProject(false);
const packResult = await this.packProject(debug);
this.$message({
message: this.$t('Pack project successfully'),
type: 'success',
duration: 1000,
duration: 500,
});
if(debug){setTimeout(()=>{
window.open(packResult.tplUrl, 'blank');
}, 500);
}else{
if (debug) {
openPreview(packResult);
} else {
this.$refs.packResultDialog.show(packResult);
}
/*this.$confirm(this.$t('Pack project successfully'), this.$t('Alert'), {
......@@ -221,7 +221,7 @@
}).catch(() => {
});*/
}catch (e) {
} catch (e) {
this.$message({
message: this.$t('Pack project failed'),
type: 'error',
......
<template>
<el-dialog :title="$t('Meta Editor')" width="80%" :visible.sync="visible"
:close-on-click-modal="false"
:close-on-press-escape="false"
:show-close="false"
:append-to-body="true">
<div class="meta-editor-wrapper">
<el-form ref="form" v-if="meta" :model="meta" :rules="rules" :show-message="false" class="info-editor" size="mini" label-position="right" label-width="70px" @submit.native.prevent>
......@@ -41,9 +43,12 @@
</div>
<!--<el-input v-if="meta" class="script-editor" :readonly=" !editable" type="textarea" :placeholder="$t('Code')"
v-model="meta.script"></el-input>-->
<codemirror ref="myCm" v-if="meta"
<codemirror ref="codeEditor" v-if="meta"
v-model="meta.script"
:options="cmOptions">
:options="cmOptions"
@cursorActivity="onCodeChange"
>
</codemirror>
</div>
<div slot="footer" class="dialog-footer">
......@@ -73,6 +78,9 @@
import 'codemirror/lib/codemirror.css'
import 'codemirror/theme/monokai.css'
import 'codemirror/addon/edit/closebrackets.js'
import 'codemirror/addon/hint/show-hint.js'
import 'codemirror/addon/hint/show-hint.css'
import 'codemirror/addon/hint/javascript-hint.js'
const exposeVariables = ['args', 'props', 'target', 'global', 'vm', 'engine'];
......@@ -95,7 +103,6 @@
],
},
cmOptions: {
// codemirror options
tabSize: 2,
mode: 'text/javascript',
styleActiveLine: true,
......@@ -104,7 +111,6 @@
line: true,
matchBrackets: true,
autoCloseBrackets: true,
// more codemirror options, 更多 codemirror 的高级配置...
}
}
},
......@@ -167,8 +173,9 @@
focusPasteBoard(){
this.$refs.pasteBoard.focus();
},
onCmCodeChange(code){
console.log(code);
onCodeChange(codemirror){
//codemirror.showHint();
//console.log(code);
}
}
}
......
......@@ -18,6 +18,7 @@
<script>
import copy from 'copy-to-clipboard'
import {openPreview} from "../../../utils";
export default {
name: "PackResultDialog",
......@@ -40,9 +41,7 @@
openInNewTab() {
this.visible = false;
setTimeout(()=>{
window.open(this.packResult.tplUrl, 'blank');
}, 500);
openPreview(this.packResult);
},
copy() {
this.visible = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment