default.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. package theme
  2. type Default struct {
  3. }
  4. func (theme *Default) template() string {
  5. return `
  6. <!DOCTYPE html>
  7. <html lang="en">
  8. <head>
  9. <meta charset="UTF-8">
  10. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  11. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  12. <title>{{ .Page.Title }}</title>
  13. <style>
  14. html {
  15. height: 100%;
  16. }
  17. body {
  18. width: 100% !important;
  19. height: 100%;
  20. margin: 0;
  21. font-size: .96rem;
  22. line-height: 1.4;
  23. background-color: #F2F4F6;
  24. color: #44485E;
  25. -webkit-text-size-adjust: none;
  26. font-family: Helvetica Neue, Tahoma, Arial, PingFangSC-Regular, Hiragino Sans GB, Microsoft Yahei, sans-serif;
  27. -webkit-font-smoothing: antialiased;
  28. touch-action: manipulation;
  29. text-size-adjust: none;
  30. }
  31. .container {
  32. max-width: 560px;
  33. min-height: 100%;
  34. margin: 0 auto;
  35. background-color: white;
  36. }
  37. .container-inner {
  38. padding: 1rem;
  39. width: 100%;
  40. box-sizing: border-box;
  41. }
  42. .action-block{
  43. margin: 30px 0 20px 0;
  44. text-align: center;
  45. }
  46. .table-wrapper{
  47. margin-bottom: 1.5rem;
  48. }
  49. .table-wrapper-inner{
  50. width: 100%;
  51. overflow-x: auto;
  52. display: flex;
  53. }
  54. .table-fixed{
  55. position: absolute;
  56. background: white;
  57. z-index: 999;
  58. }
  59. .table-relative{
  60. flex: 1 1 auto!important;
  61. }
  62. .text-success {
  63. color: #20c55c;
  64. }
  65. .text-danger {
  66. color: #ff0476;
  67. }
  68. .text-center {
  69. text-align: center;
  70. }
  71. article {
  72. line-height: 1.6rem;
  73. }
  74. article h1,
  75. article h2,
  76. article h3,
  77. article h4 {
  78. color: #232323;
  79. margin-bottom: 1.28rem;
  80. }
  81. a {
  82. font-style: none;
  83. text-decoration: none;
  84. }
  85. article p {
  86. margin-bottom: 1rem;
  87. }
  88. .preview-label {
  89. min-width: 4em;
  90. text-align: justify;
  91. text-align-last: justify;
  92. }
  93. .preview-value {
  94. text-align: right;
  95. display: block;
  96. overflow: hidden;
  97. word-break: normal;
  98. word-wrap: break-word;
  99. color: rgba(0, 0, 0, 0.9);
  100. flex: 1 1 auto !important;
  101. }
  102. .grid {
  103. padding: 1rem 0;
  104. }
  105. .grid h4 {
  106. margin-top: 0;
  107. margin-bottom: .68rem;
  108. }
  109. .row {
  110. display: flex;
  111. justify-content: flex-start;
  112. line-height: 2;
  113. }
  114. .timeline {
  115. margin: 0;
  116. list-style: none;
  117. padding-left: 1rem;
  118. }
  119. .timeline-item {
  120. position: relative;
  121. padding-bottom: 1rem;
  122. box-sizing: border-box;
  123. }
  124. .timeline-item-tail {
  125. top: 0;
  126. position: absolute;
  127. left: 4px;
  128. height: 100%;
  129. border-left: 3px solid #e4e7ed;
  130. }
  131. .timeline-item-node {
  132. left: -1px;
  133. width: 13px;
  134. height: 13px;
  135. position: absolute;
  136. background-color: #e4e7ed;
  137. border-color: #e4e7ed;
  138. border-radius: 50%;
  139. box-sizing: border-box;
  140. display: flex;
  141. justify-content: center;
  142. align-items: center;
  143. }
  144. .timeline-item-wrapper {
  145. width: 100%;
  146. position: relative;
  147. padding-left: 28px;
  148. top: -3px;
  149. }
  150. .timeline-item-timestamp{
  151. font-size: .86rem;
  152. color: #64686E;
  153. }
  154. .timeline-item-content{
  155. width:100%;
  156. }
  157. .table {
  158. border: 1px solid #ddd;
  159. width: 100%;
  160. max-width: 100%;
  161. margin-bottom: 20px;
  162. display: table;
  163. border-collapse: separate;
  164. box-sizing: border-box;
  165. text-indent: initial;
  166. border-spacing: 2px;
  167. border-collapse: collapse;
  168. border-spacing: 0;
  169. }
  170. .table-title{
  171. box-sizing: border-box;
  172. margin-bottom: 1rem;
  173. }
  174. .table>thead:first-child>tr:first-child>th {
  175. border-top: 0;
  176. }
  177. .table>thead>tr>th{
  178. vertical-align: bottom;
  179. padding: 8px;
  180. line-height: 1.42857143;
  181. border-bottom-width: 2px;
  182. border: 1px solid #ddd;
  183. text-align: left;
  184. word-break : keep-all;
  185. }
  186. .table>tbody>tr>td{
  187. border: 1px solid #ddd;
  188. padding: 8px;
  189. line-height: 1.42857143;
  190. vertical-align: top;
  191. text-align: left;
  192. word-break : keep-all;
  193. }
  194. .button {
  195. padding: .8rem 2rem;
  196. color: white;
  197. background-color: #727cf5;
  198. border-radius: .25rem;
  199. }
  200. .invite-code {
  201. font-size: 32px;
  202. letter-spacing: .6rem;
  203. color: #35742;
  204. }
  205. .copyright {
  206. text-align: center;
  207. font-size: .86rem;
  208. color: #8c8c86;
  209. margin: 50px 0 10px 0;
  210. }
  211. .cell {
  212. flex: 1 1 auto !important;
  213. }
  214. .weui-mask_transparent {
  215. position: fixed;
  216. z-index: 1000;
  217. top: 0;
  218. right: 0;
  219. left: 0;
  220. bottom: 0;
  221. }
  222. .weui-toast {
  223. position: fixed;
  224. z-index: 5500;
  225. font-size: 10px;
  226. width: 13.6em;
  227. height: 13.6em;
  228. top: 40%;
  229. left: 50%;
  230. -webkit-transform: translate(-50%,-50%);
  231. transform: translate(-50%,-50%);
  232. text-align: center;
  233. border-radius: 12px;
  234. color: rgba(255,255,255,0.9);
  235. display: -webkit-box;
  236. display: -webkit-flex;
  237. display: flex;
  238. -webkit-box-orient: vertical;
  239. -webkit-box-direction: normal;
  240. -webkit-flex-direction: column;
  241. flex-direction: column;
  242. -webkit-box-align: center;
  243. -webkit-align-items: center;
  244. align-items: center;
  245. -webkit-box-pack: center;
  246. -webkit-justify-content: center;
  247. justify-content: center;
  248. background-color: #4c4c4c;
  249. background-color: #4c4c4c;
  250. box-sizing: border-box;
  251. line-height: 1.4;
  252. }
  253. .weui-icon_toast.weui-icon_toast {
  254. width: 4em;
  255. height: 4em;
  256. vertical-align: middle;
  257. font-size: 10px;
  258. -webkit-mask-position: 50% 50%;
  259. mask-position: 50% 50%;
  260. -webkit-mask-repeat: no-repeat;
  261. mask-repeat: no-repeat;
  262. mask-size: 100%;
  263. -webkit-mask-size: 100%;
  264. background-color: currentColor;
  265. }
  266. .weui-icon-warn {
  267. -webkit-mask-image: url(data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M12%2022C6.477%2022%202%2017.523%202%2012S6.477%202%2012%202s10%204.477%2010%2010-4.477%2010-10%2010zm-.763-15.864l.11%207.596h1.305l.11-7.596h-1.525zm.759%2010.967c.512%200%20.902-.383.902-.882%200-.5-.39-.882-.902-.882a.878.878%200%2000-.896.882c0%20.499.396.882.896.882z%22%2F%3E%3C%2Fsvg%3E);
  268. mask-image: url(data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M12%2022C6.477%2022%202%2017.523%202%2012S6.477%202%2012%202s10%204.477%2010%2010-4.477%2010-10%2010zm-.763-15.864l.11%207.596h1.305l.11-7.596h-1.525zm.759%2010.967c.512%200%20.902-.383.902-.882%200-.5-.39-.882-.902-.882a.878.878%200%2000-.896.882c0%20.499.396.882.896.882z%22%2F%3E%3C%2Fsvg%3E);
  269. }
  270. </style>
  271. </head>
  272. <body>
  273. <div class="container">
  274. <div class="container-inner">
  275. <article>
  276. {{ if .Page.Head }}<h1>{{ .Page.Head }}</h1>{{ end }}
  277. {{ with .Page.Intros }}
  278. {{ if gt (len .) 0 }}
  279. {{ range $text := . }}
  280. {{ $text }}
  281. {{ end }}
  282. {{ end }}
  283. {{ end }}
  284. {{ with .Page.Actions }}
  285. {{ if gt (len .) 0 }}
  286. {{ range $action := . }}
  287. {{ $action }}
  288. {{ end }}
  289. {{ end }}
  290. {{ end }}
  291. {{ with .Page.Entries }}
  292. {{ if gt (len .) 0 }}
  293. {{ range $entry := . }}
  294. {{ $entry }}
  295. {{ end }}
  296. {{ end }}
  297. {{ end }}
  298. {{ with .Page.Timelines }}
  299. {{ if gt (len .) 0 }}
  300. {{ range $timeline := . }}
  301. {{ $timeline }}
  302. {{ end }}
  303. {{ end }}
  304. {{ end }}
  305. {{ with .Page.Tables }}
  306. {{ if gt (len .) 0 }}
  307. {{ range $table := . }}
  308. {{ $table }}
  309. {{ end }}
  310. {{ end }}
  311. {{ end }}
  312. {{ with .Page.Outros }}
  313. {{ if gt (len .) 0 }}
  314. {{ range $text := . }}
  315. {{ $text }}
  316. {{ end }}
  317. {{ end }}
  318. {{ end }}
  319. {{ if .Page.Copyright }}<div class="copyright">{{ .Page.Copyright }}</div>{{ end }}
  320. </article>
  321. </div>
  322. </div>
  323. <div role="alert" id="toast" style="display:none">
  324. <div class="weui-mask_transparent"></div>
  325. <div class="weui-toast weui-toast_text-more">
  326. <i class="weui-icon-warn weui-icon_toast"></i>
  327. <p class="weui-toast__content"></p>
  328. </div>
  329. </div>
  330. <script src="https://rd-api.nspix.com/static/css/zepto.min.js"></script>
  331. <script>
  332. var toastFlag = 0;
  333. var toastTimer = null;
  334. function showToast(message,second){
  335. let sec = second || 3
  336. let toastElement = $('#toast')
  337. toastElement.find('.weui-toast__content').text(message);
  338. if(toastFlag === 1){
  339. clearTimeout(toastTimer);
  340. } else {
  341. toastElement.show();
  342. }
  343. toastTimer = setTimeout(()=>{
  344. toastElement.hide();
  345. },sec * 1000)
  346. }
  347. $('.ajax-request').each((index,item)=>{
  348. $(item).on('click',(e)=>{
  349. let element = $(e.target);
  350. let method = element.data('method');
  351. let url = element.data('url');
  352. let data = element.data('data');
  353. let contentType = 'application/x-www-form-urlencoded';
  354. let success = element.data('success');
  355. let reload = element.data('reload');
  356. method = method || 'get';
  357. try{
  358. let payload = data && atob(data) || null;
  359. if(payload.substring(0,1) == '{'){
  360. payload = JSON.parse(payload);
  361. contentType = 'application/json';
  362. data = payload;
  363. }
  364. }catch(e){}
  365. $.ajax({
  366. type: method.toUpperCase(),
  367. url: url,
  368. data: data,
  369. contentType: contentType,
  370. timeout: 5000,
  371. success: (data,status,xhr)=>{
  372. if(xhr.status === 200){
  373. if(data.hasOwnProperty('errno') && data.hasOwnProperty('errmsg')) {
  374. if(data.errno !== 0) {
  375. showToast(data.errmsg)
  376. } else {
  377. if(success){
  378. showToast(success)
  379. }
  380. if(reload){
  381. window.location.reload();
  382. }
  383. }
  384. } else {
  385. if(success){
  386. showToast(success)
  387. }
  388. if(reload){
  389. window.location.reload();
  390. }
  391. }
  392. } else {
  393. showToast(xhr.statusText)
  394. }
  395. },
  396. error: (xhr,type)=>{
  397. showToast(xhr.response)
  398. }
  399. })
  400. })
  401. })
  402. </script>
  403. </body>
  404. </html>
  405. `
  406. }
  407. func (theme *Default) Template() string {
  408. return `
  409. <!DOCTYPE html>
  410. <html lang="en">
  411. <head>
  412. <meta charset="UTF-8">
  413. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  414. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  415. <title>{{ .Page.Title }}</title>
  416. <style>
  417. html{height:100%;}body{width:100% !important;height:100%;margin:0;font-size:.96rem;line-height:1.4;background-color:#F2F4F6;color:#44485E;-webkit-text-size-adjust:none;font-family:Helvetica Neue,Tahoma,Arial,PingFangSC-Regular,Hiragino Sans GB,Microsoft Yahei,sans-serif;-webkit-font-smoothing:antialiased;touch-action:manipulation;text-size-adjust:none;}.container{max-width:560px;min-height:100%;margin:0 auto;background-color:white;}.container-inner{padding:1rem;width:100%;box-sizing:border-box;}.action-block{margin:30px 0 20px 0;text-align:center;}.table-wrapper{margin-bottom:1.5rem;}.table-wrapper-inner{width:100%;overflow-x:auto;display:flex;}.table-fixed{position:absolute;background:white;z-index:999;}.table-relative{flex:1 1 auto!important;}.text-success{color:#20c55c;}.text-danger{color:#ff0476;}.text-center{text-align:center;}article{line-height:1.6rem;}article h1,article h2,article h3,article h4{color:#232323;margin-bottom:1.28rem;}a{font-style:none;text-decoration:none;}article p{margin-bottom:1rem;}.preview-label{min-width:4em;text-align:justify;text-align-last:justify;}.preview-value{text-align:right;display:block;overflow:hidden;word-break:normal;word-wrap:break-word;color:rgba(0,0,0,0.9);flex:1 1 auto !important;}.grid{padding:1rem 0;}.grid h4{margin-top:0;margin-bottom:.68rem;}.row{display:flex;justify-content:flex-start;line-height:2;}.timeline{margin:0;list-style:none;padding-left:1rem;}.timeline-item{position:relative;padding-bottom:1rem;box-sizing:border-box;}.timeline-item-tail{top:0;position:absolute;left:4px;height:100%;border-left:3px solid #e4e7ed;}.timeline-item-node{left:-1px;width:13px;height:13px;position:absolute;background-color:#e4e7ed;border-color:#e4e7ed;border-radius:50%;box-sizing:border-box;display:flex;justify-content:center;align-items:center;}.timeline-item-wrapper{width:100%;position:relative;padding-left:28px;top:-3px;}.timeline-item-timestamp{font-size:.86rem;color:#64686E;}.timeline-item-content{width:100%;}.table{border:1px solid #ddd;width:100%;max-width:100%;margin-bottom:20px;display:table;border-collapse:separate;box-sizing:border-box;text-indent:initial;border-spacing:2px;border-collapse:collapse;border-spacing:0;}.table-title{box-sizing:border-box;margin-bottom:1rem;}.table>thead:first-child>tr:first-child>th{border-top:0;}.table>thead>tr>th{vertical-align:bottom;padding:8px;line-height:1.42857143;border-bottom-width:2px;border:1px solid #ddd;text-align:left;word-break:keep-all;}.table>tbody>tr>td{border:1px solid #ddd;padding:8px;line-height:1.42857143;vertical-align:top;text-align:left;word-break:keep-all;}.button{padding:.8rem 2rem;color:white;background-color:#727cf5;border-radius:.25rem;}.invite-code{font-size:32px;letter-spacing:.6rem;color:#35742;}.copyright{text-align:center;font-size:.86rem;color:#8c8c86;margin:50px 0 10px 0;}.cell{flex:1 1 auto !important;}.weui-mask_transparent{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0;}.weui-toast{position:fixed;z-index:5500;font-size:10px;width:13.6em;height:13.6em;top:40%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);text-align:center;border-radius:12px;color:rgba(255,255,255,0.9);display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;flex-direction:column;-webkit-box-align:center;-webkit-align-items:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;justify-content:center;background-color:#4c4c4c;background-color:#4c4c4c;box-sizing:border-box;line-height:1.4;}.weui-icon_toast.weui-icon_toast{width:4em;height:4em;vertical-align:middle;font-size:10px;-webkit-mask-position:50% 50%;mask-position:50% 50%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;mask-size:100%;-webkit-mask-size:100%;background-color:currentColor;}.weui-icon-warn{-webkit-mask-image:url(data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M12%2022C6.477%2022%202%2017.523%202%2012S6.477%202%2012%202s10%204.477%2010%2010-4.477%2010-10%2010zm-.763-15.864l.11%207.596h1.305l.11-7.596h-1.525zm.759%2010.967c.512%200%20.902-.383.902-.882%200-.5-.39-.882-.902-.882a.878.878%200%2000-.896.882c0%20.499.396.882.896.882z%22%2F%3E%3C%2Fsvg%3E);mask-image:url(data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M12%2022C6.477%2022%202%2017.523%202%2012S6.477%202%2012%202s10%204.477%2010%2010-4.477%2010-10%2010zm-.763-15.864l.11%207.596h1.305l.11-7.596h-1.525zm.759%2010.967c.512%200%20.902-.383.902-.882%200-.5-.39-.882-.902-.882a.878.878%200%2000-.896.882c0%20.499.396.882.896.882z%22%2F%3E%3C%2Fsvg%3E);}
  418. </style>
  419. </head>
  420. <body>
  421. <div class="container">
  422. <div class="container-inner">
  423. <article>
  424. {{ if .Page.Head }}<h1>{{ .Page.Head }}</h1>{{ end }}
  425. {{ with .Page.Intros }}
  426. {{ if gt (len .) 0 }}
  427. {{ range $text := . }}
  428. {{ $text }}
  429. {{ end }}
  430. {{ end }}
  431. {{ end }}
  432. {{ with .Page.Actions }}
  433. {{ if gt (len .) 0 }}
  434. {{ range $action := . }}
  435. {{ $action }}
  436. {{ end }}
  437. {{ end }}
  438. {{ end }}
  439. {{ with .Page.Entries }}
  440. {{ if gt (len .) 0 }}
  441. {{ range $entry := . }}
  442. {{ $entry }}
  443. {{ end }}
  444. {{ end }}
  445. {{ end }}
  446. {{ with .Page.Timelines }}
  447. {{ if gt (len .) 0 }}
  448. {{ range $timeline := . }}
  449. {{ $timeline }}
  450. {{ end }}
  451. {{ end }}
  452. {{ end }}
  453. {{ with .Page.Tables }}
  454. {{ if gt (len .) 0 }}
  455. {{ range $table := . }}
  456. {{ $table }}
  457. {{ end }}
  458. {{ end }}
  459. {{ end }}
  460. {{ with .Page.Outros }}
  461. {{ if gt (len .) 0 }}
  462. {{ range $text := . }}
  463. {{ $text }}
  464. {{ end }}
  465. {{ end }}
  466. {{ end }}
  467. {{ if .Page.Copyright }}<div class="copyright">{{ .Page.Copyright }}</div>{{ end }}
  468. </article>
  469. </div>
  470. </div>
  471. <div role="alert" id="toast" style="display:none">
  472. <div class="weui-mask_transparent"></div>
  473. <div class="weui-toast weui-toast_text-more">
  474. <i class="weui-icon-warn weui-icon_toast"></i>
  475. <p class="weui-toast__content"></p>
  476. </div>
  477. </div>
  478. <script src="https://rd-api.nspix.com/static/css/zepto.min.js"></script>
  479. <script>
  480. var toastFlag=0;var toastTimer=null;function showToast(message,second){let sec=second||3;
  481. let toastElement=$('#toast');
  482. toastElement.find('.weui-toast__content').text(message);if(toastFlag===1){clearTimeout(toastTimer);}else{toastElement.show();}
  483. toastTimer=setTimeout(()=>{toastElement.hide();},sec*1000)}
  484. $('.ajax-request').each((index,item)=>{$(item).on('click',(e)=>{let element=$(e.target);let method=element.data('method');let url=element.data('url');let data=element.data('data');let contentType='application/x-www-form-urlencoded';let success=element.data('success');let reload=element.data('reload');method=method||'get';try{let payload=data&&atob(data)||null;if(payload.substring(0,1)=='{'){payload=JSON.parse(payload);contentType='application/json';data=payload;}}catch(e){}
  485. $.ajax({type:method.toUpperCase(),url:url,data:data,contentType:contentType,timeout:5000,success:(data,status,xhr)=>{if(xhr.status===200){if(data.hasOwnProperty('errno')&&data.hasOwnProperty('errmsg')){if(data.errno!==0){showToast(data.errmsg)}else{if(success){showToast(success)}
  486. if(reload){window.location.reload();}}}else{if(success){showToast(success)}
  487. if(reload){window.location.reload();}}}else{showToast(xhr.statusText)}},error:(xhr,type)=>{showToast(xhr.response)}})})})</script>
  488. </body>
  489. </html>
  490. `
  491. }