guide.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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" v-if="pageData.guideData.guideType == 'image'">
  7. <div class="img-item" v-for="(item, index) in pageData.guideData.guideData" :key="index">
  8. <img class="img" :src="item">
  9. </div>
  10. </div>
  11. </div>
  12. </div>
  13. <div class="bottom">
  14. <div class="title">
  15. Enter Link
  16. </div>
  17. <div class="search-input-wrapper">
  18. <input class="input" v-model="siteUrl" placeholder="Enter link" />
  19. <div class="btn" @click="confirm">
  20. <img :src="require('@/assets/svg/icon-tool-box-guide-arrow.svg')" alt="">
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script setup>
  27. import { ref, reactive, onMounted } from "vue";
  28. import { checkURL } from "@/uilts/help"
  29. import { setChromeStorage, getChromeStorage } from "@/uilts/chromeExtension"
  30. import { message } from "ant-design-vue";
  31. import { checkInputUrlInBlacklist } from "@/http/toolBoxApi";
  32. let siteUrl = ref('');
  33. let pageData = reactive({
  34. guideData: [],
  35. selectGuideApp: {}
  36. });
  37. const confirm = async () => {
  38. siteUrl.value = siteUrl.value.trim();
  39. if (!checkURL(siteUrl.value)) {
  40. message.info('Incorrect URL entered');
  41. return;
  42. }
  43. let blackListRes = await checkInputUrlInBlacklist({
  44. params: {
  45. url: siteUrl.value
  46. }
  47. })
  48. if(blackListRes.code == 0) {
  49. if(blackListRes.data) {
  50. message.info('This site is not supported');
  51. return;
  52. }
  53. }
  54. let {list: windowList = []} = await getChromeStorage('guideAppWindowList') || {list: []};
  55. chrome.runtime.sendMessage({
  56. actionType: "CONTENT_GUIDE_APPLY_APP",
  57. data: {
  58. siteUrl: siteUrl.value,
  59. selectGuideApp: pageData.selectGuideApp
  60. }
  61. }, (response) => { });
  62. setTimeout(() => {
  63. if(windowList && windowList.length) {
  64. for (let i = 0; i < windowList.length; i++) {
  65. let item = windowList[i];
  66. chrome.windows.remove(
  67. item.id,
  68. function () { }
  69. )
  70. };
  71. chrome.storage.local.remove("selectGuideApp");
  72. chrome.storage.local.remove("guideAppWindowList");
  73. }
  74. }, 600)
  75. };
  76. const setPageData = async () => {
  77. let selectGuideApp = await getChromeStorage('selectGuideApp') || {};
  78. pageData.selectGuideApp = selectGuideApp;
  79. if(selectGuideApp.guideData) {
  80. if(typeof selectGuideApp.guideData == 'string') {
  81. pageData.guideData = JSON.parse(selectGuideApp.guideData);
  82. } else {
  83. pageData.guideData = selectGuideApp.guideData
  84. }
  85. };
  86. }
  87. onMounted(() => {
  88. setPageData();
  89. })
  90. </script>
  91. <style lang="scss">
  92. html,
  93. body,
  94. #app {
  95. margin: 0 !important;
  96. width: 100%;
  97. height: 100%;
  98. }
  99. .guide-wrapper {
  100. width: 100%;
  101. height: 100%;
  102. .top {
  103. height: calc(100% - 158px);
  104. padding: 30px 43px;
  105. box-sizing: border-box;
  106. overflow-y: auto;
  107. .title {
  108. font-weight: 500;
  109. font-size: 30px;
  110. margin-top: 10px;
  111. margin-bottom: 30px;
  112. }
  113. .img-item {
  114. margin-bottom: 18px;
  115. .img {
  116. width: 100%;
  117. }
  118. }
  119. }
  120. .bottom {
  121. height: 158px;
  122. background: #1D9BF0;
  123. padding: 20px;
  124. box-sizing: border-box;
  125. .title {
  126. font-weight: 500;
  127. font-size: 20px;
  128. color: #fff;
  129. margin-top: 7px;
  130. margin-bottom: 18px;
  131. }
  132. .search-input-wrapper {
  133. width: 100%;
  134. height: 49px;
  135. background: #fff;
  136. border-radius: 100px;
  137. box-sizing: border-box;
  138. display: flex;
  139. .input {
  140. border: none;
  141. outline: none;
  142. border-radius: 100px;
  143. width: calc(100% - 49px);
  144. height: 100%;
  145. box-sizing: border-box;
  146. color: #636363;
  147. padding: 15px 20px 15px 20px;
  148. }
  149. .btn {
  150. width: 49px;
  151. height: 100%;
  152. background: #D2EAFC;
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. border-top-right-radius: 100px;
  157. border-bottom-right-radius: 100px;
  158. cursor: pointer;
  159. }
  160. }
  161. }
  162. }
  163. </style>