joined-group-list.vue 3.0 KB

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