Commit fb5bbaff92024cd57cb83ae1b8170171857adadb

Authored by ww
1 parent b35f6248

feat: add import && export function

@@ -722,195 +722,195 @@ App.main = function (callback, createUi) { @@ -722,195 +722,195 @@ App.main = function (callback, createUi) {
722 // is compiled into JS in the build process and is only needed for local development. 722 // is compiled into JS in the build process and is only needed for local development.
723 mxUtils.getAll((urlParams['dev'] != '1') ? [bundle] : [bundle, 723 mxUtils.getAll((urlParams['dev'] != '1') ? [bundle] : [bundle,
724 STYLE_PATH + '/default.xml'], function (xhr) { 724 STYLE_PATH + '/default.xml'], function (xhr) {
725 - // Adds bundle text to resources  
726 - mxResources.parse(xhr[0].getText()); 725 + // Adds bundle text to resources
  726 + mxResources.parse(xhr[0].getText());
727 727
728 - // Configuration mode  
729 - if (isLocalStorage && localStorage != null && window.location.hash != null &&  
730 - window.location.hash.substring(0, 9) == '#_CONFIG_') {  
731 - try {  
732 - var trustedPlugins = {}; 728 + // Configuration mode
  729 + if (isLocalStorage && localStorage != null && window.location.hash != null &&
  730 + window.location.hash.substring(0, 9) == '#_CONFIG_') {
  731 + try {
  732 + var trustedPlugins = {};
733 733
734 - for (var key in App.pluginRegistry) {  
735 - trustedPlugins[App.pluginRegistry[key]] = true;  
736 - } 734 + for (var key in App.pluginRegistry) {
  735 + trustedPlugins[App.pluginRegistry[key]] = true;
  736 + }
737 737
738 - // Only allows trusted plugins  
739 - function checkPlugins(plugins) {  
740 - if (plugins != null) {  
741 - for (var i = 0; i < plugins.length; i++) {  
742 - if (!trustedPlugins[plugins[i]]) {  
743 - throw new Error(mxResources.get('invalidInput') + ' "' + plugins[i]) + '"'; 738 + // Only allows trusted plugins
  739 + function checkPlugins(plugins) {
  740 + if (plugins != null) {
  741 + for (var i = 0; i < plugins.length; i++) {
  742 + if (!trustedPlugins[plugins[i]]) {
  743 + throw new Error(mxResources.get('invalidInput') + ' "' + plugins[i]) + '"';
  744 + }
744 } 745 }
745 } 746 }
746 - }  
747 747
748 - return true;  
749 - }; 748 + return true;
  749 + };
750 750
751 - var value = JSON.parse(Graph.decompress(window.location.hash.substring(9))); 751 + var value = JSON.parse(Graph.decompress(window.location.hash.substring(9)));
752 752
753 - if (value != null && checkPlugins(value.plugins)) {  
754 - EditorUi.debug('Setting configuration', JSON.stringify(value)); 753 + if (value != null && checkPlugins(value.plugins)) {
  754 + EditorUi.debug('Setting configuration', JSON.stringify(value));
755 755
756 - if (value.merge != null) {  
757 - var temp = localStorage.getItem(Editor.configurationKey); 756 + if (value.merge != null) {
  757 + var temp = localStorage.getItem(Editor.configurationKey);
758 758
759 - if (temp != null) { 759 + if (temp != null) {
760 760
761 - try {  
762 - var config = JSON.parse(temp); 761 + try {
  762 + var config = JSON.parse(temp);
763 763
764 - for (var key in value.merge) {  
765 - config[key] = value.merge[key];  
766 - } 764 + for (var key in value.merge) {
  765 + config[key] = value.merge[key];
  766 + }
767 767
768 - value = config; 768 + value = config;
  769 + }
  770 + catch (e) {
  771 + window.location.hash = '';
  772 + alert(e);
  773 + }
769 } 774 }
770 - catch (e) {  
771 - window.location.hash = '';  
772 - alert(e); 775 + else {
  776 + value = value.merge;
773 } 777 }
774 } 778 }
775 - else {  
776 - value = value.merge; 779 +
  780 + if (confirm(mxResources.get('configLinkWarn')) &&
  781 + confirm(mxResources.get('configLinkConfirm'))) {
  782 + localStorage.setItem(Editor.configurationKey, JSON.stringify(value));
  783 + window.location.hash = '';
  784 + window.location.reload();
777 } 785 }
778 } 786 }
779 787
780 - if (confirm(mxResources.get('configLinkWarn')) &&  
781 - confirm(mxResources.get('configLinkConfirm'))) {  
782 - localStorage.setItem(Editor.configurationKey, JSON.stringify(value));  
783 - window.location.hash = '';  
784 - window.location.reload();  
785 - } 788 + window.location.hash = '';
786 } 789 }
  790 + catch (e) {
  791 + window.location.hash = '';
  792 + alert(e);
  793 + }
  794 + }
787 795
788 - window.location.hash = ''; 796 + // Prepares themes with mapping from old default-style to old XML file
  797 + if (xhr.length > 1) {
  798 + Graph.prototype.defaultThemes['default-style2'] = xhr[1].getDocumentElement();
  799 + Graph.prototype.defaultThemes['darkTheme'] = xhr[1].getDocumentElement();
789 } 800 }
790 - catch (e) {  
791 - window.location.hash = '';  
792 - alert(e);  
793 - }  
794 - }  
795 -  
796 - // Prepares themes with mapping from old default-style to old XML file  
797 - if (xhr.length > 1) {  
798 - Graph.prototype.defaultThemes['default-style2'] = xhr[1].getDocumentElement();  
799 - Graph.prototype.defaultThemes['darkTheme'] = xhr[1].getDocumentElement();  
800 - }  
801 -  
802 - // Main  
803 - function realMain() {  
804 - var ui = (createUi != null) ? createUi() : new App(new Editor(  
805 - urlParams['chrome'] == '0' || uiTheme == 'min',  
806 - null, null, null, urlParams['chrome'] != '0'));  
807 -  
808 - if (window.mxscript != null) {  
809 - // Loads dropbox for all browsers but IE8 and below (no CORS) if not disabled or if enabled and in embed mode  
810 - // KNOWN: Picker does not work in IE11 (https://dropbox.zendesk.com/requests/1650781)  
811 - if (typeof window.DropboxClient === 'function' &&  
812 - (window.Dropbox == null && window.DrawDropboxClientCallback != null &&  
813 - (((urlParams['embed'] != '1' && urlParams['db'] != '0') ||  
814 - (urlParams['embed'] == '1' && urlParams['db'] == '1')) &&  
815 - isSvgBrowser && (document.documentMode == null || document.documentMode > 9)))) {  
816 - mxscript(App.DROPBOX_URL, function () {  
817 - // Must load this after the dropbox SDK since they use the same namespace  
818 - mxscript(App.DROPINS_URL, function () {  
819 - DrawDropboxClientCallback();  
820 - }, 'dropboxjs', App.DROPBOX_APPKEY);  
821 - });  
822 - }  
823 - // Disables client  
824 - else if (typeof window.Dropbox === 'undefined' || typeof window.Dropbox.choose === 'undefined') {  
825 - window.DropboxClient = null;  
826 - }  
827 801
828 - // Loads OneDrive for all browsers but IE6/IOS if not disabled or if enabled and in embed mode  
829 - if (typeof window.OneDriveClient === 'function' &&  
830 - (typeof OneDrive === 'undefined' && window.DrawOneDriveClientCallback != null &&  
831 - (((urlParams['embed'] != '1' && urlParams['od'] != '0') || (urlParams['embed'] == '1' &&  
832 - urlParams['od'] == '1')) && (navigator.userAgent == null ||  
833 - navigator.userAgent.indexOf('MSIE') < 0 || document.documentMode >= 10)))) {  
834 - //Editor.oneDriveInlinePicker can be set with configuration which is done later, so load it all time  
835 - mxscript(App.ONEDRIVE_URL, window.DrawOneDriveClientCallback);  
836 - }  
837 - // Disables client  
838 - else if (typeof window.OneDrive === 'undefined') {  
839 - window.OneDriveClient = null;  
840 - } 802 + // Main
  803 + function realMain() {
  804 + var ui = (createUi != null) ? createUi() : new App(new Editor(
  805 + urlParams['chrome'] == '0' || uiTheme == 'min',
  806 + null, null, null, urlParams['chrome'] != '0'));
841 807
842 - // Loads Trello for all browsers but < IE10 if not disabled or if enabled and in embed mode  
843 - if (typeof window.TrelloClient === 'function' && !mxClient.IS_IE11 &&  
844 - typeof window.Trello === 'undefined' && window.DrawTrelloClientCallback != null &&  
845 - urlParams['tr'] == '1' && (navigator.userAgent == null ||  
846 - navigator.userAgent.indexOf('MSIE') < 0 || document.documentMode >= 10)) {  
847 - mxscript(App.TRELLO_JQUERY_URL, function () {  
848 - // Must load this after the dropbox SDK since they use the same namespace  
849 - mxscript(App.TRELLO_URL, function () {  
850 - DrawTrelloClientCallback(); 808 + if (window.mxscript != null) {
  809 + // Loads dropbox for all browsers but IE8 and below (no CORS) if not disabled or if enabled and in embed mode
  810 + // KNOWN: Picker does not work in IE11 (https://dropbox.zendesk.com/requests/1650781)
  811 + if (typeof window.DropboxClient === 'function' &&
  812 + (window.Dropbox == null && window.DrawDropboxClientCallback != null &&
  813 + (((urlParams['embed'] != '1' && urlParams['db'] != '0') ||
  814 + (urlParams['embed'] == '1' && urlParams['db'] == '1')) &&
  815 + isSvgBrowser && (document.documentMode == null || document.documentMode > 9)))) {
  816 + mxscript(App.DROPBOX_URL, function () {
  817 + // Must load this after the dropbox SDK since they use the same namespace
  818 + mxscript(App.DROPINS_URL, function () {
  819 + DrawDropboxClientCallback();
  820 + }, 'dropboxjs', App.DROPBOX_APPKEY);
851 }); 821 });
852 - });  
853 - }  
854 - // Disables client  
855 - else if (typeof window.Trello === 'undefined') {  
856 - window.TrelloClient = null;  
857 - }  
858 -  
859 - } 822 + }
  823 + // Disables client
  824 + else if (typeof window.Dropbox === 'undefined' || typeof window.Dropbox.choose === 'undefined') {
  825 + window.DropboxClient = null;
  826 + }
860 827
861 - if (callback != null) {  
862 - callback(ui);  
863 - } 828 + // Loads OneDrive for all browsers but IE6/IOS if not disabled or if enabled and in embed mode
  829 + if (typeof window.OneDriveClient === 'function' &&
  830 + (typeof OneDrive === 'undefined' && window.DrawOneDriveClientCallback != null &&
  831 + (((urlParams['embed'] != '1' && urlParams['od'] != '0') || (urlParams['embed'] == '1' &&
  832 + urlParams['od'] == '1')) && (navigator.userAgent == null ||
  833 + navigator.userAgent.indexOf('MSIE') < 0 || document.documentMode >= 10)))) {
  834 + //Editor.oneDriveInlinePicker can be set with configuration which is done later, so load it all time
  835 + mxscript(App.ONEDRIVE_URL, window.DrawOneDriveClientCallback);
  836 + }
  837 + // Disables client
  838 + else if (typeof window.OneDrive === 'undefined') {
  839 + window.OneDriveClient = null;
  840 + }
864 841
865 - /**  
866 - * For developers only  
867 - */  
868 - if (urlParams['chrome'] != '0' && urlParams['test'] == '1') {  
869 - EditorUi.debug('App.start', [ui, (new Date().getTime() - t0.getTime()) + 'ms']); 842 + // Loads Trello for all browsers but < IE10 if not disabled or if enabled and in embed mode
  843 + if (typeof window.TrelloClient === 'function' && !mxClient.IS_IE11 &&
  844 + typeof window.Trello === 'undefined' && window.DrawTrelloClientCallback != null &&
  845 + urlParams['tr'] == '1' && (navigator.userAgent == null ||
  846 + navigator.userAgent.indexOf('MSIE') < 0 || document.documentMode >= 10)) {
  847 + mxscript(App.TRELLO_JQUERY_URL, function () {
  848 + // Must load this after the dropbox SDK since they use the same namespace
  849 + mxscript(App.TRELLO_URL, function () {
  850 + DrawTrelloClientCallback();
  851 + });
  852 + });
  853 + }
  854 + // Disables client
  855 + else if (typeof window.Trello === 'undefined') {
  856 + window.TrelloClient = null;
  857 + }
870 858
871 - if (urlParams['export'] != null) {  
872 - EditorUi.debug('Export:', EXPORT_URL);  
873 } 859 }
874 - }  
875 - };  
876 860
877 - if (urlParams['dev'] == '1' || EditorUi.isElectronApp) //TODO check if we can remove these scripts loading from index.html  
878 - {  
879 - realMain();  
880 - }  
881 - else {  
882 - mxStencilRegistry.allowEval = false;  
883 - let loadScriptList = [  
884 - 'js/shapes-14-6-5.min.js',  
885 - 'js/stencils.min.js',  
886 - 'js/extensions.min.js'  
887 - ]  
888 - if (Enable_OSS) {  
889 - loadScriptList = [  
890 - `${OSS_Prefix}shapes-14-6-5.min.js`,  
891 - `${OSS_Prefix}stencils.min.js`,  
892 - `${OSS_Prefix}extensions.min.js`  
893 - ]  
894 - }  
895 - // const shapesMinSrc = 'js/shapes-14-6-5.min.js'  
896 - // const stenclisMinSrc = 'js/stencils.min.js'  
897 - // const extensionsMinSrc = 'js/extensions.min.js'  
898 - App.loadScripts(loadScriptList, realMain);  
899 - }  
900 - }, function (xhr) {  
901 - var st = document.getElementById('geStatus'); 861 + if (callback != null) {
  862 + callback(ui);
  863 + }
902 864
903 - if (st != null) {  
904 - st.innerHTML = 'Error loading page. <a>Please try refreshing.</a>'; 865 + /**
  866 + * For developers only
  867 + */
  868 + if (urlParams['chrome'] != '0' && urlParams['test'] == '1') {
  869 + EditorUi.debug('App.start', [ui, (new Date().getTime() - t0.getTime()) + 'ms']);
905 870
906 - // Tries reload with default resources in case any language resources were not available  
907 - st.getElementsByTagName('a')[0].onclick = function () {  
908 - mxLanguage = 'en';  
909 - doLoad(mxResources.getDefaultBundle(RESOURCE_BASE, mxLanguage) ||  
910 - mxResources.getSpecialBundle(RESOURCE_BASE, mxLanguage)); 871 + if (urlParams['export'] != null) {
  872 + EditorUi.debug('Export:', EXPORT_URL);
  873 + }
  874 + }
911 }; 875 };
912 - }  
913 - }); 876 +
  877 + if (urlParams['dev'] == '1' || EditorUi.isElectronApp) //TODO check if we can remove these scripts loading from index.html
  878 + {
  879 + realMain();
  880 + }
  881 + else {
  882 + mxStencilRegistry.allowEval = false;
  883 + let loadScriptList = [
  884 + 'js/shapes-14-6-5.min.js',
  885 + 'js/stencils.min.js',
  886 + 'js/extensions.min.js'
  887 + ]
  888 + if (Enable_OSS) {
  889 + loadScriptList = [
  890 + `${OSS_Prefix}shapes-14-6-5.min.js`,
  891 + `${OSS_Prefix}stencils.min.js`,
  892 + `${OSS_Prefix}extensions.min.js`
  893 + ]
  894 + }
  895 + // const shapesMinSrc = 'js/shapes-14-6-5.min.js'
  896 + // const stenclisMinSrc = 'js/stencils.min.js'
  897 + // const extensionsMinSrc = 'js/extensions.min.js'
  898 + App.loadScripts(loadScriptList, realMain);
  899 + }
  900 + }, function (xhr) {
  901 + var st = document.getElementById('geStatus');
  902 +
  903 + if (st != null) {
  904 + st.innerHTML = 'Error loading page. <a>Please try refreshing.</a>';
  905 +
  906 + // Tries reload with default resources in case any language resources were not available
  907 + st.getElementsByTagName('a')[0].onclick = function () {
  908 + mxLanguage = 'en';
  909 + doLoad(mxResources.getDefaultBundle(RESOURCE_BASE, mxLanguage) ||
  910 + mxResources.getSpecialBundle(RESOURCE_BASE, mxLanguage));
  911 + };
  912 + }
  913 + });
914 }; 914 };
915 915
916 function doMain() { 916 function doMain() {
@@ -3547,9 +3547,9 @@ App.prototype.pickLibrary = function (mode) { @@ -3547,9 +3547,9 @@ App.prototype.pickLibrary = function (mode) {
3547 // Removes openFile if dialog is closed 3547 // Removes openFile if dialog is closed
3548 this.showDialog(new OpenDialog(this).container, (Editor.useLocalStorage) ? 640 : 360, 3548 this.showDialog(new OpenDialog(this).container, (Editor.useLocalStorage) ? 640 : 360,
3549 (Editor.useLocalStorage) ? 480 : 220, true, true, function () { 3549 (Editor.useLocalStorage) ? 480 : 220, true, true, function () {
3550 - Editor.useLocalStorage = prevValue;  
3551 - window.openFile = null;  
3552 - }); 3550 + Editor.useLocalStorage = prevValue;
  3551 + window.openFile = null;
  3552 + });
3553 } 3553 }
3554 }; 3554 };
3555 3555
@@ -4221,7 +4221,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { @@ -4221,7 +4221,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) {
4221 function getUserPermission() { 4221 function getUserPermission() {
4222 defHttp.get('/yt/role/me/permissions') 4222 defHttp.get('/yt/role/me/permissions')
4223 .then(res => { 4223 .then(res => {
4224 - USER_PERMISSION.permission = res 4224 + USER_PERMISSION.permission = res
4225 updateButtonContainer() 4225 updateButtonContainer()
4226 // var flag = hasSavePermission() 4226 // var flag = hasSavePermission()
4227 // if (!flag) { 4227 // if (!flag) {
@@ -4234,7 +4234,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { @@ -4234,7 +4234,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) {
4234 // 调用API,获取保存的内容 4234 // 调用API,获取保存的内容
4235 function getSaveContent() { 4235 function getSaveContent() {
4236 defHttp.get('/yt/configuration/center/get_configuration_info/' + Editor.configurationId) 4236 defHttp.get('/yt/configuration/center/get_configuration_info/' + Editor.configurationId)
4237 - .then(function (response) { 4237 + .then(function (response) {
4238 getUserPermission() 4238 getUserPermission()
4239 4239
4240 const { platform } = response || {} 4240 const { platform } = response || {}
@@ -4282,7 +4282,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) { @@ -4282,7 +4282,7 @@ App.prototype.loadFile = function (id, sameWindow, file, success, force) {
4282 } 4282 }
4283 4283
4284 }) 4284 })
4285 - .catch(function (error) { 4285 + .catch(function (error) {
4286 }); 4286 });
4287 } 4287 }
4288 4288
@@ -5022,17 +5022,75 @@ App.prototype.updateButtonContainer = function () { @@ -5022,17 +5022,75 @@ App.prototype.updateButtonContainer = function () {
5022 !this.isOfflineApp()) { 5022 !this.isOfflineApp()) {
5023 if (file != null) { 5023 if (file != null) {
5024 if (this.shareButton == null) { 5024 if (this.shareButton == null) {
  5025 + this.buttonContainer.className = 'thingskit-button-container'
  5026 +
  5027 + this.leftContainer = document.createElement('div')
  5028 + this.leftContainer.className = 'left-button-container'
  5029 + this.buttonContainer.appendChild(this.leftContainer)
  5030 +
  5031 + this.rightContainer = document.createElement('div')
  5032 + this.rightContainer.className = 'right-button-container'
  5033 + this.buttonContainer.appendChild(this.rightContainer)
  5034 +
  5035 + // TODO thingsKit 导入按钮
  5036 + this.importButton = document.createElement('div');
  5037 + this.importButton.className = 'geBtn gePrimaryBtn';
  5038 + this.importButton.style.display = 'inline-block';
  5039 + this.importButton.style.backgroundColor = '#2474f9';
  5040 + this.importButton.style.borderColor = '#2474f9';
  5041 + this.importButton.style.backgroundImage = 'none';
  5042 + this.importButton.style.marginTop = '-10px';
  5043 + this.importButton.style.lineHeight = '28px';
  5044 + this.importButton.style.minWidth = '0px';
  5045 + this.importButton.setAttribute('title', '导入');
  5046 + this.importButton.setAttribute('id', 'thingskitImportButton');
  5047 + mxUtils.write(this.importButton, '导入');
  5048 + mxEvent.addListener(this.importButton, 'click', mxUtils.bind(this, function () {
  5049 + this.currentFile.ui.actions.get('open').funct()
  5050 + console.log(this)
  5051 + }));
  5052 + this.leftContainer.appendChild(this.importButton);
  5053 +
  5054 + // TODO thingsKit 导出案例
  5055 + this.exportButton = document.createElement('div');
  5056 + this.exportButton.className = 'geBtn gePrimaryBtn';
  5057 + this.exportButton.style.display = 'inline-block';
  5058 + this.exportButton.style.backgroundColor = '#2474f9';
  5059 + this.exportButton.style.borderColor = '#2474f9';
  5060 + this.exportButton.style.backgroundImage = 'none';
  5061 + this.exportButton.style.marginTop = '-10px';
  5062 + this.exportButton.style.lineHeight = '28px';
  5063 + this.exportButton.style.minWidth = '0px';
  5064 + this.exportButton.setAttribute('title', '导出');
  5065 + this.exportButton.setAttribute('id', 'thingskitExportButton');
  5066 + mxUtils.write(this.exportButton, '导出');
  5067 + mxEvent.addListener(this.exportButton, 'click', mxUtils.bind(this, function () {
  5068 +
  5069 + function savefiles(data, name) {
  5070 + const blob = new Blob([data]);
  5071 + const el = document.createElementNS("http://www.w3.org/1999/xhtml", "a")
  5072 + const href = URL.createObjectURL(blob);
  5073 + el.href = href
  5074 + el.download = name;
  5075 + el.click();
  5076 + URL.revokeObjectURL(href)
  5077 + el.remove()
  5078 + }
  5079 +
  5080 + savefiles(this.currentFile.data, '未命名.xml')
  5081 + }));
  5082 + this.leftContainer.appendChild(this.exportButton);
  5083 +
5025 // TODO thingsKit 锁定 / 解锁 按钮 5084 // TODO thingsKit 锁定 / 解锁 按钮
5026 this.lockButton = document.createElement('div'); 5085 this.lockButton = document.createElement('div');
5027 this.lockButton.className = 'geBtn gePrimaryBtn'; 5086 this.lockButton.className = 'geBtn gePrimaryBtn';
5028 this.lockButton.style.display = 'inline-block'; 5087 this.lockButton.style.display = 'inline-block';
5029 - this.lockButton.style.backgroundColor = '#F2931E';  
5030 - this.lockButton.style.borderColor = '#F08705'; 5088 + this.lockButton.style.backgroundColor = '#2474f9';
  5089 + this.lockButton.style.borderColor = '#2474f9';
5031 this.lockButton.style.backgroundImage = 'none'; 5090 this.lockButton.style.backgroundImage = 'none';
5032 this.lockButton.style.marginTop = '-10px'; 5091 this.lockButton.style.marginTop = '-10px';
5033 this.lockButton.style.lineHeight = '28px'; 5092 this.lockButton.style.lineHeight = '28px';
5034 this.lockButton.style.minWidth = '0px'; 5093 this.lockButton.style.minWidth = '0px';
5035 - this.lockButton.style.cssFloat = 'right';  
5036 this.lockButton.setAttribute('title', '锁定 / 解锁'); 5094 this.lockButton.setAttribute('title', '锁定 / 解锁');
5037 mxUtils.write(this.lockButton, '锁定 / 解锁'); 5095 mxUtils.write(this.lockButton, '锁定 / 解锁');
5038 mxEvent.addListener(this.lockButton, 'click', mxUtils.bind(this, function () { 5096 mxEvent.addListener(this.lockButton, 'click', mxUtils.bind(this, function () {
@@ -5040,38 +5098,36 @@ App.prototype.updateButtonContainer = function () { @@ -5040,38 +5098,36 @@ App.prototype.updateButtonContainer = function () {
5040 this.actions.actions.lockUnlock.funct() 5098 this.actions.actions.lockUnlock.funct()
5041 } 5099 }
5042 })); 5100 }));
5043 - this.buttonContainer.appendChild(this.lockButton); 5101 + this.rightContainer.appendChild(this.lockButton);
5044 5102
5045 // TODO thingsKit 预览模式按钮 5103 // TODO thingsKit 预览模式按钮
5046 this.shareButton = document.createElement('div'); 5104 this.shareButton = document.createElement('div');
5047 this.shareButton.className = 'geBtn gePrimaryBtn'; 5105 this.shareButton.className = 'geBtn gePrimaryBtn';
5048 this.shareButton.style.display = 'inline-block'; 5106 this.shareButton.style.display = 'inline-block';
5049 - this.shareButton.style.backgroundColor = '#F2931E';  
5050 - this.shareButton.style.borderColor = '#F08705'; 5107 + this.shareButton.style.backgroundColor = '#2474f9';
  5108 + this.shareButton.style.borderColor = '#2474f9';
5051 this.shareButton.style.backgroundImage = 'none'; 5109 this.shareButton.style.backgroundImage = 'none';
5052 this.shareButton.style.marginTop = '-10px'; 5110 this.shareButton.style.marginTop = '-10px';
5053 this.shareButton.style.lineHeight = '28px'; 5111 this.shareButton.style.lineHeight = '28px';
5054 this.shareButton.style.minWidth = '0px'; 5112 this.shareButton.style.minWidth = '0px';
5055 - this.shareButton.style.cssFloat = 'right';  
5056 this.shareButton.setAttribute('title', '预览'); 5113 this.shareButton.setAttribute('title', '预览');
5057 mxUtils.write(this.shareButton, '预览'); 5114 mxUtils.write(this.shareButton, '预览');
5058 mxEvent.addListener(this.shareButton, 'click', mxUtils.bind(this, function () { 5115 mxEvent.addListener(this.shareButton, 'click', mxUtils.bind(this, function () {
5059 const href = window.location.href + '&lightbox=1' 5116 const href = window.location.href + '&lightbox=1'
5060 window.open(href) 5117 window.open(href)
5061 })); 5118 }));
5062 - this.buttonContainer.appendChild(this.shareButton); 5119 + this.rightContainer.appendChild(this.shareButton);
5063 5120
5064 // TODO thingsKit 保存按钮 5121 // TODO thingsKit 保存按钮
5065 this.saveButton = document.createElement('div'); 5122 this.saveButton = document.createElement('div');
5066 this.saveButton.className = 'geBtn gePrimaryBtn'; 5123 this.saveButton.className = 'geBtn gePrimaryBtn';
5067 this.saveButton.style.display = 'inline-block'; 5124 this.saveButton.style.display = 'inline-block';
5068 - this.saveButton.style.backgroundColor = '#F2931E';  
5069 - this.saveButton.style.borderColor = '#F08705'; 5125 + this.saveButton.style.backgroundColor = '#2474f9';
  5126 + this.saveButton.style.borderColor = '#2474f9';
5070 this.saveButton.style.backgroundImage = 'none'; 5127 this.saveButton.style.backgroundImage = 'none';
5071 this.saveButton.style.marginTop = '-10px'; 5128 this.saveButton.style.marginTop = '-10px';
5072 this.saveButton.style.lineHeight = '28px'; 5129 this.saveButton.style.lineHeight = '28px';
5073 this.saveButton.style.minWidth = '0px'; 5130 this.saveButton.style.minWidth = '0px';
5074 - this.saveButton.style.cssFloat = 'right';  
5075 this.saveButton.setAttribute('title', '保存'); 5131 this.saveButton.setAttribute('title', '保存');
5076 this.saveButton.setAttribute('id', 'thingskitSaveButton'); 5132 this.saveButton.setAttribute('id', 'thingskitSaveButton');
5077 mxUtils.write(this.saveButton, '保存'); 5133 mxUtils.write(this.saveButton, '保存');
@@ -5082,45 +5138,8 @@ App.prototype.updateButtonContainer = function () { @@ -5082,45 +5138,8 @@ App.prototype.updateButtonContainer = function () {
5082 : 'save') 5138 : 'save')
5083 .funct(); 5139 .funct();
5084 })); 5140 }));
5085 - this.buttonContainer.appendChild(this.saveButton);  
5086 -  
5087 -  
5088 -  
5089 - // this.shareButton = document.createElement('div');  
5090 - // this.shareButton.className = 'geBtn gePrimaryBtn';  
5091 - // this.shareButton.style.display = 'inline-block';  
5092 - // this.shareButton.style.backgroundColor = '#F2931E';  
5093 - // this.shareButton.style.borderColor = '#F08705';  
5094 - // this.shareButton.style.backgroundImage = 'none';  
5095 - // this.shareButton.style.padding = '2px 10px 0 10px';  
5096 - // this.shareButton.style.marginTop = '-10px';  
5097 - // this.shareButton.style.height = '28px';  
5098 - // this.shareButton.style.lineHeight = '28px';  
5099 - // this.shareButton.style.minWidth = '0px';  
5100 - // this.shareButton.style.cssFloat = 'right';  
5101 - // this.shareButton.setAttribute('title', mxResources.get('share'));  
5102 - //  
5103 - // var icon = document.createElement('img');  
5104 - // icon.setAttribute('src', this.shareImage);  
5105 - // icon.setAttribute('align', 'absmiddle');  
5106 - // icon.style.marginRight = '4px';  
5107 - // icon.style.marginTop = '-3px';  
5108 - // this.shareButton.appendChild(icon);  
5109 - //  
5110 - // if (!Editor.isDarkMode() && uiTheme != 'atlas')  
5111 - // {  
5112 - // this.shareButton.style.color = 'black';  
5113 - // icon.style.filter = 'invert(100%)';  
5114 - // }  
5115 - //  
5116 - // mxUtils.write(this.shareButton, mxResources.get('share'));  
5117 - //  
5118 - // mxEvent.addListener(this.shareButton, 'click', mxUtils.bind(this, function()  
5119 - // {  
5120 - // this.actions.get('share').funct();  
5121 - // }));  
5122 - //  
5123 - // this.buttonContainer.appendChild(this.shareButton); 5141 + this.rightContainer.appendChild(this.saveButton);
  5142 +
5124 } 5143 }
5125 } 5144 }
5126 else if (this.shareButton != null) { 5145 else if (this.shareButton != null) {
@@ -5130,6 +5149,10 @@ App.prototype.updateButtonContainer = function () { @@ -5130,6 +5149,10 @@ App.prototype.updateButtonContainer = function () {
5130 this.saveButton = null; 5149 this.saveButton = null;
5131 this.lockButton.parentNode.removeChild(this.lockButton); 5150 this.lockButton.parentNode.removeChild(this.lockButton);
5132 this.lockButton = null; 5151 this.lockButton = null;
  5152 + this.importButton.parentNode.removeChild(this.importButton);
  5153 + this.importButton = null;
  5154 + this.exportButton.parentNode.removeChild(this.exportButton);
  5155 + this.exportButton = null;
5133 } 5156 }
5134 5157
5135 //Fetch notifications 5158 //Fetch notifications
@@ -355,6 +355,15 @@ @@ -355,6 +355,15 @@
355 } 355 }
356 } 356 }
357 357
  358 + /**
  359 + * @description 导入文件时初始化图表
  360 + */
  361 + const setFileData = EditorUi.prototype.setFileData
  362 + EditorUi.prototype.setFileData = function () {
  363 + setFileData.apply(this, arguments)
  364 + Sidebar.prototype.initChartInstance(this.editor.graph)
  365 + }
  366 +
358 // const selectPage = EditorUi.prototype.selectPage 367 // const selectPage = EditorUi.prototype.selectPage
359 // EditorUi.prototype.selectPage = function () { 368 // EditorUi.prototype.selectPage = function () {
360 // try { 369 // try {
@@ -453,7 +462,7 @@ @@ -453,7 +462,7 @@
453 axisLabel: { 462 axisLabel: {
454 distance: 35, 463 distance: 35,
455 color: '#999', 464 color: '#999',
456 - fontSize: 20 465 + fontSize: 20
457 }, 466 },
458 anchor: { 467 anchor: {
459 show: false 468 show: false
@@ -470,7 +479,7 @@ @@ -470,7 +479,7 @@
470 fontSize: 25, 479 fontSize: 25,
471 fontWeight: 'bolder', 480 fontWeight: 'bolder',
472 formatter: '{value} °C', 481 formatter: '{value} °C',
473 - color: 'auto' 482 + color: 'inherit'
474 }, 483 },
475 data: [ 484 data: [
476 { 485 {
@@ -481,6 +490,6 @@ @@ -481,6 +490,6 @@
481 ] 490 ]
482 } 491 }
483 } 492 }
484 - 493 +
485 })(); 494 })();
486 495
@@ -602,3 +602,19 @@ @@ -602,3 +602,19 @@
602 width: 100%; 602 width: 100%;
603 height: 100%; 603 height: 100%;
604 } 604 }
  605 +
  606 +
  607 +html > body > .geMenubarContainer > .geMenubar {
  608 + display: flex;
  609 +}
  610 +
  611 +
  612 +html > body > .geMenubarContainer > .geMenubar > .thingskit-button-container {
  613 + display: flex !important;
  614 + position: static !important;
  615 + flex: 1 1 auto;
  616 +}
  617 +
  618 +.left-button-container {
  619 + flex: 1 1 auto;
  620 +}