|
@@ -11,6 +11,16 @@
|
|
|
<iframe :src="iframe_url" frameborder="0" sandbox></iframe>
|
|
|
</div>
|
|
|
<div class="content" v-else>
|
|
|
+ <template v-if="state.showMask && state.status != '固定右上角'">
|
|
|
+ <div class="mask" @click="confirmStatus">
|
|
|
+ <img class="luck" :src=" require('@/assets/svg/icon-post-lock.svg') " />
|
|
|
+ <div class="btn">
|
|
|
+ <img class="img" v-if="state.detail && state.detail.nftProjectIcon" :src=" state.detail.nftProjectIcon " />
|
|
|
+ <div class="font">Available for holders of {{state.detail.nftProjectName}} NFT</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <img class="mask_bg" v-if="state.detail.linkImagePath" :src=" state.detail.linkImagePath " />
|
|
|
+ </template>
|
|
|
<iframe :src="state.iframe_url" v-show="state.status == 'iframe'" ref="dom_iframe" frameborder="0"
|
|
|
scrolling="yes" allow="camera *;microphone *"></iframe>
|
|
|
<!-- sandbox="allow-same-origin allow-scripts allow-popups allow-top-navigation allow-forms allow-modals allow-popups-to-escape-sandbox" -->
|
|
@@ -64,9 +74,13 @@
|
|
|
<script setup>
|
|
|
import { getChromeStorage, setChromeStorage, defineProps, sendChromeTabMessage } from "@/uilts/chromeExtension";
|
|
|
import { getPostDetail } from '@/http/redPacket.js'
|
|
|
+import { getPostEditorNftCertInfo } from '@/http/toolBoxApi'
|
|
|
import { guid, getQueryString } from "@/uilts/help";
|
|
|
-import { onMounted, reactive, ref } from "vue";
|
|
|
+import { onMounted, reactive, ref, onBeforeUnmount } from "vue";
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
import { reSetBindTwtterId } from '@/http/help.js'
|
|
|
+import Report from "@/log-center/log"
|
|
|
+import "element-plus/es/components/message/style/css";
|
|
|
let dom_iframe = ref(null)
|
|
|
let state = reactive({
|
|
|
status: '', //
|
|
@@ -79,10 +93,13 @@ let state = reactive({
|
|
|
tweetId: '',
|
|
|
detail: {},
|
|
|
handle_type: '',
|
|
|
+ showMask: false,
|
|
|
cover_url: require('@/assets/img/back-loading.png')
|
|
|
})
|
|
|
|
|
|
let dom = {}
|
|
|
+let nftAuthINfo = ref(null)
|
|
|
+let loadTime = (new Date).getTime()
|
|
|
|
|
|
let props = defineProps({
|
|
|
pre_view: {
|
|
@@ -103,6 +120,10 @@ chrome.runtime.onMessage.addListener((req, sender, sendResponse) => {
|
|
|
state.show_btn = true
|
|
|
state.status = 'iframe'
|
|
|
state.iframe_url = req.data.iframe_url
|
|
|
+ nftAuthINfo.value = req.data.nftAuthINfo
|
|
|
+ state.showMask = req.data.showMask
|
|
|
+ state.detail = req.data.detail
|
|
|
+ state.postId = req.data.postId
|
|
|
}
|
|
|
break
|
|
|
}
|
|
@@ -139,6 +160,19 @@ onMounted(() => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ chrome.runtime.onMessage.addListener(msgListener)
|
|
|
+
|
|
|
+ // 页面返回重试状态
|
|
|
+ document.addEventListener('visibilitychange', function () {
|
|
|
+ let isHidden = document.hidden;
|
|
|
+ if (!isHidden && !nftAuthINfo.value) {
|
|
|
+ getDetail();
|
|
|
+ }
|
|
|
+ });
|
|
|
+})
|
|
|
+
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ chrome.runtime.onMessage.removeListener(msgListener);
|
|
|
})
|
|
|
|
|
|
// detail函数
|
|
@@ -148,6 +182,7 @@ const getDetail = () => {
|
|
|
state.status = '网页错误'
|
|
|
}
|
|
|
// iframe.onload = () => {
|
|
|
+ // alert(123)
|
|
|
// if (state.status == '加载' || state.status == 'iframe') {
|
|
|
// state.show_btn = true
|
|
|
// state.status = 'iframe'
|
|
@@ -172,29 +207,199 @@ const getDetail = () => {
|
|
|
if (state.detail.viewBgImagePath) {
|
|
|
state.cover_url = state.detail.viewBgImagePath
|
|
|
}
|
|
|
+ state.iframe_url = state.detail.convertUrl
|
|
|
state.show_btn = true
|
|
|
state.status = 'iframe'
|
|
|
- state.iframe_url = state.detail.convertUrl
|
|
|
+ // 蒙层
|
|
|
+ if (state.detail && state.detail.certNftProjectId) {
|
|
|
+ state.showMask = true;
|
|
|
+ // 确权
|
|
|
+ getChromeStorage('userInfo', (_userInfo) => {
|
|
|
+ if (_userInfo) {
|
|
|
+ getNftInfoStatus()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ reportSucc(false)
|
|
|
+ }
|
|
|
+ // report
|
|
|
+ Report.reportLog({
|
|
|
+ redPacketType: Report.redPacketType.postEditor,
|
|
|
+ businessType: Report.businessType.pageView,
|
|
|
+ pageSource: Report.pageSource.pe_loading_page,
|
|
|
+ postId: state.postId || '',
|
|
|
+ postEditorUrl: state.detail.convertUrl
|
|
|
+ });
|
|
|
} else {
|
|
|
state.status = '网页错误'
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+const getNftInfoStatus = () => {
|
|
|
+ getPostEditorNftCertInfo({
|
|
|
+ params: {
|
|
|
+ postId: state.postId,
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ let { code, data } = res;
|
|
|
+ if ( code === 0 ) {
|
|
|
+ nftAuthINfo.value = data;
|
|
|
+ // checkMask
|
|
|
+ getChromeStorage('post_id_list', (list) => {
|
|
|
+ if (list && list.indexOf(state.postId) !== -1 && nftAuthINfo.value?.certStatus === 1) {
|
|
|
+ state.showMask = false;
|
|
|
+ // report
|
|
|
+ reportSucc()
|
|
|
+ } else {
|
|
|
+ // report
|
|
|
+ reportFail()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const reportSucc = (isEncrypted = true) => {
|
|
|
+ let params = {}
|
|
|
+ if (isEncrypted) {
|
|
|
+ params['nft-encrypted-status'] = 1;
|
|
|
+ }
|
|
|
+ // report
|
|
|
+ Report.reportLog({
|
|
|
+ redPacketType: Report.redPacketType.postEditor,
|
|
|
+ businessType: Report.businessType.pageView,
|
|
|
+ pageSource: Report.pageSource.pe_display_page,
|
|
|
+ postId: state.postId || '',
|
|
|
+ postEditorUrl: state.detail.convertUrl,
|
|
|
+ ...params,
|
|
|
+ }, {
|
|
|
+ 'loading-time': (new Date).getTime() - loadTime,
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+const reportFail = () => {
|
|
|
+ Report.reportLog({
|
|
|
+ redPacketType: Report.redPacketType.postEditor,
|
|
|
+ businessType: Report.businessType.pageView,
|
|
|
+ pageSource: Report.pageSource.pe_display_page,
|
|
|
+ postId: state.postId || '',
|
|
|
+ postEditorUrl: state.detail.convertUrl,
|
|
|
+ 'nft-encrypted-status': 0,
|
|
|
+ }, {
|
|
|
+ 'loading-time': (new Date).getTime() - loadTime,
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+const confirmStatus = () => {
|
|
|
+ getChromeStorage('userInfo', (_userInfo) => {
|
|
|
+ if (!_userInfo) {
|
|
|
+ chrome.runtime.sendMessage(
|
|
|
+ { actionType: "POPUP_LOGIN", data: "" },
|
|
|
+ (response) => {
|
|
|
+ console.log("res", response);
|
|
|
+ }
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ if (nftAuthINfo.value && nftAuthINfo.value?.certStatus === 1) {
|
|
|
+ succBack()
|
|
|
+ } else {
|
|
|
+ sendChromeTabMessage({
|
|
|
+ actionType: 'Set_ToolBox_By_Nft',
|
|
|
+ data: {
|
|
|
+ postId: state.postId,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // report
|
|
|
+ let params = {}
|
|
|
+ if (nftAuthINfo.value?.certStatus === 1) {
|
|
|
+ if (state.showMask) {
|
|
|
+ params['nft-encrypted-status'] = 0
|
|
|
+ } else {
|
|
|
+ params['nft-encrypted-status'] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Report.reportLog({
|
|
|
+ redPacketType: Report.redPacketType.postEditor,
|
|
|
+ businessType: Report.businessType.buttonClick,
|
|
|
+ pageSource: Report.pageSource.pe_display_page,
|
|
|
+ objectType: Report.objectType.encrypte_nft_button,
|
|
|
+ postId: state.postId || '',
|
|
|
+ postEditorUrl: state.detail.convertUrl,
|
|
|
+ ...params,
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+const succBack = () => {
|
|
|
+ ElMessage({
|
|
|
+ message: `NFT validated!`,
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ state.showMask = false;
|
|
|
+ // 记录解锁
|
|
|
+ getChromeStorage('post_id_list', (list) => {
|
|
|
+ let originList = list ? list : [];
|
|
|
+ if (originList.indexOf(state.postId) === -1) {
|
|
|
+ originList.push(state.postId)
|
|
|
+ setChromeStorage({ post_id_list: JSON.stringify(originList) })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const hideMask = (data) => {
|
|
|
+ if (data && data.post_Id && data.post_Id === state.postId) {
|
|
|
+ succBack()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
const clickCancel = () => {
|
|
|
state.show_alert = false
|
|
|
}
|
|
|
|
|
|
const clickFixed = () => {
|
|
|
- state.handle_type = '固定右上角'
|
|
|
- getChromeStorage('fullCheck', (res) => {
|
|
|
- if (res && res.fullCheck) {
|
|
|
- // 固定
|
|
|
- handleFixed()
|
|
|
+ getChromeStorage('userInfo', (_userInfo) => {
|
|
|
+ if (!_userInfo) {
|
|
|
+ chrome.runtime.sendMessage(
|
|
|
+ { actionType: "POPUP_LOGIN", data: "" },
|
|
|
+ (response) => {
|
|
|
+ console.log("res", response);
|
|
|
+ }
|
|
|
+ )
|
|
|
} else {
|
|
|
- state.show_alert = true
|
|
|
+ state.handle_type = '固定右上角'
|
|
|
+ getChromeStorage('fullCheck', (res) => {
|
|
|
+ if (res && res.fullCheck) {
|
|
|
+ // 固定
|
|
|
+ handleFixed()
|
|
|
+ } else {
|
|
|
+ state.show_alert = true
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
+ // report
|
|
|
+ let params = {}
|
|
|
+ if (nftAuthINfo.value?.certStatus === 1) {
|
|
|
+ if (state.showMask) {
|
|
|
+ params['nft-encrypted-status'] = 0
|
|
|
+ } else {
|
|
|
+ params['nft-encrypted-status'] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Report.reportLog({
|
|
|
+ redPacketType: Report.redPacketType.postEditor,
|
|
|
+ businessType: Report.businessType.buttonClick,
|
|
|
+ pageSource: Report.pageSource.pe_display_page,
|
|
|
+ objectType: Report.objectType.top_right_button,
|
|
|
+ postId: state.postId || '',
|
|
|
+ postEditorUrl: state.detail.convertUrl,
|
|
|
+ ...params,
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
// 固定
|
|
@@ -202,19 +407,34 @@ const handleFull = () => {
|
|
|
if (state.status != 'iframe' || !state.iframe_url) {
|
|
|
return
|
|
|
}
|
|
|
- // 切换状态
|
|
|
- state.status = '固定右上角'
|
|
|
- state.show_btn = false
|
|
|
- sendChromeTabMessage({
|
|
|
- actionType: 'Set_ToolBox_Fixed',
|
|
|
- data: {
|
|
|
- type: '全屏',
|
|
|
- iframe_url: state.iframe_url,
|
|
|
- tweetId: state.tweetId,
|
|
|
+ getChromeStorage('userInfo', (_userInfo) => {
|
|
|
+ if (!_userInfo) {
|
|
|
+ chrome.runtime.sendMessage(
|
|
|
+ { actionType: "POPUP_LOGIN", data: "" },
|
|
|
+ (response) => {
|
|
|
+ console.log("res", response);
|
|
|
+ }
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ // 切换状态
|
|
|
+ state.status = '固定右上角'
|
|
|
+ state.show_btn = false
|
|
|
+ sendChromeTabMessage({
|
|
|
+ actionType: 'Set_ToolBox_Fixed',
|
|
|
+ data: {
|
|
|
+ type: '全屏',
|
|
|
+ iframe_url: state.iframe_url,
|
|
|
+ tweetId: state.tweetId,
|
|
|
+ nftAuthINfo: nftAuthINfo.value,
|
|
|
+ showMask: state.showMask,
|
|
|
+ detail: state.detail,
|
|
|
+ postId: state.postId,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 清除当前iframe src
|
|
|
+ state.iframe_url = ''
|
|
|
}
|
|
|
})
|
|
|
- // 清除当前iframe src
|
|
|
- state.iframe_url = ''
|
|
|
}
|
|
|
|
|
|
// 全屏
|
|
@@ -227,7 +447,11 @@ const handleFixed = () => {
|
|
|
data: {
|
|
|
type: '固定右上角',
|
|
|
iframe_url: state.iframe_url,
|
|
|
- tweetId: state.tweetId
|
|
|
+ tweetId: state.tweetId,
|
|
|
+ nftAuthINfo: nftAuthINfo.value,
|
|
|
+ showMask: state.showMask,
|
|
|
+ detail: state.detail,
|
|
|
+ postId: state.postId,
|
|
|
}
|
|
|
})
|
|
|
// 清除当前iframe src
|
|
@@ -244,6 +468,35 @@ const clickFull = () => {
|
|
|
state.show_alert = true
|
|
|
}
|
|
|
})
|
|
|
+ // report
|
|
|
+ let params = {}
|
|
|
+ if (nftAuthINfo.value?.certStatus === 1) {
|
|
|
+ if (state.showMask) {
|
|
|
+ params['nft-encrypted-status'] = 0
|
|
|
+ } else {
|
|
|
+ params['nft-encrypted-status'] = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Report.reportLog({
|
|
|
+ redPacketType: Report.redPacketType.postEditor,
|
|
|
+ businessType: Report.businessType.buttonClick,
|
|
|
+ pageSource: Report.pageSource.pe_display_page,
|
|
|
+ objectType: Report.objectType.fullscreen_button,
|
|
|
+ postId: state.postId || '',
|
|
|
+ postEditorUrl: state.detail.convertUrl,
|
|
|
+ ...params,
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+const msgListener = (req, sender, sendResponse) => {
|
|
|
+ switch (req.actionType) {
|
|
|
+ case 'BG_LOGIN_SET_USERINFO_CB':
|
|
|
+ getDetail()
|
|
|
+ break;
|
|
|
+ case 'FINISH_ToolBox_By_Nft':
|
|
|
+ hideMask(req.data)
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
</script>
|
|
@@ -266,6 +519,7 @@ const clickFull = () => {
|
|
|
.alert {
|
|
|
text-align: center;
|
|
|
position: absolute;
|
|
|
+ z-index: 3;
|
|
|
top: 0;
|
|
|
left: 0;
|
|
|
width: 100%;
|
|
@@ -390,6 +644,7 @@ const clickFull = () => {
|
|
|
}
|
|
|
|
|
|
.content {
|
|
|
+ position: relative;
|
|
|
width: 100%;
|
|
|
height: calc(100% - 40px);
|
|
|
background: #686868;
|
|
@@ -397,6 +652,56 @@ const clickFull = () => {
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
|
|
|
+ .mask {
|
|
|
+ position: absolute;
|
|
|
+ z-index: 2;
|
|
|
+ display: flex;
|
|
|
+ cursor: pointer;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ flex-direction: column;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-color: rgba($color: #000000, $alpha: .8);
|
|
|
+ .luck {
|
|
|
+ width: 100px;
|
|
|
+ height: 100px;
|
|
|
+ }
|
|
|
+ .btn {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ width: 345px;
|
|
|
+ height: 70px;
|
|
|
+ margin-top: 12px;
|
|
|
+ border-radius: 100px;
|
|
|
+ background: #1D9BF0;
|
|
|
+ .img {
|
|
|
+ overflow: hidden;
|
|
|
+ width: 35px;
|
|
|
+ height: 35px;
|
|
|
+ margin-right: 16px;
|
|
|
+ border-radius: 4px;
|
|
|
+ }
|
|
|
+ .font {
|
|
|
+ width: 188px;
|
|
|
+ color: #fff;
|
|
|
+ font-weight: 700;
|
|
|
+ font-size: 16px;
|
|
|
+ line-height: 19px;
|
|
|
+ letter-spacing: 0.3px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .mask_bg {
|
|
|
+ position: absolute;
|
|
|
+ z-index: 1;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ object-fit: contain;
|
|
|
+ background-color: #000000;
|
|
|
+ }
|
|
|
+
|
|
|
iframe {
|
|
|
background: #fff;
|
|
|
width: 100%;
|