joined-group-list.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div class="group-list-page" ref="pageWrapperDom">
  3. <div class="title">
  4. <img class="icon" :src="require('@/assets/svg/icon-joined-group-logo.svg')">
  5. NFT Owners Group
  6. </div>
  7. <div class="content-wrapper">
  8. <nft-group-list style="height: 100%" ref="groupListDom" :showBadge="true" @clickCallBack="clickHandler"
  9. @updateList="updateList"></nft-group-list>
  10. </div>
  11. </div>
  12. </template>
  13. <script setup>
  14. import { onMounted, ref, nextTick } from "vue";
  15. import NftGroupList from '@/view/components/nft-group-list.vue';
  16. import { sendCurrentTabMessage, setChromeStorage } from '@/uilts/chromeExtension.js';
  17. let groupListDom = ref(null);
  18. const clickHandler = (params) => {
  19. setChromeStorage({
  20. groupTabData: JSON.stringify({
  21. deTabVal: 'deGroupTab'
  22. })
  23. })
  24. let url = `https://twitter.com/${params.defaultTwitterAccount}`;
  25. sendMessageToContent({
  26. actionType: 'IFRAME_PAGE_JUMP',
  27. data: {
  28. url
  29. }
  30. })
  31. }
  32. const sendMessageToContent = (params) => {
  33. let { actionType, data } = params || {};
  34. chrome.tabs.getCurrent((tab) => {
  35. chrome.tabs.sendMessage(tab.id, {
  36. actionType,
  37. data,
  38. }, (res) => { console.log(res) });
  39. })
  40. }
  41. const updateList = (data) => {
  42. setHeight(data);
  43. };
  44. const setHeight = (data) => {
  45. const maxHeight = 321;
  46. nextTick(() => {
  47. if (!data || !data.length) {
  48. sendCurrentTabMessage({
  49. actionType: "IFRAME_JOINED_GROUP_SET_STYLE",
  50. data: {
  51. height: '0px'
  52. }
  53. })
  54. return;
  55. }
  56. let listDom = document.querySelector('.list-content');
  57. if (listDom) {
  58. const titleDomHeight = 56, marginBottom = 12;
  59. let height = maxHeight;
  60. let contentHeight = listDom.offsetHeight + titleDomHeight + marginBottom;
  61. if (contentHeight < maxHeight) {
  62. height = contentHeight;
  63. } else {
  64. height = maxHeight;
  65. }
  66. sendCurrentTabMessage({
  67. actionType: "IFRAME_JOINED_GROUP_SET_STYLE",
  68. data: {
  69. height: height + 'px'
  70. }
  71. })
  72. }
  73. })
  74. }
  75. onMounted(() => {
  76. })
  77. </script>
  78. <style lang="scss">
  79. html,
  80. body,
  81. #app {
  82. width: 100%;
  83. height: 100%;
  84. margin: 0;
  85. padding: 0;
  86. }
  87. .group-list-page {
  88. height: 100%;
  89. overflow-y: auto;
  90. background: #F7F9F9;
  91. padding: 0 16px;
  92. box-sizing: border-box;
  93. .title {
  94. font-weight: 800;
  95. font-size: 18px;
  96. box-sizing: border-box;
  97. height: 56px;
  98. display: flex;
  99. align-items: center;
  100. .icon {
  101. margin-right: 8px;
  102. }
  103. }
  104. .content-wrapper {
  105. height: calc(100% - 60px);
  106. overflow-y: auto;
  107. padding-left: 4px;
  108. box-sizing: border-box;
  109. }
  110. }
  111. </style>