mirror of
https://gitee.com/tengzhinei/Vue-rap.git
synced 2025-12-24 08:12:44 +08:00
添加异常捕获
This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
//代码写在onload里防止阻塞页面渲染
|
||||
window.onload = function () {
|
||||
Rap.config({
|
||||
debug: true,
|
||||
debug: false,
|
||||
default_page: "test/default",
|
||||
app_version: '12',
|
||||
comp_version: {'test_page6': 1},
|
||||
|
||||
2
rap.1.2.6.min.js
vendored
2
rap.1.2.6.min.js
vendored
File diff suppressed because one or more lines are too long
108
rap.laster.js
108
rap.laster.js
@@ -39,6 +39,9 @@
|
||||
|
||||
return {
|
||||
resolve: function (res) {
|
||||
if(result==2){
|
||||
return this;
|
||||
}
|
||||
success_arg = res;
|
||||
result = 1;
|
||||
if (success) {
|
||||
@@ -49,17 +52,18 @@
|
||||
reject: function (res) {
|
||||
error_arg = res;
|
||||
result = 2;
|
||||
var reject_ok=false;
|
||||
if (error) {
|
||||
error(error_arg);
|
||||
} else if (next) {
|
||||
reject_ok=error(error_arg);
|
||||
}
|
||||
if (!reject_ok&&next) {
|
||||
next.reject(res);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
then: function (call, e) {
|
||||
then: function (call) {
|
||||
next = P();
|
||||
success = call;
|
||||
error = e;
|
||||
if (result == 1) {
|
||||
nextCall();
|
||||
} else if (result == 2 ) {
|
||||
@@ -73,10 +77,16 @@
|
||||
return next;
|
||||
},
|
||||
catch: function (e) {
|
||||
next = P();
|
||||
this.then(function () {
|
||||
next.resolve();
|
||||
});
|
||||
error = e;
|
||||
if (result == 2) {
|
||||
error(error_arg);
|
||||
}
|
||||
next.parent = this;
|
||||
return next;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -192,7 +202,12 @@
|
||||
if (Rap.debug) {
|
||||
script += "//@ sourceURL=" + modUrl;
|
||||
}
|
||||
eval(script);
|
||||
try {
|
||||
eval(script);
|
||||
}catch (e){
|
||||
throw e;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -246,6 +261,9 @@
|
||||
|
||||
var RapReady = null;
|
||||
|
||||
var onPageLoadError=function () {
|
||||
|
||||
};
|
||||
|
||||
var Rap = {
|
||||
config: function (config) {
|
||||
@@ -267,6 +285,9 @@
|
||||
}
|
||||
var loadCss = Rap.loadCss(config.css);
|
||||
var loadScript = Rap.loadScript(config.script);
|
||||
if(config.onPageLoadError){
|
||||
onPageLoadError=config.onPageLoadError;
|
||||
}
|
||||
Rap.promise(function () {
|
||||
return loadCss;
|
||||
}).then(function () {
|
||||
@@ -676,6 +697,12 @@
|
||||
} else {
|
||||
this.loadMod(Rap.global_router.page).then(function () {
|
||||
Rap.onViewChangeCallBack(modName);
|
||||
}).catch(function (e) {
|
||||
console.log(Rap.global_router.page+'页面加载错误');
|
||||
console.log(e);
|
||||
if(onPageLoadError){
|
||||
onPageLoadError(Rap.global_router.page,e);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -729,10 +756,7 @@
|
||||
try {
|
||||
content = Cache.get(key_content);
|
||||
var json = JSON.parse(content);
|
||||
evalScript(modUrl + ".js", url, modName, json).then(function () {
|
||||
p.resolve();
|
||||
});
|
||||
return p;
|
||||
return evalScript(modUrl + ".js", url, modName, json);
|
||||
} catch (e) {
|
||||
Cache.remove(key_content);
|
||||
}
|
||||
@@ -741,12 +765,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
rapGet(modUrl + '.html?version=' + version).then(function (content) {
|
||||
var template = "";
|
||||
var style = "";
|
||||
var script = "";
|
||||
return rapGet(modUrl + '.html?version=' + version).then(function (content) {
|
||||
var el = document.createElement('div');
|
||||
el.innerHTML = content;
|
||||
var style = "";
|
||||
var template = "";
|
||||
var script = "";
|
||||
var links = [];
|
||||
for (var i = 0; i < el.children.length; i++) {
|
||||
var child = el.children[i];
|
||||
@@ -771,39 +795,35 @@
|
||||
})
|
||||
})(i);
|
||||
}
|
||||
|
||||
promise.then(function () {
|
||||
var compile = Vue.compile(template);
|
||||
var lc = {
|
||||
render: compile.render,
|
||||
staticRenderFns: compile.staticRenderFns,
|
||||
style: style,
|
||||
script: script,
|
||||
name: key_content,
|
||||
base: url
|
||||
};
|
||||
Cache.set(key, version);
|
||||
var lc_json = {
|
||||
render: compile.render.toString(),
|
||||
staticRenderFns: compile.staticRenderFns.toString(),
|
||||
style: style,
|
||||
script: script,
|
||||
name: key_content,
|
||||
base: url
|
||||
};
|
||||
Cache.set(key_content, JSON.stringify(lc_json));
|
||||
return lc;
|
||||
}).then(function (lc) {
|
||||
return evalScript(modUrl + ".js", url, modName, lc);
|
||||
}).then(function () {
|
||||
p.resolve();
|
||||
});
|
||||
|
||||
}).catch(function () {
|
||||
console.log('url:' + modUrl + " get error")
|
||||
return promise;
|
||||
}).then(function () {
|
||||
var compile = Vue.compile(template);
|
||||
var lc = {
|
||||
render: compile.render,
|
||||
staticRenderFns: compile.staticRenderFns,
|
||||
style: style,
|
||||
script: script,
|
||||
name: key_content,
|
||||
base: url
|
||||
};
|
||||
Cache.set(key, version);
|
||||
var lc_json = {
|
||||
render: compile.render.toString(),
|
||||
staticRenderFns: compile.staticRenderFns.toString(),
|
||||
style: style,
|
||||
script: script,
|
||||
name: key_content,
|
||||
base: url
|
||||
};
|
||||
Cache.set(key_content, JSON.stringify(lc_json));
|
||||
return lc;
|
||||
}).then(function (lc) {
|
||||
return evalScript(modUrl + ".js", url, modName, lc);
|
||||
}).catch(function (e) {
|
||||
console.log('url:' + modUrl + " get error");
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
return p;
|
||||
},
|
||||
$query: function () {
|
||||
var hash = window.location.hash;
|
||||
|
||||
2
rap.laster.min.js
vendored
2
rap.laster.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user