guide.vue 5.0 KB

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