Browse Source

[bug][点击全屏]

zhangwei 2 năm trước cách đây
mục cha
commit
02b14d411f

+ 73 - 0
src/view/components/icon-svg.vue

@@ -0,0 +1,73 @@
+<template>
+    <!-- 固定 -->
+    <template v-if="icon == '固定'">
+        <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" :class="class"
+            @click.stop="clickStop">
+            <mask id="path-1-inside-1_22849_40056" fill="white">
+                <rect x="1" y="2" width="18" height="16" rx="1" />
+            </mask>
+            <rect x="1" y="2" width="18" height="16" rx="1" fill="#D9D9D9" fill-opacity="0.01" stroke="white"
+                stroke-width="3" mask="url(#path-1-inside-1_22849_40056)" />
+            <rect x="9" y="5" width="7" height="5" fill="white" />
+        </svg>
+    </template>
+
+    <!-- 放大 -->
+    <template v-if="icon == '放大'">
+        <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" :class="class"
+            @click.stop="clickStop">
+            <path
+                d="M11.3054 3.39557H15.4646L11.8944 6.8807L11.8944 6.88068L11.8923 6.88281C11.7377 7.03738 11.6759 7.2515 11.6759 7.45338C11.6759 7.65758 11.7381 7.87294 11.8611 8.05744L11.8888 8.09904L11.9304 8.12678C12.1149 8.24978 12.3303 8.31196 12.5345 8.31196C12.7363 8.31196 12.9505 8.25011 13.105 8.09554L16.5923 4.6083V8.77794C16.5923 9.00244 16.702 9.20602 16.8445 9.34851C16.987 9.49099 17.1905 9.60072 17.4151 9.60072C17.6396 9.60072 17.8431 9.49099 17.9856 9.34851C18.1281 9.20602 18.2378 9.00244 18.2378 8.77794V3.5396C18.2871 3.02389 18.1855 2.58065 17.9514 2.25868C17.7118 1.92926 17.3491 1.75 16.9377 1.75H11.3054C11.0809 1.75 10.8773 1.85973 10.7348 2.00222C10.5923 2.1447 10.4826 2.34828 10.4826 2.57278C10.4826 2.79729 10.5923 3.00087 10.7348 3.14335C10.8773 3.28583 11.0809 3.39557 11.3054 3.39557ZM9.77794 15.6877H5.6083L9.09554 12.2005C9.2485 12.0475 9.31196 11.8347 9.31196 11.6419C9.31196 11.4566 9.25337 11.2528 9.11311 11.1015C8.97067 10.9011 8.75564 10.7952 8.52497 10.7952C8.29228 10.7952 8.06427 10.9018 7.88281 11.0832L4.39557 14.5705V10.019C4.39557 9.79447 4.28583 9.59089 4.14335 9.44841C4.00087 9.30592 3.79729 9.19619 3.57278 9.19619C3.34828 9.19619 3.1447 9.30592 3.00222 9.44841C2.85973 9.59089 2.75 9.79447 2.75 10.019V15.4604C2.75 15.8987 2.91219 16.3805 3.19379 16.756C3.47667 17.1332 3.90175 17.4288 4.43196 17.4288H9.77794C10.0024 17.4288 10.206 17.319 10.3485 17.1765C10.491 17.0341 10.6007 16.8305 10.6007 16.606C10.6007 16.1115 10.2265 15.6877 9.77794 15.6877Z"
+                fill="white" stroke="white" stroke-width="0.5" />
+        </svg>
+    </template>
+
+    <!-- 缩小 -->
+    <svg v-if="icon == '缩小'" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"
+        :class="class" @click.stop="clickStop">
+        <g clip-path="url(#clip0_22829_232305)">
+            <path
+                d="M2.57362 11.9381H6.74327L3.25602 15.4254C3.10307 15.5783 3.0396 15.7912 3.0396 15.984C3.0396 16.1693 3.09819 16.373 3.23846 16.5244C3.38089 16.7248 3.59592 16.8307 3.82659 16.8307C4.05929 16.8307 4.28729 16.7241 4.46875 16.5426L7.956 13.0554V17.6069C7.956 17.8314 8.06573 18.035 8.20821 18.1775C8.3507 18.32 8.55428 18.4297 8.77878 18.4297C9.00328 18.4297 9.20686 18.32 9.34934 18.1775C9.49183 18.035 9.60156 17.8314 9.60156 17.6069V12.1655C9.60156 11.7271 9.43937 11.2454 9.15777 10.8699C8.87489 10.4927 8.44981 10.1971 7.9196 10.1971H2.57362C2.34912 10.1971 2.14554 10.3068 2.00306 10.4493C1.86057 10.5918 1.75084 10.7954 1.75084 11.0199C1.75084 11.5144 2.12504 11.9381 2.57362 11.9381Z"
+                fill="white" stroke="white" stroke-width="0.5" />
+            <path
+                d="M16.6276 2.25602L13.1403 5.74327V1.57362C13.1403 1.34912 13.0306 1.14554 12.8881 1.00306C12.7456 0.860574 12.542 0.750839 12.3175 0.750839C12.093 0.750839 11.8894 0.860574 11.747 1.00306C11.6045 1.14554 11.4947 1.34912 11.4947 1.57362V6.81196C11.4455 7.32767 11.5471 7.77091 11.7812 8.09288C12.0208 8.4223 12.3835 8.60156 12.7948 8.60156H18.4272C18.6517 8.60156 18.8553 8.49183 18.9978 8.34934C19.1403 8.20686 19.25 8.00328 19.25 7.77878C19.25 7.55427 19.1403 7.3507 18.9978 7.20821C18.8553 7.06573 18.6517 6.956 18.4272 6.956H14.268L17.8381 3.47087L17.8382 3.47088L17.8403 3.46875C17.9949 3.31418 18.0567 3.10006 18.0567 2.89818C18.0567 2.69398 17.9945 2.47862 17.8715 2.29412L17.8438 2.25252L17.8022 2.22479C17.6177 2.10179 17.4023 2.0396 17.1981 2.0396C16.9962 2.0396 16.7821 2.10145 16.6276 2.25602Z"
+                fill="white" stroke="white" stroke-width="0.5" />
+        </g>
+        <defs>
+            <clipPath id="clip0_22829_232305">
+                <rect width="18" height="18" fill="white" transform="translate(1 1)" />
+            </clipPath>
+        </defs>
+    </svg>
+
+    <!-- 关闭 -->
+    <svg v-if="icon == '关闭'" width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"
+        :class="class" @click.stop="clickStop">
+        <line y1="-1" x2="16.7592" y2="-1" transform="matrix(-0.698077 0.716023 -0.698077 -0.716023 15.1914 4)"
+            stroke="white" stroke-width="2" />
+        <line y1="-1" x2="16.7592" y2="-1" transform="matrix(0.698077 0.716022 0.698077 -0.716022 4.79297 4)"
+            stroke="white" stroke-width="2" />
+    </svg>
+
+
+</template>
+<script setup>
+import { defineProps, defineEmits } from 'vue'
+const emits = defineEmits("back");
+let props = defineProps({
+    icon: {
+        type: String,
+        default: ''
+    },
+    class: {
+        type: String,
+        default: ''
+    }
+})
+const clickStop = () => {
+    emits("clickStop");
+}
+
+</script>
+<style>
+</style>

