LOCKING盒子版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

350 lines
8.5 KiB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. }
  13. #board {
  14. position: relative;
  15. width: 504px;
  16. height: 219px;
  17. padding: 9px 12px 15px;
  18. background: url(./bg.png) no-repeat;
  19. box-sizing: border-box;
  20. }
  21. .inner {
  22. position: relative;
  23. height: 100%;
  24. width: 100%;
  25. display: flex;
  26. flex-direction: column;
  27. }
  28. #close-icon {
  29. position: absolute;
  30. width: 24px;
  31. height: 24px;
  32. top: 24px;
  33. right: 32px;
  34. cursor: pointer;
  35. z-index: 1;
  36. }
  37. .close-icon:before,
  38. .close-icon:after {
  39. content: '';
  40. position: absolute;
  41. top: 0;
  42. left: 0;
  43. right: 0;
  44. bottom: 0;
  45. margin: auto;
  46. width: 16px;
  47. height: 2px;
  48. background-color: #fff;
  49. }
  50. .close-icon:before {
  51. transform: rotate(45deg);
  52. }
  53. .close-icon:after {
  54. transform: rotate(-45deg);
  55. }
  56. h3 {
  57. flex: none;
  58. height: 52px;
  59. line-height: 52px;
  60. color: #fff;
  61. font-size: 20px;
  62. padding-left: 20px;
  63. }
  64. #syncMsg {
  65. display: flex;
  66. flex-direction: column;
  67. justify-content: space-evenly;
  68. flex: 1;
  69. }
  70. .line {
  71. display: flex;
  72. font-size: 14px;
  73. line-height: 22px;
  74. flex-direction: row;
  75. justify-content: space-between;
  76. padding: 0 20px;
  77. }
  78. .primary-btn {
  79. font-size: 16px;
  80. color: #7850FF;
  81. cursor: pointer;
  82. }
  83. .err-icon {
  84. position: relative;
  85. border-radius: 50%;
  86. display: inline-block;
  87. vertical-align: top;
  88. height: 24px;
  89. width: 24px;
  90. background-color: #FF3F17;
  91. }
  92. .succ-icon {
  93. position: relative;
  94. border-radius: 50%;
  95. display: inline-block;
  96. vertical-align: top;
  97. height: 24px;
  98. width: 24px;
  99. background: #51DCB6;
  100. }
  101. .succ-icon:before,
  102. .succ-icon:after {
  103. content: '';
  104. position: absolute;
  105. top: 0;
  106. left: 0;
  107. right: 0;
  108. bottom: 0;
  109. margin: auto;
  110. width: 16px;
  111. height: 2px;
  112. background-color: #fff;
  113. }
  114. .succ-icon:before {
  115. width: 7px;
  116. transform: translate(-3px, 2px) rotate(41deg);
  117. }
  118. .succ-icon:after {
  119. width: 10px;
  120. transform: translateX(2px) rotate(-60deg);
  121. }
  122. .label {
  123. margin-left: 8px;
  124. }
  125. #conflictMsg {
  126. display: flex;
  127. flex-direction: row;
  128. /* justify-content: space-evenly; */
  129. flex: 1;
  130. padding: 0 20px;
  131. align-items: center;
  132. }
  133. #conflictMsg .right {
  134. flex: none;
  135. margin-left: 72px;
  136. }
  137. #conflictMsg .left {
  138. flex: 1;
  139. font-size: 20px;
  140. color: rgba(0, 0, 0, 0.85);
  141. }
  142. .hide {
  143. display: none !important;
  144. }
  145. #syncMsg.success .err-icon {
  146. display: none;
  147. }
  148. #syncMsg.success .label:after {
  149. content: '成功!';
  150. }
  151. #syncMsg.success .primary-btn:after {
  152. content: '查看';
  153. }
  154. #syncMsg.error .succ-icon {
  155. display: none;
  156. }
  157. #syncMsg.error .label:after {
  158. content: '失败';
  159. }
  160. #syncMsg.error .primary-btn:after {
  161. content: '重新同步';
  162. }
  163. #syncMsg.incomming #syncIncoming {
  164. font-size: 20px;
  165. color: rgba(0, 0, 0, 0.85);
  166. }
  167. #syncMsg.incomming .primary-btn:after {
  168. content: '下载';
  169. }
  170. </style>
  171. </head>
  172. <body>
  173. <div id="board">
  174. <div id="close-icon" class="close-icon"></div>
  175. <div class="inner">
  176. <h3>消息通知</h3>
  177. <div id="syncMsg">
  178. <div class="line">
  179. <span id="syncMsgFileName">文件名称</span>
  180. <span id="syncMsgDate">21/08/20 16:34:21</span>
  181. </div>
  182. <div class="line">
  183. <div id="syncResult">
  184. <span class="err-icon close-icon"></span>
  185. <span class="succ-icon"></span>
  186. <span class="label">同步</span>
  187. </div>
  188. <div id="syncIncoming">
  189. </div>
  190. <span id="syncMsgBtn" class="primary-btn"></span>
  191. </div>
  192. </div>
  193. <div id="conflictMsg">
  194. <div class="left" id="conflictMsgText">
  195. 该文件存在版本冲突,请先下载该文件最新版本,修改后再上传!
  196. </div>
  197. <div class="right">
  198. <span id="conflictMsgBtn" class="primary-btn">下载</span>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. <script type="text/javascript">
  204. let contextMsg;
  205. const noop = () => { };
  206. const domId = document.getElementById.bind(document);
  207. const closeBtn = domId('close-icon');
  208. const syncMsgView = domId('syncMsg');
  209. const syncMsgBtn = domId('syncMsgBtn');
  210. const syncMsgFileName = domId('syncMsgFileName');
  211. const syncMsgDate = domId('syncMsgDate');
  212. const syncResult = domId('syncResult');
  213. const syncIncoming = domId('syncIncoming');
  214. const conflictMsgView = domId('conflictMsg');
  215. const conflictMsgBtn = domId('conflictMsgBtn');
  216. const conflictMsgText = domId('conflictMsgText');
  217. syncMsgView.classList.add('hide');
  218. conflictMsgView.classList.add('hide');
  219. syncResult.classList.add('hide');
  220. syncIncoming.classList.add('hide');
  221. function closeWindow() {
  222. window.ipcRenderer.invoke('window:hide');
  223. }
  224. closeBtn.addEventListener('click', closeWindow);
  225. syncMsgBtn.addEventListener('click', function () {
  226. if (contextMsg.taskSyncStatus === 'TASK_SYNC_STATUS_FINISH') { // 查看
  227. window.ipcRenderer.invoke('open-file-position', contextMsg);
  228. closeWindow();
  229. return;
  230. }
  231. if (contextMsg.taskSyncStatus === 'TASK_SYNC_STATUS_FAIL') { // 重新同步
  232. window.ipcRenderer.invoke('re-sync-file', contextMsg);
  233. closeWindow();
  234. return;
  235. }
  236. if (contextMsg.notifyType === 1) { // 下载
  237. window.ipcRenderer.invoke('download-file', contextMsg);
  238. closeWindow();
  239. return;
  240. }
  241. });
  242. conflictMsgBtn.addEventListener('click', function () { // 下载
  243. window.ipcRenderer.invoke('download-file', contextMsg);
  244. closeWindow();
  245. });
  246. window.addIpcRendererListener('on-notify', function (_, message) { // message: DATA.SocketFileMsg
  247. console.log('comming message: ', message);
  248. render(message);
  249. });
  250. function render(message) {
  251. contextMsg = message;
  252. resetDomStatus();
  253. let runningMethod = noop;
  254. if(message.notifyType === 1) {
  255. runningMethod = renderTaskIncoming;
  256. } else if(message.notifyType === 2 || message.notifyType === 3) {
  257. runningMethod = renderConflictMsg;
  258. } else if(message.taskSyncStatus === 'TASK_SYNC_STATUS_FINISH') {
  259. runningMethod = renderTaskSuccess;
  260. } else if(message.taskSyncStatus === 'TASK_SYNC_STATUS_FAIL') {
  261. runningMethod = renderTaskError;
  262. }
  263. runningMethod(message);
  264. }
  265. function useView(dom) { dom.classList.remove('hide'); };
  266. function fileFullName(message) {
  267. const extension = message.extension;
  268. return `${message.archName}${extension ? '.' + extension : ''}`;
  269. }
  270. function resetDomStatus() {
  271. syncMsgView.classList.add('hide');
  272. syncMsgView.classList.remove('success');
  273. syncMsgView.classList.remove('error');
  274. syncMsgView.classList.remove('incomming');
  275. syncResult.classList.add('hide');
  276. syncIncoming.classList.add('hide');
  277. conflictMsgView.classList.add('hide');
  278. }
  279. function renderTaskSuccess(message) {
  280. useView(syncMsgView);
  281. syncMsgView.classList.add('success');
  282. useView(syncResult);
  283. syncMsgFileName.innerText = fileFullName(message);
  284. syncMsgDate.innerText = message.taskCreateDateStr;
  285. }
  286. function renderTaskError(message) {
  287. useView(syncMsgView);
  288. syncMsgView.classList.add('error');
  289. syncResult.classList.remove('hide');
  290. syncMsgFileName.innerText = fileFullName(message);
  291. syncMsgDate.innerText = message.taskCreateDateStr;
  292. }
  293. function renderTaskIncoming(message) {
  294. useView(syncMsgView);
  295. syncMsgView.classList.add('incomming');
  296. useView(syncIncoming);
  297. syncMsgFileName.innerText = fileFullName(message);
  298. syncMsgDate.innerText = message.taskCreateDateStr;
  299. syncIncoming.innerText = message.notifyMessage;
  300. }
  301. function renderConflictMsg(message) {
  302. useView(conflictMsgView);
  303. conflictMsgText.innerText = `「${fileFullName(message)}」存在版本冲突,请先下载该文件最新版本,修改后再上传!`;
  304. }
  305. </script>
  306. </body>
  307. </html>