系統監控當前路由如相同仍觸發 iframe 重新載入 | scrollbar寬度none
This commit is contained in:
parent
153015e996
commit
b81d231caf
@ -29,10 +29,30 @@ const filteredItems = computed(() => {
|
||||
|
||||
const handleClick = (ord) => {
|
||||
if (ord) {
|
||||
router.push({
|
||||
const targetRoute = {
|
||||
name: "baja",
|
||||
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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,22 @@
|
||||
serif;
|
||||
}
|
||||
|
||||
/* Webkit 瀏覽器 (Chrome, Safari, Edge) */
|
||||
::-webkit-scrollbar {
|
||||
width: 0px;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
/* Firefox */
|
||||
* {
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
/* IE 和舊版 Edge */
|
||||
* {
|
||||
-ms-overflow-style: none;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #69b0cf;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onUnmounted } from "vue";
|
||||
import { ref, computed, onMounted, onUnmounted, watch } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { nextTick } from "vue"; // 確保 iframe 渲染完成
|
||||
|
||||
@ -7,6 +7,7 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const iframeRef = ref(null);
|
||||
const loading = ref(true);
|
||||
const iframeKey = ref(0); // 用於強制 iframe 重新渲染
|
||||
|
||||
const ordUrl = computed(() => {
|
||||
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 = () => {
|
||||
console.log("iframe loaded!");
|
||||
// const iframeDocument =
|
||||
@ -63,6 +76,7 @@ onMounted(async () => {
|
||||
<iframe
|
||||
v-if="iframeSrc"
|
||||
ref="iframeRef"
|
||||
:key="iframeKey"
|
||||
:src="iframeSrc"
|
||||
width="100%"
|
||||
:style="{ height: 'calc(100vh - 90px)' }"
|
||||
|
Loading…
Reference in New Issue
Block a user