+ 20 - 4
src/view/content/tool-box/full.vue

@@ -3,10 +3,12 @@
         <div class="head">
             <span></span>
             <div>
-                <!-- 缩放 -->
-                <img :src="require('@/assets/img/icon-full.png')" alt class="fixed" @click="clickFull" />
+                <!-- 缩小 -->
+                <icon-svg v-if="state.status == '全屏'" :icon="'缩小'" @clickStop="clickFull" :class="'full'"></icon-svg>
+                <icon-svg v-else :icon="'放大'" @clickStop="clickFull" :class="'full'"></icon-svg>
+
                 <!-- 关闭 -->
-                <img :src="require('@/assets/img/icon-close.png')" alt class="full" @click="clickClose" />
+                <icon-svg :icon="'关闭'" @clickStop="clickClose" :class="'fixed'"></icon-svg>
             </div>
         </div>
         <div class="content">
@@ -18,6 +20,7 @@
 import { onMounted, reactive, ref } from "vue";
 import { sendEventInfo } from "@/uilts/event";
 import { $ } from "@/uilts/help";
+import IconSvg from '@/view/components/icon-svg.vue'
 
 let state = reactive({
     status: '固定', // 全屏
@@ -38,6 +41,14 @@ window.addEventListener("onEvent", e => {
             state.iframe_url = info.data.iframe_url
             state.tweetId = info.data.tweetId
             break
+        case 'ToolBox_To_Full':
+            if (state.iframe_url || state.tweetId) {
+                sendClose()
+            }
+            state.status = '全屏'
+            state.iframe_url = info.data.iframe_url
+            state.tweetId = info.data.tweetId
+            break
     }
 });
 
@@ -119,7 +130,12 @@ const sendClose = () => {
             margin-left: 16px;
         }
 
-        img {
+        div {
+            display: flex;
+            justify-content: center;
+        }
+
+        svg {
             width: 20px;
             height: 20px;
             cursor: pointer;

+ 14 - 7
src/view/content/tool-box/index.vue

@@ -3,15 +3,16 @@
         <div class="head" @click.stop="clickHead">
             <span></span>
             <div v-show="state.show_btn && state.status == ''">
-                <img :src="require('@/assets/img/icon-fixed.png')" alt class="fixed" @click.stop="clickFixed" />
-                <img :src="require('@/assets/img/icon-full.png')" alt class="full" @click.stop="clickFull" />
+                <icon-svg :icon="'固定'" @clickStop="clickFixed" :class="'fixed'"></icon-svg>
+                <icon-svg :icon="'放大'" @clickStop="clickFull" :class="'full'"></icon-svg>
             </div>
         </div>
         <div class="content" v-if="pre_view">
             <iframe :src="iframe_url" frameborder="0"></iframe>
         </div>
         <div class="content" v-else>
-            <iframe :src="state.iframe_url" v-show="state.status == ''" ref="dom_iframe" frameborder="0" allow="camera *;microphone *"></iframe>
+            <iframe :src="state.iframe_url" v-show="state.status == ''" ref="dom_iframe" frameborder="0"
+                allow="camera *;microphone *"></iframe>
             <!-- 网页错误 -->
             <div class="state" v-show="state.status == '网页错误'">
                 <img :src="require('@/assets/img/icon-page-fail.png')" alt />
@@ -57,6 +58,7 @@ import { guid } from "@/uilts/help";
 import { sendEventInfo } from "@/uilts/event";
 import { onMounted, reactive, ref } from "vue";
 import { $ } from "@/uilts/help";
+import IconSvg from '@/view/components/icon-svg.vue'
 let dom_toolbox = ref(null)
 let dom_iframe = ref(null)
 let state = reactive({
@@ -132,7 +134,7 @@ onMounted(() => {
                 return
             }
         }
-    }catch(error){
+    } catch (error) {
         console.log(error)
     }
     getDetail()
@@ -206,10 +208,10 @@ const handleFull = () => {
     dom.fixed.dataset.tweetId = state.tweetId
     state.show_btn = false
     sendEventInfo({
-        event_type: 'ToolBox_To_Fixed',
+        event_type: 'ToolBox_To_Full',
         data: {
             iframe_url: state.iframe_url,
-            tweetId: state.tweetId
+            tweetId: state.tweetId,
         }
     })
     // 清除当前iframe src
@@ -366,6 +368,11 @@ const clickFull = () => {
         align-items: center;
         justify-content: space-between;
 
+        div {
+            display: flex;
+            justify-content: center;
+        }
+
         span {
             color: #FFFFFF;
             font-style: normal;
@@ -374,7 +381,7 @@ const clickFull = () => {
             margin-left: 16px;
         }
 
-        img {
+        svg {
             width: 20px;
             height: 20px;
             cursor: pointer;

+ 14 - 248
src/view/iframe/test/index.vue

@@ -1,265 +1,31 @@
 <template>
-    <div class="denet-toolbox" @click.stop="clickHead">
-        <div class="head" @click.stop="clickHead">
-            <span></span>
-            <div>
-                <img :src="require('@/assets/img/icon-fixed.png')" alt class="fixed" @click.stop="clickFixed" />
-                <img :src="require('@/assets/img/icon-full.png')" alt class="full" @click.stop="clickFull" />
-                <!-- <img :src="require('@/assets/img/icon-close.png')" alt class="full" @click="clickFull" /> -->
-            </div>
-        </div>
-        <div class="content">
-            <iframe src="https://www.bilibili.com" v-show="state.status == ''" frameborder="0"></iframe>
-            <!-- 网页错误 -->
-            <div class="state" v-show="state.status == '网页错误'">
-                <img :src="require('@/assets/img/icon-page-fail.png')" alt />
-                <div>Oops, this link is invalid</div>
-            </div>
+    <!-- <div class="denet-toolbox" @click.stop="clickHead">
+        
+    </div> -->
+    <input type="button" value="点击" @click="state.show = !state.show">
+    <p v-if="state.show" :data-view="1" :data-click="'按钮'" @click.stop="clickTest">1</p>
+    <p v-else :data-view="2">2</p>
 
-            <!-- 加载 -->
-            <div class="state" v-show="state.status == '加载'">
-                <img :src="require('@/assets/img/icon-loading-gray.png')" alt />
-            </div>
-
-            <!-- 关闭 -->
-            <div class="state" v-show="state.status == '关闭'">
-
-            </div>
-            <!-- 固定右上角 -->
-            <div class="state" v-show="state.status == '固定右上角'">
-                <img :src="require('@/assets/img/icon-page-fail.png')" alt />
-                <div>Pinned to the top right</div>
-            </div>
-        </div>
-        <!-- alert -->
-        <div class="alert" v-show="state.show_alert">
-            <div class="back" @click.stop="clickCancel"></div>
-            <div class="confirm">
-                <div class="check">
-                    <input :id="state.checkbox_id" type='checkbox' v-model="state.checkbox" />
-                    <label :for="state.checkbox_id">Don't remind</label>
-                </div>
-
-                <div class="title">Web Page Progress May Reset</div>
-                <div class="handle">
-                    <div class="cancel" @click.stop="clickCancel">Cancel</div>
-                    <div class="continue" @click.stop="clickContinue">Continue</div>
-                </div>
-            </div>
-        </div>
-    </div>
 </template>
 <script setup>
-import { getChromeStorage, setChromeStorage, httpContentToBack } from "@/uilts/chromeExtension";
-import { guid } from "@/uilts/help";
 import { onMounted, reactive } from "vue";
 
 let state = reactive({
-    status: '', //
-    show_alert: false,
-    list: [],
-    checkbox: false,
-    checkbox_id: `denet-${guid()}`
+    show: false
 })
 onMounted(() => {
-   
-})
-
-const clickHead = () => {
-    // 
-}
-
-const clickContinue = () => {
-    if (state.checkbox) {
-        setChromeStorage({ fullCheck: JSON.stringify({ fullCheck: 1 }) })
-        // 全屏
-    }
-}
-
-const clickCancel = () => {
-    state.show_alert = false
-}
+    var io = new IntersectionObserver((e) => {
+        console.log(e[0].target)
+    });
+    io.observe(document.querySelector('p[data-view]'))
 
-const clickFixed = () => {
-    getChromeStorage('fullCheck', (res) => {
-        if (res && res.fullCheck) {
-            // 固定
-
-        } else {
-            state.show_alert = true
-        }
-    })
-}
-
-const clickFull = () => {
-    getChromeStorage('fullCheck', (res) => {
-        if (res && res.fullCheck) {
-            // 全屏
+})
 
-        } else {
-            state.show_alert = true
-        }
-    })
+function clickTest() {
+    console.log('clickTest')
 }
 
-
 </script>
 
 <style lang="scss">
-.denet-toolbox {
-    width: 505px;
-    height: 544px;
-    filter: drop-shadow(0px 4px 20px rgba(0, 0, 0, 0.2));
-    border-radius: 12px;
-    overflow: hidden;
-    position: relative;
-
-    .alert {
-        text-align: center;
-        position: absolute;
-        top: 0;
-        left: 0;
-        width: 100%;
-        height: 100%;
-
-        .back {
-            background: #000000;
-            opacity: 0.8;
-            position: absolute;
-            top: 0;
-            left: 0;
-            width: 100%;
-            height: 100%;
-            cursor: auto;
-        }
-
-        .confirm {
-            position: absolute;
-            width: 355px;
-            height: 180px;
-            background: #FFFFFF;
-            border-radius: 20px;
-            top: 173px;
-            left: 50%;
-            margin-left: -180px;
-
-            .title {
-                font-weight: 600;
-                font-size: 18px;
-                color: #000000;
-                margin-bottom: 34px;
-            }
-
-            .check {
-                color: #899099;
-                font-weight: 400;
-                font-size: 14px;
-                margin: 12px 15px 32px 0;
-                text-align: right;
-                align-content: center;
-                justify-content: flex-end;
-                display: flex;
-                line-height: 17px;
-
-                input {
-                    margin-right: 8px;
-                }
-
-                label {
-                    line-height: 19px;
-                }
-
-            }
-
-            .handle {
-                display: flex;
-                justify-content: center;
-                align-items: center;
-
-                div {
-                    font-weight: 600;
-                    font-size: 16px;
-                    width: 156px;
-                    height: 47px;
-                    line-height: 47px;
-                    cursor: pointer;
-                    border-radius: 1000px;
-                    user-select: none;
-                }
-
-                .cancel {
-                    color: #000000;
-                    background: rgba(56, 154, 255, 0.01);
-                    border: 1px solid #E6E6E6;
-                }
-
-                .continue {
-                    background: #1D9BF0;
-                    font-weight: 600;
-                    margin-left: 11px;
-                    color: #FFFFFF;
-                }
-            }
-        }
-    }
-
-    .head {
-        width: 100%;
-        height: 40px;
-        background: #373737;
-        display: flex;
-        align-items: center;
-        justify-content: space-between;
-
-        span {
-            color: #FFFFFF;
-            font-style: normal;
-            font-weight: 500;
-            font-size: 14px;
-            margin-left: 16px;
-        }
-
-        img {
-            width: 20px;
-            height: 20px;
-            cursor: pointer;
-
-        }
-
-        .full {
-            margin-right: 16px;
-        }
-
-        .fixed {
-            margin-right: 20px;
-        }
-    }
-
-    .content {
-        width: 100%;
-        height: calc(100% - 40px);
-        background: #686868;
-        display: flex;
-        align-items: center;
-        justify-content: center;
-
-        iframe {
-            width: 100%;
-            height: 100%;
-        }
-
-        .state {
-            img {
-                margin-bottom: 14px;
-            }
-
-            div {
-                color: #8E8E8E;
-                text-align: center;
-                font-weight: 500;
-                font-size: 22px;
-            }
-        }
-    }
-}
 </style>