Commit 0b3a1a94 authored by 任建锋's avatar 任建锋

Merge branch 'dev' into rjf_test

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