yvan_require.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. define(["require", "exports"], function (require2, exports) {
  2. "use strict";
  3. Object.defineProperty(exports, "__esModule", {value: true});
  4. function mergeProps(target, sou1, excludes) {
  5. var names = Object.getOwnPropertyNames(sou1)
  6. for (var i = 0; i < names.length; i++) {
  7. if (typeof excludes === 'object') {
  8. if (excludes.includes(names[i])) {
  9. continue;
  10. }
  11. }
  12. target[names[i]] = sou1[names[i]];
  13. }
  14. }
  15. function onLoadFinish(callback) {
  16. if (typeof setupProcess === 'function') {
  17. setupProcess('A3');
  18. }
  19. // require(['axios', 'qs', 'lodash', 'json5', 'moment', 'jquery', 'yvan-ext', 'jszip', 'ClipboardJS'], function (axios, qs, lodash, json5, moment, jquery, YvanUI, jszip, ClipboardJS) {
  20. // 'lodash', 'jquery', 'axios', 'qs',
  21. require(['json5', 'moment', 'yvan-ext', 'jszip', 'ClipboardJS'], function (json5, moment, YvanUI, jszip, ClipboardJS) {
  22. window['axios'] = YvanUI.axios;
  23. window['qs'] = YvanUI.qs;
  24. window['_'] = YvanUI.lodash;
  25. window['lodash'] = YvanUI.lodash;
  26. window['json5'] = json5;
  27. window['moment'] = moment;
  28. window['$'] = YvanUI.jquery;
  29. window['jquery'] = YvanUI.jquery;
  30. window['jQuery'] = YvanUI.jquery;
  31. window['jszip'] = jszip;
  32. window['JSZip'] = jszip;
  33. window['ClipboardJS'] = ClipboardJS;
  34. window["time_offset"] = 0;
  35. var getServerTime = function () {
  36. return Number(new Date()) + window["time_offset"];
  37. };
  38. window['getServerTime'] = getServerTime;
  39. YvanUI['getServerTime'] = getServerTime;
  40. function syncTime() {
  41. try {
  42. jquery.get("/time", {t1: Number(new Date())}, function (data) {
  43. data = data.data;
  44. var t1 = Number(data.t1); // 客户端时间(请求前)
  45. var t2 = Number(data.t2); // 数据库时间
  46. var t3 = Number(data.t3); // 数据库时间 + 查询时间
  47. var t4 = Number(new Date()); // 客户端时间(请求后)
  48. window["time_offset"] = ((t2 - t1) + (t3 - t4)) / 2;
  49. console.log("time_offset --> ", window["time_offset"]);
  50. });
  51. } catch (e) {
  52. console.log("时间同步失败", e);
  53. }
  54. }
  55. syncTime();
  56. require(['yvan-ext'], function (YvanUI, Sortable) {
  57. if (typeof setupProcess === 'function') {
  58. setupProcess('A4');
  59. }
  60. window['Sortable'] = Sortable;
  61. window['YvanUI'] = YvanUI;
  62. if (window.localStorage.getItem("dark-mode") && window.location.search !== '?design=true') {
  63. // 黑色
  64. require(['css!/node_modules/yvan-ext/dist/dark.css'], function () {
  65. })
  66. }
  67. callback();
  68. })
  69. })
  70. };
  71. exports.onLoadFinish = onLoadFinish;
  72. function config(customConfig) {
  73. var cfg = {
  74. paths: {
  75. '@': '/dist',
  76. 'axios': '/assets/axios/axios.min',
  77. 'qs': '/assets/qs/qs.min',
  78. 'jquery': '/assets/jquery/jquery-1.11.1.min',
  79. 'lodash': '/assets/lodash/lodash.min',
  80. 'json5': '/assets/json5/json5.min',
  81. 'moment': '/assets/moment/moment.min',
  82. 'recast': '/assets/recast/recast',
  83. 'lay-excel': '/assets/layui-excel/excel',
  84. 'xlsx': '/assets/xlsx/xlsx.full.min',
  85. 'modeler': '/assets/bpmn-js/dist/bpmn-modeler.development',
  86. 'bpmn-js-properties-panel': '/assets/bpmn-js-properties-panel/dist/bpmn-js-properties-panel.umd',
  87. 'bpmn-modeler': '/assets/bpmn-js/dist/bpmn-modeler.production.min',
  88. 'bpmn-navigated': '/assets/bpmn-js/dist/bpmn-navigated-viewer.production.min',
  89. 'bpmn-viewer': '/assets/bpmn-js/dist/bpmn-viewer.production.min',
  90. 'viewer': '/assets/viewer/viewer',
  91. 'polyfill': '/assets/polyfill/polyfill.min',
  92. 'es6-promise': '/assets/polyfill/es6-promise.auto.min',
  93. 'tslib': '/assets/tslib/tslib',
  94. 'jqueryCookie': '/assets/jquery/jquery.cookie',
  95. 'jszip': '/assets/jszip/jszip.min',
  96. 'vs': '/assets/monaco-editor/min/vs',
  97. 'node-sql-parser': '/assets/sql/postgresql.umd',
  98. 'sql-formatter': '/assets/sql-formatter/sql-formatter.min',
  99. 'ClipboardJS': '/assets/clipboard/clipboard.min',
  100. 'localforage': '/assets/localForage/localforage.min',
  101. 'socket.io-client': '/assets/socket.io/socket.io',
  102. 'xterm': '/assets/xterm/xterm.min',
  103. 'xterm-addon-fit': '/assets/xterm/xterm-addon-fit',
  104. 'handlebars': '/assets/handlebars/handlebars.amd',
  105. 'sanitizer': '/assets/mxgraph-editor/sanitizer/sanitizer.min',
  106. 'pako': '/assets/mxgraph-editor/deflate/pako.min',
  107. 'mxgraphInit': '/assets/mxgraph-editor/js/Init',
  108. 'mxgraphBase64': '/assets/mxgraph-editor/deflate/base64',
  109. 'mxgraphJscolor': '/assets/mxgraph-editor/jscolor/jscolor',
  110. 'mxgraphClient': '/assets/mxgraph/js/mxClient',
  111. 'mxgraphEditorUi': '/assets/mxgraph-editor/js/EditorUi',
  112. 'mxgraphEditor': '/assets/mxgraph-editor/js/Editor',
  113. 'mxgraphSidebar': '/assets/mxgraph-editor/js/Sidebar',
  114. 'mxgraphGraph': '/assets/mxgraph-editor/js/Graph',
  115. 'mxgraphFormat': '/assets/mxgraph-editor/js/Format',
  116. 'mxgraphShapes': '/assets/mxgraph-editor/js/Shapes',
  117. 'mxgraphActions': '/assets/mxgraph-editor/js/Actions',
  118. 'mxgraphMenus': '/assets/mxgraph-editor/js/Menus',
  119. 'mxgraphToolbar': '/assets/mxgraph-editor/js/Toolbar',
  120. 'mxgraphDialogs': '/assets/mxgraph-editor/js/Dialogs',
  121. 'mxgraph': '/assets/mxgraph/fix',
  122. 'echarts': '/assets/echarts/echarts.min'
  123. },
  124. map: {
  125. '*': {
  126. css: '/assets/require-css/css.min.js'
  127. },
  128. },
  129. shim: {
  130. 'yvan-ext': {
  131. deps: [
  132. 'css!/node_modules/yvan-ext/dist/yvan-ext.css',
  133. // 'polyfill',
  134. 'es6-promise',
  135. 'axios',
  136. 'qs',
  137. 'lodash',
  138. 'json5',
  139. 'moment',
  140. 'jquery',
  141. 'jqueryCookie'
  142. ]
  143. },
  144. 'jqueryCookie': {
  145. deps: [
  146. 'jquery'
  147. ]
  148. },
  149. 'modeler': {
  150. deps: [
  151. 'css!/assets/bpmn-js/dist/assets/diagram-js.css',
  152. 'css!/assets/bpmn-js/dist/assets/bpmn-font/css/bpmn.css',
  153. 'css!/assets/bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css',
  154. 'css!/assets/bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css',
  155. 'css!/assets/bpmn-js-properties-panel/dist/assets/properties-panel.css',
  156. 'css!/assets/bpmn-js-properties-panel/dist/assets/element-templates.css'
  157. ]
  158. },
  159. 'xterm': {
  160. deps: [
  161. 'css!/assets/xterm/xterm.css'
  162. ]
  163. },
  164. 'mxgraphClient': {
  165. deps: [
  166. 'mxgraphInit',
  167. 'pako',
  168. 'mxgraphBase64',
  169. 'mxgraphJscolor',
  170. 'sanitizer'
  171. ]
  172. },
  173. 'mxgraphEditorUi': {
  174. deps: [
  175. 'mxgraphClient'
  176. ]
  177. },
  178. 'mxgraphEditor': {
  179. deps: [
  180. 'mxgraphEditorUi'
  181. ]
  182. },
  183. 'mxgraphSidebar': {
  184. deps: [
  185. 'mxgraphEditor'
  186. ]
  187. },
  188. 'mxgraphGraph': {
  189. deps: [
  190. 'mxgraphSidebar'
  191. ]
  192. },
  193. 'mxgraphFormat': {
  194. deps: [
  195. 'mxgraphGraph'
  196. ]
  197. },
  198. 'mxgraphShapes': {
  199. deps: [
  200. 'mxgraphFormat'
  201. ]
  202. },
  203. 'mxgraphActions': {
  204. deps: [
  205. 'mxgraphShapes'
  206. ]
  207. },
  208. 'mxgraphMenus': {
  209. deps: [
  210. 'mxgraphActions'
  211. ]
  212. },
  213. 'mxgraphToolbar': {
  214. deps: [
  215. 'mxgraphMenus'
  216. ]
  217. },
  218. 'mxgraphDialogs': {
  219. deps: [
  220. 'mxgraphToolbar'
  221. ]
  222. },
  223. 'mxgraph': {
  224. deps: [
  225. 'css!/assets/mxgraph-editor/styles/grapheditor.css',
  226. 'css!/assets/mxgraph/fix.css',
  227. 'mxgraphDialogs'
  228. ]
  229. },
  230. },
  231. 'vs/nls': {
  232. availableLanguages: {'*': 'zh-cn'}
  233. },
  234. };
  235. window.mxBasePath = '/assets/mxgraph/src';
  236. window.mxLanguage = '';
  237. window.IMAGE_PATH = '/assets/mxgraph/images';
  238. window.STENCIL_PATH = '/static/mxgraph/stencils';
  239. window.urlParams = (function (url) {
  240. var result = new Object();
  241. var idx = url.lastIndexOf('?');
  242. if (idx > 0) {
  243. var params = url.substring(idx + 1).split('&');
  244. for (var i = 0; i < params.length; i++) {
  245. idx = params[i].indexOf('=');
  246. if (idx > 0) {
  247. result[params[i].substring(0, idx)] = params[i].substring(idx + 1);
  248. }
  249. }
  250. }
  251. return result;
  252. })(window.location.href);
  253. if (typeof customConfig === 'object') {
  254. mergeProps(cfg, customConfig, ['paths', 'map', 'shim', 'vs/nls']);
  255. if (typeof customConfig.paths === 'object') {
  256. mergeProps(cfg.paths, customConfig.paths);
  257. }
  258. if (typeof customConfig.map === 'object') {
  259. mergeProps(cfg.map, customConfig.map);
  260. }
  261. if (typeof customConfig.shim === 'object') {
  262. mergeProps(cfg.shim, customConfig.shim);
  263. }
  264. if (typeof customConfig['vs/nls'] === 'object') {
  265. mergeProps(cfg['vs/nls'], customConfig['vs/nls']);
  266. }
  267. }
  268. require.config(cfg);
  269. };
  270. exports.config = config;
  271. })