Merge pull request #39 from i2Echo/master

fix bug
This commit is contained in:
Zhang Chen 2018-01-20 14:18:25 +08:00 committed by GitHub
commit 439c86418c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 11 deletions

View File

@ -47,6 +47,7 @@ body{
white-space: pre;
border: 1px solid #ddd;
border-radius: 2px;
overflow: auto;
}
#editTip{
position: absolute;

1
_server/vendor/polyfill.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n():"function"==typeof define&&define.amd?define(n):n()}(0,function(){"use strict";function e(){}function n(e,n){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,f._immediateFn(function(){var i=1===e._state?n.onFulfilled:n.onRejected;if(null!==i){var r;try{r=i(e._value)}catch(e){return void o(n.promise,e)}t(n.promise,r)}else(1===e._state?t:o)(n.promise,e._value)})):e._deferreds.push(n)}function t(e,n){try{if(n===e)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var t=n.then;if(n instanceof f)return e._state=3,e._value=n,void i(e);if("function"==typeof t)return void r(function(e,n){return function(){e.apply(n,arguments)}}(t,n),e)}e._state=1,e._value=n,i(e)}catch(n){o(e,n)}}function o(e,n){e._state=2,e._value=n,i(e)}function i(e){2===e._state&&0===e._deferreds.length&&f._immediateFn(function(){e._handled||f._unhandledRejectionFn(e._value)});for(var t=0,o=e._deferreds.length;o>t;t++)n(e,e._deferreds[t]);e._deferreds=null}function r(e,n){var i=!1;try{e(function(e){i||(i=!0,t(n,e))},function(e){i||(i=!0,o(n,e))})}catch(e){if(i)return;i=!0,o(n,e)}}function f(e){if(!(this instanceof f))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],r(e,this)}var u=setTimeout,c=f.prototype;c.catch=function(e){return this.then(null,e)},c.then=function(t,o){var i=new this.constructor(e);return n(this,new function(e,n,t){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof n?n:null,this.promise=t}(t,o,i)),i},f.all=function(e){return new f(function(n,t){function o(e,f){try{if(f&&("object"==typeof f||"function"==typeof f)){var u=f.then;if("function"==typeof u)return void u.call(f,function(n){o(e,n)},t)}i[e]=f,0==--r&&n(i)}catch(e){t(e)}}if(!e||void 0===e.length)throw new TypeError("Promise.all accepts an array");var i=Array.prototype.slice.call(e);if(0===i.length)return n([]);for(var r=i.length,f=0;i.length>f;f++)o(f,i[f])})},f.resolve=function(e){return e&&"object"==typeof e&&e.constructor===f?e:new f(function(n){n(e)})},f.reject=function(e){return new f(function(n,t){t(e)})},f.race=function(e){return new f(function(n,t){for(var o=0,i=e.length;i>o;o++)e[o].then(n,t)})},f._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){u(e,0)},f._unhandledRejectionFn=function(e){void 0!==console&&console&&console.warn("Possible Unhandled Promise Rejection:",e)};var a=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==a)return a;throw Error("unable to locate global object")}();a.Promise||(a.Promise=f)});

View File

@ -2,7 +2,9 @@
var exportM = new Vue({
el: '#exportM',
data: {
isExport: false,
},
methods: {
exportMap: function(){
editor.updateMap();
@ -32,6 +34,7 @@ var exportM = new Vue({
}
pout.value = filestr;
editArea.mapArr = filestr;
this.isExport = true;
editArea.error = 0;
tip.whichShow = 2;
}
@ -54,9 +57,13 @@ var editArea = new Vue({
mapArr: function (val, oldval) {
var that = this;
if(val=='') return;
if(exportM.isExport){
exportM.isExport = false;
return;
}
if(that.formatArr()){
that.error = 0;
clearTimeout(that.formatTimer);
setTimeout(function(){
that.mapArr = that.formatArr();
that.drawMap();
@ -98,7 +105,8 @@ var editArea = new Vue({
},
formatArr: function(){
var formatArrStr = '';
var that = this;
clearTimeout(that.formatTimer);
if(this.mapArr.split(/\D+/).join(' ').trim().split(' ').length != 169) return false;
var arr = this.mapArr.replace(/\s+/g, '').split('],[');

View File

@ -101,9 +101,10 @@
<!-- =========================================================== -->
<script src='_server/vendor/vue.min.js'></script>
<script src='_server/vendor/polyfill.min.js'></script>
<!-- <script src="https://cdn.bootcss.com/vue/2.5.13/vue.js"></script> -->
<script src='_server/fs.js'></script>
<script src='_server/editor_file.js'></script>
<!-- <script src='_server/editor_file.js'></script> -->
<script src='_server/vm.js'></script>
<script>
@ -121,7 +122,7 @@ var main={'instance':{}};
var core={};
function editor() {
this.version = "1.2";
this.version = "1.3.2";
this.material = {};
}
// 重构这一堆回调
@ -146,7 +147,8 @@ editor.prototype.init = function(){
});
Promise.all([p1, p2, p3])
.then(function([maps, icons, img]){
.then(function(results){
var maps = results[0], icons = results[1];
editor.idsInit(maps, icons); // 初始化图片素材信息
editor.drawInitData(icons); // 初始化绘图
editor.listen(); // 开始监听事件
@ -449,9 +451,11 @@ editor.prototype.listen = function() {
}//在格子内画一个随机色块
function eToLoc(e) {
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
editor.loc = {
'x': document.documentElement.scrollLeft+e.clientX - mid.offsetLeft-mapEdit.offsetLeft,
'y': document.documentElement.scrollTop+e.clientY - mid.offsetTop-mapEdit.offsetTop,
'x': scrollLeft+e.clientX - mid.offsetLeft-mapEdit.offsetLeft,
'y': scrollTop+e.clientY - mid.offsetTop-mapEdit.offsetTop,
'size': 32
};
return editor.loc; }//返回可用的组件内坐标
@ -579,9 +583,11 @@ editor.prototype.listen = function() {
data.onmousedown = function (e) {
e.stopPropagation();
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop
var loc = {
'x': document.documentElement.scrollLeft + e.clientX + iconLib.scrollLeft - right.offsetLeft-iconLib.offsetLeft,
'y': document.documentElement.scrollTop + e.clientY + iconLib.scrollTop - right.offsetTop-iconLib.offsetTop,
'x': scrollLeft + e.clientX + iconLib.scrollLeft - right.offsetLeft-iconLib.offsetLeft,
'y': scrollTop + e.clientY + iconLib.scrollTop - right.offsetTop-iconLib.offsetTop,
'size': 32
};
editor.loc = loc;
@ -657,7 +663,7 @@ editor.info
var editor = new editor();
editor.init();
editor.fs=fs;
editor.file=editor_file;
// editor.file=editor_file;
</script>
<script>
// 文件相关操作