Skip to content

Commit dc8c7e5

Browse files
committed
fix white-screen error
1 parent 4171185 commit dc8c7e5

3 files changed

Lines changed: 40 additions & 12 deletions

File tree

src/App.vue

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ import Msg from "./components/popup/msg.vue";
2828
import showUserCard from "./popup/usercard.ts";
2929
import Notification from "./components/popup/notification.vue";
3030
import Emitter from "./services/eventEmitter";
31-
import isUnsupportedBrowser from "./services/browser";
31+
// import isUnsupportedBrowser from "./services/browser";
3232
33-
try {
34-
if (isUnsupportedBrowser()) {
35-
alert(
36-
"Your browser is not supported. Please switch to a mainstream browser like Chrome, Firefox, Edge, or Safari for a better experience.你的浏览器不被支持,请更换为主流浏览器(如 Chrome、Firefox、Edge 或 Safari)以获得更好的体验。",
37-
);
38-
}
39-
} catch (e) {
40-
// ignore detection errors
41-
}
33+
// try {
34+
// if (isUnsupportedBrowser()) {
35+
// alert(
36+
// "Your browser is not supported. Please switch to a mainstream browser like Chrome, Firefox, Edge, or Safari for a better experience.你的浏览器不被支持,请更换为主流浏览器(如 Chrome、Firefox、Edge 或 Safari)以获得更好的体验。",
37+
// );
38+
// }
39+
// } catch (e) {
40+
// // ignore detection errors
41+
// }
4242
4343
function handleClick(event: MouseEvent) {
4444
const target = event.target as HTMLElement;
@@ -69,6 +69,11 @@ setTimeout(async () => {
6969
body {
7070
margin: 0;
7171
}
72+
/* # Ensure html/body have deterministic heights and provide a vh fallback for #app. */ */
73+
html,
74+
body {
75+
height: 100%;
76+
}
7277
7378
#app {
7479
font-family: Avenir, Helvetica, Arial, sans-serif;
@@ -79,5 +84,7 @@ body {
7984
width: 100vw;
8085
background-color: white;
8186
overscroll-behavior: none;
87+
/* fallback to ensure non-zero height when viewport-unit quirks occur */
88+
min-height: 100vh;
8289
}
8390
</style>

src/layout/Adaptation.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ defineComponent({
2525
<style scoped>
2626
.basic-layout {
2727
position: relative;
28+
/* prefer dynamic viewport height but provide fallbacks to avoid 0 on some browsers */
2829
height: 100dvh;
30+
/* use JS-driven --vh when available (better on mobile), then fallback to 100vh */
31+
min-height: calc(var(--vh, 1vh) * 100);
2932
width: 100vw;
3033
overflow: hidden;
3134
overflow-x: hidden;
@@ -47,7 +50,9 @@ defineComponent({
4750
top: var(--left-height);
4851
left: 0;
4952
width: 100vw;
53+
/* keep dVh when available but fallback to calc(var(--vh)) and then standard vh */
5054
height: calc(100dvh - var(--left-height));
55+
min-height: calc((var(--vh, 1vh) * 100) - var(--left-height));
5156
}
5257
5358
.scroll-container {
@@ -78,14 +83,16 @@ defineComponent({
7883
@media (min-aspect-ratio: 1/1) {
7984
.layout-left {
8085
width: 50vw;
81-
height: 100dvh;
86+
height: 100dvh;
87+
min-height: calc(var(--vh, 1vh) * 100);
8288
}
8389
8490
.layout-right {
8591
top: 0;
8692
left: 50vw;
8793
width: 50vw;
88-
height: 100dvh;
94+
height: 100dvh;
95+
min-height: calc(var(--vh, 1vh) * 100);
8996
}
9097
9198
.scroll-container {

src/main.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,18 @@ window.$Logger = LogManager;
4444
window.$getPath = getPath;
4545
const errorLogger = new ErrorLogger(app);
4646
window.$ErrorLogger = errorLogger;
47+
// mobile/embedded browser viewport-vh fix:
48+
// set a CSS variable --vh to 1% of the innerHeight and update on resize.
49+
// Use this in CSS as: height: calc(var(--vh) * 100);
50+
function setVh() {
51+
try {
52+
const vh = window.innerHeight * 0.01;
53+
document.documentElement.style.setProperty("--vh", `${vh}px`);
54+
} catch (e) {
55+
// ignore
56+
}
57+
}
58+
setVh();
59+
window.addEventListener("resize", setVh);
60+
4761
app.mount("#app");

0 commit comments

Comments
 (0)