Commit 6c107013 authored by Akikonata's avatar Akikonata

Merge branch 'dev' of https://github.com/fex-team/kityminder into dev

parents 1c150e3d 3dcb9abd
...@@ -75,6 +75,18 @@ ...@@ -75,6 +75,18 @@
localStorage.lastKMVersion = KM.version; localStorage.lastKMVersion = KM.version;
} }
}); });
km.on('unziperror', function(ev){
alert('unziperror');
});
km.on('parseerror', function(ev){
alert('parseerror');
});
km.on('unknownprotocal', function(ev){
alert('unknownprotocal');
});
</script> </script>
<!--Baidu Tongji Code--> <!--Baidu Tongji Code-->
......
...@@ -89,6 +89,7 @@ kity.extendClass(Minder, { ...@@ -89,6 +89,7 @@ kity.extendClass(Minder, {
} }
if (!protocal) { if (!protocal) {
this.fire('unknownprotocal');
throw new Error('Unsupported protocal: ' + protocalName); throw new Error('Unsupported protocal: ' + protocalName);
} }
...@@ -104,7 +105,7 @@ kity.extendClass(Minder, { ...@@ -104,7 +105,7 @@ kity.extendClass(Minder, {
json = params.json || (params.json = protocal.decode(local)); json = params.json || (params.json = protocal.decode(local));
if (typeof json === 'object' && 'then' in json) { if (typeof json === 'object' && 'then' in json){
var self = this; var self = this;
json.then(local, function(data) { json.then(local, function(data) {
self._doImport(data, params); self._doImport(data, params);
...@@ -116,6 +117,7 @@ kity.extendClass(Minder, { ...@@ -116,6 +117,7 @@ kity.extendClass(Minder, {
}, },
_doImport: function(json, params) { _doImport: function(json, params) {
try{
this._fire(new MinderEvent('preimport', params, false)); this._fire(new MinderEvent('preimport', params, false));
// 删除当前所有节点 // 删除当前所有节点
...@@ -138,6 +140,9 @@ kity.extendClass(Minder, { ...@@ -138,6 +140,9 @@ kity.extendClass(Minder, {
this._firePharse({ this._firePharse({
type: 'interactchange' type: 'interactchange'
}); });
}catch(e){
this.fire('rendererror');
}
} }
}); });
\ No newline at end of file
...@@ -73,15 +73,18 @@ KityMinder.registerProtocal( 'freemind', function () { ...@@ -73,15 +73,18 @@ KityMinder.registerProtocal( 'freemind', function () {
} }
return { return {
fileDescription: 'xmind格式文件', fileDescription: 'freemind格式文件',
fileExtension: '.xmind', fileExtension: '.mm',
decode: function ( local ) { decode: function ( local ) {
var json = xml2km( local ); try{
return xml2km( local );
return json; }catch(e){
km.fire('parseerror');
return undefined;
}
}, },
// recognize: recognize, // recognize: null,
recognizePriority: -1 recognizePriority: -1
}; };
......
...@@ -75,7 +75,7 @@ KityMinder.registerProtocal( 'mindmanager', function () { ...@@ -75,7 +75,7 @@ KityMinder.registerProtocal( 'mindmanager', function () {
} }
function onerror(){ function onerror(){
alert('文件过程解压出错,请检查该文件是否损坏'); km.fire('unziperror');
} }
function getEntries( file, onend ) { function getEntries( file, onend ) {
...@@ -99,12 +99,16 @@ KityMinder.registerProtocal( 'mindmanager', function () { ...@@ -99,12 +99,16 @@ KityMinder.registerProtocal( 'mindmanager', function () {
if ( entry.filename == 'Document.xml' ) { if ( entry.filename == 'Document.xml' ) {
hasMainDoc = true; hasMainDoc = true;
entry.getData( new zip.TextWriter(), function ( text ) { entry.getData( new zip.TextWriter(), function ( text ) {
try{
var km = xml2km( $.parseXML( text ) ); var km = xml2km( $.parseXML( text ) );
callback && callback( km ); callback && callback( km );
}catch(e){
km.fire('parseerror');
}
} ); } );
} }
} ); } );
!hasMainDoc && alert('找不到文件主文档,请检查文件是否是合法mindmanager格式文件'); !hasMainDoc && km.fire('parseerror');
} ); } );
} }
}; };
......
...@@ -81,7 +81,7 @@ KityMinder.registerProtocal( 'xmind', function () { ...@@ -81,7 +81,7 @@ KityMinder.registerProtocal( 'xmind', function () {
} }
function onerror(){ function onerror(){
alert('文件过程解压出错,请检查该文件是否损坏'); km.fire('unziperror');
} }
function getEntries(file, onend) { function getEntries(file, onend) {
...@@ -105,13 +105,17 @@ KityMinder.registerProtocal( 'xmind', function () { ...@@ -105,13 +105,17 @@ KityMinder.registerProtocal( 'xmind', function () {
if(entry.filename == 'content.xml'){ if(entry.filename == 'content.xml'){
hasMainDoc = true; hasMainDoc = true;
entry.getData(new zip.TextWriter(), function(text) { entry.getData(new zip.TextWriter(), function(text) {
try{
var km = xml2km($.parseXML(text)); var km = xml2km($.parseXML(text));
callback && callback( km ); callback && callback( km );
}catch(e){
km.fire('parseerror');
}
}); });
} }
}); });
!hasMainDoc && alert('找不到文件主文档,请检查文件是否是合法xmind格式文件'); !hasMainDoc && km.fire('parseerror');
}); });
} }
}; };
......
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