app.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <title>ROMA</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <link rel="icon" type="image/x-ico" href=""/>
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
  9. <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
  10. <link rel="stylesheet" href="./public/static/amis-sdk/helper.css">
  11. <link rel="stylesheet" href="./public/static/amis-sdk/sdk.css">
  12. <link rel="stylesheet" href="./public/static/amis-sdk/iconfont.css">
  13. <link rel="stylesheet" href="./public/static/fonts/remixicon.css">
  14. <style>
  15. html,
  16. body,
  17. .app-wrapper {
  18. position: relative;
  19. width: 100%;
  20. height: 100%;
  21. margin: 0;
  22. padding: 0;
  23. touch-action: pan-y;
  24. }
  25. :root {
  26. --Form-item-gap: 1.3rem;
  27. --InputGroup-height: 2.5rem;
  28. --Button-height: 2.5rem;
  29. --InputGroup-paddingX: .6rem;
  30. --InputGroup-addOn-bg: var(--Form-input-bg);
  31. /* --fontSizeBase: .9rem; */
  32. }
  33. .app-wrapper {
  34. position: relative;
  35. width: 100%;
  36. height: 100%;
  37. margin: 0;
  38. padding: 0;
  39. }
  40. .amis-scope .cxd-Layout--headerFixed .cxd-Layout-header .cxd-Page {
  41. background: none;
  42. }
  43. .amis-scope .cxd-Page-body .cxd-DropDown--alignRight .cxd-DropDown-menu {
  44. text-align: center;
  45. }
  46. /* .amis-scope .cxd-DropDown button .m-r-xs {
  47. width: 100%;
  48. height: 100%;
  49. } */
  50. .amis-scope .cxd-Button--default {
  51. border: none;
  52. outline: none;
  53. }
  54. .amis-scope .cxd-Button--default:not(:disabled):not(.is-disabled):hover {
  55. color: none;
  56. background: none;
  57. border-color: none;
  58. border-width: none;
  59. border-style: none;
  60. box-shadow: none;
  61. border: none;
  62. outline: none;
  63. }
  64. .amis-scope .m-r-xs {
  65. margin-top:-5px;
  66. width: 30px;
  67. height: 30px;
  68. }
  69. @media (min-width: 768px) {
  70. .amis-scope .cxd-Layout--asideFixed.cxd-Layout--folded .cxd-Layout-aside {
  71. z-index: 2000;
  72. }
  73. }
  74. </style>
  75. </head>
  76. <body>
  77. <div id="root" class="app-wrapper"></div>
  78. <script type='text/javascript' src='./public/static/amis-sdk/sdk.js'></script>
  79. <script type='text/javascript' src='./public/static/amis-static/history.js'></script>
  80. <!-- 引入语言包 -->
  81. <script src="./lang/en-US.js"></script>
  82. <script src="./lang/zh-CN.js"></script>
  83. <!-- 引入多语言js处理文件,必须先引入语言包 -->
  84. <script src="./public/static/tools/common.js"></script>
  85. <!-- 引入header的JSON -->
  86. <script src="./pages/app/header-json.js"></script>
  87. <script>
  88. (function () {
  89. let amis = amisRequire('amis/embed');
  90. const match = amisRequire('path-to-regexp').match;
  91. // 如果想用 browserHistory 请切换下这处代码, 其他不用变
  92. // const history = History.createBrowserHistory();
  93. const history = History.createHashHistory();
  94. const header = getHeaderJson()
  95. const app = {
  96. type: 'app',
  97. brandName: 'ROMA',
  98. // logo: './public/static/images/logo.jpg',
  99. // footer: '<div class="p-2 text-center bg-light">底部区域</div>',
  100. // asideBefore: '<div class="p-2 text-center">菜单前面区域</div>',
  101. // asideAfter: '<div class="p-2 text-center">菜单后面区域</div>',
  102. // // api: '/pages/site.json'
  103. header,
  104. api: 'http://172.20.118.83:8051/demomenu'
  105. };
  106. function normalizeLink(to, location = history.location) {
  107. to = to || '';
  108. if (to && to[0] === '#') {
  109. to = location.pathname + location.search + to;
  110. } else if (to && to[0] === '?') {
  111. to = location.pathname + to;
  112. }
  113. const idx = to.indexOf('?');
  114. const idx2 = to.indexOf('#');
  115. let pathname = ~idx
  116. ? to.substring(0, idx)
  117. : ~idx2
  118. ? to.substring(0, idx2)
  119. : to;
  120. let search = ~idx ? to.substring(idx, ~idx2 ? idx2 : undefined) : '';
  121. let hash = ~idx2 ? to.substring(idx2) : location.hash;
  122. if (!pathname) {
  123. pathname = location.pathname;
  124. } else if (pathname[0] != '/' && !/^https?\:\/\//.test(pathname)) {
  125. let relativeBase = location.pathname;
  126. const paths = relativeBase.split('/');
  127. paths.pop();
  128. let m;
  129. while ((m = /^\.\.?\//.exec(pathname))) {
  130. if (m[0] === '../') {
  131. paths.pop();
  132. }
  133. pathname = pathname.substring(m[0].length);
  134. }
  135. pathname = paths.concat(pathname).join('/');
  136. }
  137. return pathname + search + hash;
  138. }
  139. function isCurrentUrl(to, ctx) {
  140. if (!to) {
  141. return false;
  142. }
  143. const pathname = history.location.pathname;
  144. const link = normalizeLink(to, {
  145. ...location,
  146. pathname,
  147. hash: ''
  148. });
  149. if (!~link.indexOf('http') && ~link.indexOf(':')) {
  150. let strict = ctx && ctx.strict;
  151. return match(link, {
  152. decode: decodeURIComponent,
  153. strict: typeof strict !== 'undefined' ? strict : true
  154. })(pathname);
  155. }
  156. return decodeURI(pathname) === link;
  157. }
  158. let languageInfo = getLanguageInfo();
  159. let amisInstance = amis.embed(
  160. '#root',
  161. app,
  162. {
  163. location: history.location,
  164. locale: languageInfo.lang
  165. },
  166. {
  167. replaceText: languageInfo.langReplaceText,
  168. langReplaceTextIgnoreKeys: languageInfo.langReplaceTextIgnoreKeys,
  169. // watchRouteChange: fn => {
  170. // return history.listen(fn);
  171. // },
  172. updateLocation: (location, replace) => {
  173. location = normalizeLink(location);
  174. if (location === 'goBack') {
  175. return history.goBack();
  176. } else if (
  177. (!/^https?\:\/\//.test(location) &&
  178. location ===
  179. history.location.pathname + history.location.search) ||
  180. location === history.location.href
  181. ) {
  182. // 目标地址和当前地址一样,不处理,免得重复刷新
  183. return;
  184. } else if (/^https?\:\/\//.test(location) || !history) {
  185. return (window.location.href = location);
  186. }
  187. history[replace ? 'replace' : 'push'](location);
  188. },
  189. jumpTo: (to, action) => {
  190. if (to === 'goBack') {
  191. return history.goBack();
  192. }
  193. to = normalizeLink(to);
  194. if (isCurrentUrl(to)) {
  195. return;
  196. }
  197. if (action && action.actionType === 'url') {
  198. action.blank === false
  199. ? (window.location.href = to)
  200. : window.open(to, '_blank');
  201. return;
  202. } else if (action && action.blank) {
  203. window.open(to, '_blank');
  204. return;
  205. }
  206. if (/^https?:\/\//.test(to)) {
  207. window.location.href = to;
  208. } else if (
  209. (!/^https?\:\/\//.test(to) &&
  210. to === history.pathname + history.location.search) ||
  211. to === history.location.href
  212. ) {
  213. // do nothing
  214. } else {
  215. history.push(to);
  216. }
  217. },
  218. isCurrentUrl: isCurrentUrl,
  219. theme: 'cxd'
  220. }
  221. );
  222. history.listen(state => {
  223. amisInstance.updateProps({
  224. location: state.location || state
  225. });
  226. });
  227. })();
  228. </script>
  229. </body>
  230. </html>