index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <template>
  2. <!-- notifyTrayPanel -->
  3. <div
  4. class="x-panel sds-notify-tray-panel sds-tray-panel"
  5. style="
  6. position: absolute;
  7. z-index: 11000;
  8. visibility: visible;
  9. right: 10px;
  10. top: 41px;
  11. "
  12. :style="{ display: display }"
  13. @click.stop="clickNotifyTrayPanel"
  14. >
  15. <div class="x-panel-header">
  16. <span class="x-panel-header-text"
  17. ><div class="sds-notify-setting-btn" @click.stop="openNotifySetting">
  18. &nbsp;
  19. </div>
  20. <span class="x-panel-header-text">消息</span></span
  21. >
  22. </div>
  23. <div class="x-panel-bwrap">
  24. <div class="x-panel-body">
  25. <div
  26. id="sds-notify-tray-panel-dataview"
  27. class="
  28. sds-notify-tray-panel-dataview
  29. syno-dataview
  30. flexcrollactive
  31. scroll-at-top scroll-at-bottom scroll-at-left scroll-at-right
  32. "
  33. style="
  34. overflow: hidden;
  35. width: 340px;
  36. height: 100%;
  37. border-width: 0px;
  38. position: relative;
  39. text-align: left;
  40. padding: 0px;
  41. "
  42. >
  43. <div
  44. id="sds-notify-tray-panel-dataview_mcontentwrapper"
  45. class="mcontentwrapper"
  46. style="
  47. width: 340px;
  48. height: 100%;
  49. top: 0px;
  50. left: 0px;
  51. border-bottom: 0px solid black;
  52. text-align: start;
  53. padding: 0px;
  54. position: relative;
  55. z-index: 2;
  56. "
  57. >
  58. <div
  59. id="sds-notify-tray-panel-dataview_contentwrapper"
  60. class="contentwrapper"
  61. style="
  62. position: relative;
  63. top: 0px;
  64. width: 100%;
  65. display: block;
  66. padding: 0px;
  67. left: 0px;
  68. "
  69. >
  70. <div style="width: 100%">
  71. <div
  72. class="sds-notify-tray-panel-dataview-wrapper"
  73. v-if="notifyTrayPanelDetail.detailMessageList.length"
  74. >
  75. <div
  76. class="item"
  77. :class="detailMessage.cls"
  78. v-for="(
  79. detailMessage, detailMessageIndex
  80. ) in notifyTrayPanelDetail.detailMessageList"
  81. :key="detailMessage.id"
  82. >
  83. <div class="title blue-status">
  84. <div class="notification-level info"></div>
  85. <div class="content cursor-no-pointer">
  86. {{ detailMessage.title }}
  87. </div>
  88. </div>
  89. <div class="time">{{ detailMessage.time }}</div>
  90. <div class="msg allowDefCtxMenu selectabletext">
  91. <div class="detail" v-html="detailMessage.text"></div>
  92. <a
  93. class="link-font"
  94. @click.stop="
  95. openNotifyDetail(
  96. detailMessage,
  97. detailMessageIndex,
  98. $event
  99. )
  100. "
  101. >详情</a
  102. >
  103. </div>
  104. <div class="remain-items"></div>
  105. </div>
  106. </div>
  107. <div style="width: 100%" id="ext-gen600" v-else>
  108. <div
  109. class="sds-notify-empty-text"
  110. id="ext-gen644"
  111. aria-label="没有通知"
  112. style="line-height: 418px"
  113. >
  114. 没有通知
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <div
  121. id="sds-notify-tray-panel-dataview_scrollwrapper"
  122. class="scrollwrapper"
  123. style="
  124. width: 340px;
  125. height: 100%;
  126. position: absolute;
  127. top: 0px;
  128. left: 0px;
  129. "
  130. >
  131. <div
  132. id="sds-notify-tray-panel-dataview_zoomdetectdiv"
  133. class="zoomdetectdiv"
  134. style="
  135. font-size: 12px;
  136. height: 1em;
  137. width: 1em;
  138. position: absolute;
  139. z-index: -999;
  140. visibility: hidden;
  141. "
  142. ></div>
  143. <div
  144. id="sds-notify-tray-panel-dataview_vscrollerbase"
  145. class="vscrollerbase scrollgeneric flexinactive"
  146. style="height: 345px; left: 340px; visibility: hidden"
  147. >
  148. <div
  149. id="sds-notify-tray-panel-dataview_vscrollerbar"
  150. class="vscrollerbar scrollgeneric"
  151. style="
  152. padding: 0px;
  153. height: 341px;
  154. top: 0px;
  155. z-index: 2;
  156. visibility: hidden;
  157. "
  158. >
  159. <div
  160. id="sds-notify-tray-panel-dataview_vscrollerbarbeg"
  161. class="vscrollerbarbeg scrollgeneric"
  162. style="height: 341px"
  163. ></div>
  164. <div
  165. id="sds-notify-tray-panel-dataview_vscrollerbarend"
  166. class="vscrollerbarend scrollgeneric"
  167. style="top: 341px"
  168. ></div>
  169. </div>
  170. <div
  171. id="sds-notify-tray-panel-dataview_vscrollerbasebeg"
  172. class="vscrollerbasebeg scrollgeneric"
  173. style="height: 345px"
  174. ></div>
  175. <div
  176. id="sds-notify-tray-panel-dataview_vscrollerbaseend"
  177. class="vscrollerbaseend scrollgeneric"
  178. style="top: 345px"
  179. ></div>
  180. </div>
  181. <div
  182. id="sds-notify-tray-panel-dataview_hscrollerbase"
  183. class="hscrollerbase scrollgeneric flexinactive"
  184. style="width: 340px; top: 345px; visibility: hidden"
  185. >
  186. <div
  187. id="sds-notify-tray-panel-dataview_hscrollerbar"
  188. class="hscrollerbar scrollgeneric"
  189. style="
  190. padding: 0px;
  191. width: 336px;
  192. left: 0px;
  193. z-index: 2;
  194. visibility: hidden;
  195. "
  196. >
  197. <div
  198. id="sds-notify-tray-panel-dataview_hscrollerbarbeg"
  199. class="hscrollerbarbeg scrollgeneric"
  200. style="width: 336px"
  201. ></div>
  202. <div
  203. id="sds-notify-tray-panel-dataview_hscrollerbarend"
  204. class="hscrollerbarend scrollgeneric"
  205. style="left: 336px"
  206. ></div>
  207. </div>
  208. <div
  209. id="sds-notify-tray-panel-dataview_hscrollerbasebeg"
  210. class="hscrollerbasebeg scrollgeneric"
  211. style="width: 340px"
  212. ></div>
  213. <div
  214. id="sds-notify-tray-panel-dataview_hscrollerbaseend"
  215. class="hscrollerbaseend scrollgeneric"
  216. style="left: 340px"
  217. ></div>
  218. </div>
  219. <div
  220. id="sds-notify-tray-panel-dataview_scrollerjogbox"
  221. class="scrollerjogbox scrollgeneric"
  222. style="visibility: hidden"
  223. ></div>
  224. <div
  225. id="sds-notify-tray-panel-dataview_domfixdiv"
  226. class="domfixdiv"
  227. style="display: none"
  228. ></div>
  229. <div
  230. id="sds-notify-tray-panel-dataview_copyholder"
  231. class="copyholder"
  232. style="
  233. border: 0px solid blue;
  234. visibility: hidden;
  235. padding: 0px;
  236. display: none;
  237. "
  238. ></div>
  239. </div>
  240. </div>
  241. </div>
  242. <div class="x-panel-bbar" style="width: 340px">
  243. <div
  244. class="x-toolbar x-small-editor x-toolbar-layout-ct"
  245. style="width: 328px"
  246. >
  247. <table cellspacing="0" class="x-toolbar-ct">
  248. <tbody>
  249. <tr>
  250. <td class="x-toolbar-left" align="left">
  251. <table cellspacing="0">
  252. <tbody>
  253. <tr class="x-toolbar-left-row">
  254. <td class="x-toolbar-cell">
  255. <span
  256. cellspacing="0"
  257. class="
  258. x-btn
  259. syno-ux-button syno-ux-button-grey
  260. x-btn-noicon
  261. "
  262. :class="
  263. notifyTrayPanelDetail.detailMessageList.length
  264. ? ''
  265. : 'x-item-disabled'
  266. "
  267. style="width: auto; margin-left: 0px"
  268. ><em class="x-unselectable" unselectable="on"
  269. ><button
  270. type="button"
  271. class="x-btn-text"
  272. @click="clearAll"
  273. >
  274. 清除全部
  275. </button></em
  276. ></span
  277. >
  278. </td>
  279. </tr>
  280. </tbody>
  281. </table>
  282. </td>
  283. <td class="x-toolbar-right" align="right">
  284. <table cellspacing="0" class="x-toolbar-right-ct">
  285. <tbody>
  286. <tr>
  287. <td>
  288. <table cellspacing="0">
  289. <tbody>
  290. <tr class="x-toolbar-right-row">
  291. <td class="x-toolbar-cell">
  292. <span
  293. cellspacing="0"
  294. class="
  295. x-btn
  296. syno-ux-button syno-ux-button-blue
  297. x-btn-noicon
  298. "
  299. style="width: auto; margin-left: 0px"
  300. ><em class="x-unselectable"
  301. ><button
  302. type="button"
  303. class="x-btn-text"
  304. @click="openNotifyShowall"
  305. >
  306. 显示全部
  307. </button></em
  308. ></span
  309. >
  310. </td>
  311. </tr>
  312. </tbody>
  313. </table>
  314. </td>
  315. <td>
  316. <table cellspacing="0">
  317. <tbody>
  318. <tr class="x-toolbar-extras-row"></tr>
  319. </tbody>
  320. </table>
  321. </td>
  322. </tr>
  323. </tbody>
  324. </table>
  325. </td>
  326. </tr>
  327. </tbody>
  328. </table>
  329. </div>
  330. </div>
  331. </div>
  332. <div class="sds-notify-panel-arrow" style="left: 179px; top: -17px"></div>
  333. </div>
  334. </template>
  335. <script>
  336. export default {
  337. data() {
  338. return {
  339. display: "none",
  340. notifyTrayPanelDetail: {
  341. detailMessageList: [
  342. {
  343. id: 0,
  344. title: "系统",
  345. date: "1651720579",
  346. time: "",
  347. time1: "",
  348. cls: "unread",
  349. text: '我们的<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>已更新。',
  350. message:
  351. '我们已更新<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>,使它更容易理解并反映我们最近的政策更改。建议您通过单击上面的链接来阅读我们的服务数据收集披露,并定期检查是否有任何更改。',
  352. showMessage: " 我们的服务数据收集披露已更新。 ",
  353. },
  354. {
  355. id: 1,
  356. title: "系统",
  357. time: "",
  358. time1: "",
  359. cls: "unread",
  360. date: "1612493322",
  361. text: '我们的<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>已更新。',
  362. message:
  363. '我们已更新<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>,使它更容易理解并反映我们最近的政策更改。建议您通过单击上面的链接来阅读我们的服务数据收集披露,并定期检查是否有任何更改。',
  364. showMessage: " 我们的服务数据收集披露已更新。 ",
  365. },
  366. {
  367. id: 2,
  368. title: "系统",
  369. time: "",
  370. time1: "",
  371. cls: "unread",
  372. date: "1651695379",
  373. text: '我们的<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>已更新。',
  374. message:
  375. '我们已更新<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>,使它更容易理解并反映我们最近的政策更改。建议您通过单击上面的链接来阅读我们的服务数据收集披露,并定期检查是否有任何更改。',
  376. showMessage: " 我们的服务数据收集披露已更新。 ",
  377. },
  378. {
  379. id: 3,
  380. title: "系统",
  381. time: "",
  382. time1: "",
  383. cls: "unread",
  384. date: "1625453322",
  385. text: '我们的<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>已更新。',
  386. message:
  387. '我们已更新<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>,使它更容易理解并反映我们最近的政策更改。建议您通过单击上面的链接来阅读我们的服务数据收集披露,并定期检查是否有任何更改。',
  388. showMessage: " 我们的服务数据收集披露已更新。 ",
  389. },
  390. {
  391. id: 4,
  392. title: "系统",
  393. time: "",
  394. time1: "",
  395. cls: "unread",
  396. date: "1651522579",
  397. text: '我们的<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>已更新。',
  398. message:
  399. '我们已更新<a href="https://sy.to/zvgxb" target="_blank">服务数据收集披露</a>,使它更容易理解并反映我们最近的政策更改。建议您通过单击上面的链接来阅读我们的服务数据收集披露,并定期检查是否有任何更改。',
  400. showMessage: " 我们的服务数据收集披露已更新。 ",
  401. },
  402. ],
  403. },
  404. };
  405. },
  406. created() {},
  407. mounted() {
  408. this.$bus.on("openNotifyTrayPanel", this.openNotifyTrayPanel);
  409. this.$bus.on("clearAllNotifyMessage", this.clearAllNotifyMessage);
  410. },
  411. components: {},
  412. methods: {
  413. //显示本页面
  414. openNotifyTrayPanel(e) {
  415. if (this.display === "none") {
  416. let date = new Date().getTime();
  417. this.notifyTrayPanelDetail.detailMessageList.forEach((item) => {
  418. function timestampToTime(timestamp) {
  419. if (timestamp.length == 10) {
  420. var timestamp = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  421. } else {
  422. var timestamp = new Date(timestamp);
  423. }
  424. let Y = timestamp.getFullYear() + "-";
  425. let M =
  426. (timestamp.getMonth() + 1 < 10
  427. ? "0" + (timestamp.getMonth() + 1)
  428. : timestamp.getMonth() + 1) + "-";
  429. let D =
  430. (timestamp.getDate() < 10
  431. ? "0" + timestamp.getDate()
  432. : timestamp.getDate()) + " ";
  433. let h =
  434. (timestamp.getHours() < 10
  435. ? "0" + timestamp.getHours()
  436. : timestamp.getHours()) + ":";
  437. let m =
  438. (timestamp.getMinutes() < 10
  439. ? "0" + timestamp.getMinutes()
  440. : timestamp.getMinutes()) + ":";
  441. let s =
  442. timestamp.getSeconds() < 10
  443. ? "0" + timestamp.getSeconds()
  444. : timestamp.getSeconds();
  445. return Y + M + D + h + m + s;
  446. }
  447. if (item.date.length == 10) {
  448. var itemDate = item.date * 1000;
  449. } else {
  450. var itemDate = item.date;
  451. }
  452. if (date - itemDate <= 3600000) {
  453. item.time = parseInt((date - itemDate) / (1000 * 60)) + "分钟前";
  454. } else if (date - itemDate <= 86400000) {
  455. item.time =
  456. parseInt((date - itemDate) / (1000 * 60 * 60)) + "小时前";
  457. } else if (date - itemDate <= 2592000000) {
  458. item.time =
  459. parseInt((date - itemDate) / (1000 * 60 * 60 * 24)) + "天前";
  460. } else if (date - itemDate <= 31536000000) {
  461. item.time =
  462. parseInt((date - itemDate) / (1000 * 60 * 60 * 24 * 30)) +
  463. "个月前";
  464. } else {
  465. item.time =
  466. parseInt((date - itemDate) / (1000 * 60 * 60 * 24 * 365)) +
  467. "年前";
  468. }
  469. item.time1 = timestampToTime(item.date);
  470. });
  471. this.display = "block";
  472. if (!e.srcElement.className.includes(" pressed")) {
  473. e.srcElement.className = e.srcElement.className + " pressed";
  474. }
  475. this.$bus.emit("notifyMessageRead");
  476. window.addEventListener("click", this.hiddenNotifyAndchangeIconColor);
  477. } else {
  478. this.display = "none";
  479. if (e.srcElement.className.includes(" pressed")) {
  480. e.srcElement.className = e.srcElement.className.replace(
  481. " pressed",
  482. ""
  483. );
  484. }
  485. }
  486. },
  487. // 点击本页面
  488. clickNotifyTrayPanel() {
  489. },
  490. // 隐藏本页面并更新页面对应的图标颜色
  491. hiddenNotifyAndchangeIconColor(e) {
  492. let el = document.querySelector(".tray-item.notify-button");
  493. if (e.srcElement === el) {
  494. window.addEventListener("click", this.hiddenNotifyAndchangeIconColor);
  495. } else {
  496. this.display = "none";
  497. if (el.className && el.className.includes(" pressed")) {
  498. el.className = el.className.replace(" pressed", "");
  499. }
  500. window.removeEventListener(
  501. "click",
  502. this.hiddenNotifyAndchangeIconColor
  503. );
  504. }
  505. },
  506. //打开详情页面
  507. openNotifyDetail(detailMessage, detailMessageIndex, e) {
  508. this.hiddenNotifyAndchangeIconColor(e);
  509. // openNotifyDetail(detailMessage, detailMessageIndex,e)
  510. this.$bus.emit("openNotifyDetail", detailMessage);
  511. this.notifyTrayPanelDetail.detailMessageList[detailMessageIndex].cls = "";
  512. },
  513. // 打开显示全部页面
  514. openNotifyShowall(e) {
  515. this.hiddenNotifyAndchangeIconColor(e);
  516. this.$bus.emit(
  517. "openNotifyShowall",
  518. this.notifyTrayPanelDetail.detailMessageList
  519. );
  520. },
  521. // 打开清除全部页面
  522. clearAll(e) {
  523. this.hiddenNotifyAndchangeIconColor(e);
  524. if (!this.notifyTrayPanelDetail.detailMessageList.length) {
  525. return;
  526. }
  527. let obj = {
  528. cls: "confirm-delete-icon",
  529. icon: "confirm-delete-icon",
  530. title: "",
  531. text: "所有桌面通知都会被清除。是否确定要继续?",
  532. buttonList: [
  533. {
  534. id: 0,
  535. text: "取消",
  536. cls: "v-btn-cancel",
  537. event: this.cancelDeleteAll,
  538. },
  539. {
  540. id: 1,
  541. text: "清除全部",
  542. cls: "v-btn-danger",
  543. event: this.confirmDeleteAll,
  544. },
  545. ],
  546. };
  547. this.$bus.emit("openMessage", obj);
  548. this.$bus.emit("openMask");
  549. },
  550. // 取消清除所有信息
  551. cancelDeleteAll() {
  552. this.$bus.emit("closeMessage");
  553. this.$bus.emit("closeMask");
  554. },
  555. // 确定清除所有信息
  556. confirmDeleteAll() {
  557. this.$bus.emit("clearAllNotifyMessage");
  558. this.cancelDeleteAll();
  559. },
  560. // 清除所有信息
  561. clearAllNotifyMessage() {
  562. this.notifyTrayPanelDetail.detailMessageList = [];
  563. },
  564. // 打开设置页面
  565. openNotifySetting(e) {
  566. this.hiddenNotifyAndchangeIconColor(e);
  567. this.$bus.emit("openNotifySetting");
  568. },
  569. },
  570. name: "NotifyTrayPanel",
  571. };
  572. </script>
  573. <style lang="css" scoped>
  574. #sds-notify-tray-panel-dataview_mcontentwrapper {
  575. overflow: scroll;
  576. }
  577. #sds-notify-tray-panel-dataview_mcontentwrapper::-webkit-scrollbar {
  578. width: 0 !important;
  579. }
  580. </style>