guide.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="guide-wrapper">
  3. <div class="top">
  4. <div class="title">Guided Tutorial</div>
  5. <div class="content">
  6. <div class="img-list"
  7. v-if="pageData.guideData.guideType == 'image'">
  8. <div class="img-item"
  9. v-for="(item, index) in pageData.guideData.guideData"
  10. :key="index">
  11. <img class="img" :src="item" >
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. <div class="bottom">
  17. <div class="title">
  18. Enter Link
  19. </div>
  20. <div class="search-input-wrapper">
  21. <input class="input" v-model="siteUrl" placeholder="Enter link" />
  22. <div class="btn" @click="confirm">
  23. <img :src="require('@/assets/svg/icon-tool-box-guide-arrow.svg')" alt="">
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script setup>
  30. import { ref, reactive, onMounted } from "vue";
  31. import { checkURL } from "@/uilts/help"
  32. let siteUrl = ref('');
  33. let pageData = reactive({
  34. guideType: '',
  35. guideData: []
  36. });
  37. const confirm = () => {
  38. siteUrl.value = siteUrl.value.trim();
  39. if(!checkURL(siteUrl.value)) {
  40. return;
  41. }
  42. chrome.runtime.sendMessage({
  43. actionType: "CONTENT_GUIDE_APPLY_APP",
  44. data: {
  45. siteUrl: siteUrl.value
  46. }
  47. },(response) => {});
  48. setTimeout(() => {
  49. for(let i = 0; i < pageData.windowData.length; i++) {
  50. let item = pageData.windowData[i];
  51. chrome.windows.remove(
  52. item.id,
  53. function() {}
  54. )
  55. };
  56. }, 600)
  57. };
  58. const onRuntimeMsg = () => {
  59. chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
  60. sendResponse('ok')
  61. switch (req.actionType) {
  62. case 'CONTENT_EDIT_SEND_GUIDE_DATA':
  63. let {guideData, windowData} = req.data;
  64. pageData.guideData = guideData;
  65. pageData.windowData = windowData;
  66. break;
  67. }
  68. })
  69. }
  70. onMounted(() => {
  71. setTimeout(() => {
  72. chrome.runtime.sendMessage({
  73. actionType: "CONTENT_GET_GUIDE_DATA",
  74. data:{}
  75. },(response) => {});
  76. }, 600)
  77. onRuntimeMsg();
  78. })
  79. </script>
  80. <style lang="scss">
  81. html, body, #app {
  82. margin: 0 !important;
  83. width: 100%;
  84. height: 100%;
  85. }
  86. .guide-wrapper {
  87. width: 100%;
  88. height: 100%;
  89. .top {
  90. height: calc(100% - 158px);
  91. padding: 30px 43px;
  92. box-sizing: border-box;
  93. overflow-y: auto;
  94. .title {
  95. font-weight: 500;
  96. font-size: 30px;
  97. margin-top: 10px;
  98. margin-bottom: 30px;
  99. }
  100. .img-item {
  101. margin-bottom: 18px;
  102. .img {
  103. width: 100%;
  104. }
  105. }
  106. }
  107. .bottom {
  108. height: 158px;
  109. background: #1D9BF0;
  110. padding: 20px;
  111. box-sizing: border-box;
  112. .title {
  113. font-weight: 500;
  114. font-size: 20px;
  115. color: #fff;
  116. margin-top: 7px;
  117. margin-bottom: 18px;
  118. }
  119. .search-input-wrapper {
  120. width: 100%;
  121. height: 49px;
  122. background: #fff;
  123. border-radius: 100px;
  124. box-sizing: border-box;
  125. display: flex;
  126. .input {
  127. border: none;
  128. outline: none;
  129. border-radius: 100px;
  130. width: calc(100% - 49px);
  131. height: 100%;
  132. box-sizing: border-box;
  133. color: #636363;
  134. padding: 15px 20px 15px 20px;
  135. }
  136. .btn {
  137. width: 49px;
  138. height: 100%;
  139. background: #D2EAFC;
  140. display: flex;
  141. align-items: center;
  142. justify-content: center;
  143. border-top-right-radius: 100px;
  144. border-bottom-right-radius: 100px;
  145. cursor: pointer;
  146. }
  147. }
  148. }
  149. }
  150. </style>