index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="detail-wrapper">
  3. <div class="back-bar">
  4. <img
  5. :src="require('@/assets/svg/icon-nft-back-arrow.svg')"
  6. class="icon-arrow"
  7. @click="back"
  8. />
  9. <span>Settings</span>
  10. </div>
  11. <div class="item">
  12. <div class="l">Announcement Notification</div>
  13. <div class="r">
  14. <a-switch v-model:checked="noticeStatus" @change="change"></a-switch>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script setup>
  20. import { onBeforeMount, ref } from "vue";
  21. import router from "@/router/popup.js";
  22. import { getSetting, putSetting } from "@/http/user";
  23. let noticeStatus = ref(true);
  24. function back() {
  25. router.back();
  26. }
  27. function change(checked) {
  28. let noticeSwitch = checked ? 1 : 0;
  29. // set
  30. putSetting({
  31. params: { noticeSwitch }
  32. }).then(res => {
  33. let { code, data } = res;
  34. if (code === 0) {
  35. noticeStatus.value = checked
  36. } else {
  37. noticeStatus.value = !checked
  38. }
  39. }).catch(() => {
  40. noticeStatus.value = !checked
  41. })
  42. noticeSetting()
  43. }
  44. function noticeSetting() {
  45. chrome.runtime.sendMessage({
  46. actionType: "USER_SETTING",
  47. data: {
  48. status: noticeStatus.value
  49. }
  50. }, (response) => {
  51. console.log("res", response);
  52. });
  53. }
  54. onBeforeMount(() => {
  55. getSetting({}).then((res) => {
  56. let { code, data } = res;
  57. if (code === 0) {
  58. noticeStatus.value = data.noticeSwitch === 1 ? true : false;
  59. }
  60. });
  61. });
  62. </script>
  63. <style lang='scss' scoped>
  64. .detail-wrapper {
  65. width: 100%;
  66. height: 100%;
  67. background-color: #f5f5f5;
  68. .back-bar {
  69. height: 48px;
  70. background: #ffffff;
  71. box-shadow: 0px 0.5px 0px #d1d9dd;
  72. box-sizing: border-box;
  73. padding: 14px;
  74. font-weight: 500;
  75. font-size: 16px;
  76. display: flex;
  77. align-items: center;
  78. margin-bottom: 14px;
  79. .icon-arrow {
  80. width: 24px;
  81. margin-right: 12px;
  82. cursor: pointer;
  83. }
  84. }
  85. .item {
  86. display: flex;
  87. align-items: center;
  88. justify-content: space-between;
  89. height: 50px;
  90. padding: 0 16px;
  91. background-color: #ffffff;
  92. .l {
  93. color: #000000;
  94. font-size: 15px;
  95. font-weight: 500;
  96. }
  97. }
  98. }
  99. :deep() .ant-switch {
  100. background-color: #e9ecee;
  101. height: 14px;
  102. line-height: 16px;
  103. min-width: 36px;
  104. }
  105. :deep() .ant-switch-checked {
  106. background-color: #aed8f5 !important;
  107. }
  108. :deep() .ant-switch::after {
  109. width: 20px;
  110. height: 20px;
  111. top: -4px;
  112. left: -1px;
  113. }
  114. :deep() .ant-switch-checked::after {
  115. background-color: #1d9bf0 !important;
  116. margin-left: 3px;
  117. left: 100% !important;
  118. }
  119. </style>