系統監控當前路由如相同仍觸發 iframe 重新載入 | scrollbar寬度none

This commit is contained in:
huliang 2025-07-08 18:01:39 +08:00
parent 153015e996
commit b81d231caf
3 changed files with 53 additions and 3 deletions

View File

@ -29,10 +29,30 @@ const filteredItems = computed(() => {
const handleClick = (ord) => { const handleClick = (ord) => {
if (ord) { if (ord) {
router.push({ const targetRoute = {
name: "baja", name: "baja",
query: { pagename: "system", ord: encodeURIComponent(ord) }, query: { pagename: "system", ord: encodeURIComponent(ord) },
}); };
//
if (
router.currentRoute.value.query.ord === targetRoute.query.ord
) {
// iframe
router.push({
name: "baja",
query: {
...targetRoute.query,
_t: new Date().getTime(),
},
});
} else {
router.push(targetRoute);
}
//
if (props.toggleSidebar) {
props.toggleSidebar();
}
} }
}; };

View File

@ -4,6 +4,22 @@
serif; serif;
} }
/* Webkit 瀏覽器 (Chrome, Safari, Edge) */
::-webkit-scrollbar {
width: 0px;
background: transparent;
}
/* Firefox */
* {
scrollbar-width: none;
}
/* IE 和舊版 Edge */
* {
-ms-overflow-style: none;
}
a { a {
color: #69b0cf; color: #69b0cf;
} }

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed, onMounted, onUnmounted } from "vue"; import { ref, computed, onMounted, onUnmounted, watch } from "vue";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { nextTick } from "vue"; // iframe import { nextTick } from "vue"; // iframe
@ -7,6 +7,7 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const iframeRef = ref(null); const iframeRef = ref(null);
const loading = ref(true); const loading = ref(true);
const iframeKey = ref(0); // iframe
const ordUrl = computed(() => { const ordUrl = computed(() => {
const ord = route.query.ord || ""; const ord = route.query.ord || "";
@ -31,6 +32,18 @@ const iframeSrc = computed(() => {
} }
}); });
// _t
watch(
() => route.query._t,
(newTimestamp) => {
if (newTimestamp) {
// iframe
iframeKey.value++;
loading.value = true;
}
}
);
const iframeLoad = () => { const iframeLoad = () => {
console.log("iframe loaded!"); console.log("iframe loaded!");
// const iframeDocument = // const iframeDocument =
@ -63,6 +76,7 @@ onMounted(async () => {
<iframe <iframe
v-if="iframeSrc" v-if="iframeSrc"
ref="iframeRef" ref="iframeRef"
:key="iframeKey"
:src="iframeSrc" :src="iframeSrc"
width="100%" width="100%"
:style="{ height: 'calc(100vh - 90px)' }" :style="{ height: 'calc(100vh - 90px)' }"