forked from OpenWebGAL/WebGAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
181 lines (179 loc) · 6.52 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>WebGAL NG</title>
</head>
<body>
<!--快速显示落地页,让用户感知不到加载的过程-->
<div id="Title_enter_page" onclick="enter()" style="
width: 1600px;
height: 900px;
overflow: hidden;
position: absolute;
top: 0;
z-index: 14;
opacity: 1;
transition: opacity 1.5s;
">
<!-- 落地页背景-->
<div id="Title_bg_container" style="
height: 100%;
width: 100%;
position: absolute;
background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
top: 0;
opacity: 1;
transition: opacity 1s;
"></div>
<!-- 点击后的白色渐变-->
<div id="Title_white_container" style="
width: 100%;
height: 100%;
position: absolute;
top: 0;
opacity: 0;
background: linear-gradient(165deg,rgba(255,255,255,0.25) 0%,rgba(255,255,255,1) 50%,rgba(255,255,255,0.25) 100%);
transition: opacity 1s;
"></div>
<!-- 落地页文字-->
<div id="Title_enter_text" style="width: 100%;
position: absolute;
top: 0;
height: 100%;
opacity: 1;
transition: opacity 1s;
z-index: 15;
font-family: '思源宋体',Georgia,serif">
<div class="toCenter" style="
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
">
<div class="StartButton" style="font-size: xx-large;
letter-spacing: 0.25em ;
padding: 2em 2em 2em 2em;
text-shadow: 0 0 30px rgba(0,0,0,0.5);
transition: text-shadow 1s;
">
PRESS THE SCREEN TO START
</div>
</div>
<div
style="position: absolute;
bottom: 1em;
display: flex;
justify-content: center;
width: 100%;
flex-flow: column;
align-items: center ">
<div style="padding: 0 0 0.25em 0">
Powered by <a href="https://github.com/MakinoharaShoko/WebGAL" onclick="jump('https://github.com/MakinoharaShoko/WebGAL')">WebGAL</a> Framework
</div>
<div>
Made with ❤ by <a href="https://github.com/MakinoharaShoko" onclick="jump('https://github.com/MakinoharaShoko')">Mahiru</a>
</div>
</div>
</div>
</div>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
let enterPromise=new Promise(res=>window.enterPromise=res)
let renderPromise=new Promise(res=>window.renderPromise=res)
/**
* 将播放bgm的事件发送出去
*/
Promise.all([enterPromise,renderPromise])
.then(()=>{
const event = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true,
});
const target = document.getElementById('play_title_bgm_target');
if (target !== null) {
target.dispatchEvent(event);
}
})
// 激活强制缩放
// 在调整窗口大小时重新计算宽高,设计稿按照 1600*900。
setTimeout(resizeTitle, 100);
resizeTitle();
//判断是跳转操作还是enter操作
let tryToEnter=true;
window.onresize = resizeTitle;
// 监听键盘 F11 事件,全屏时触发页面调整
document.onkeydown = function (event) {
const e = event;
if (e && e.keyCode === 122) {
setTimeout(() => {
resizeTitle();
}, 100);
}
};
function jump(url){
tryToEnter=false;
window.location=url;
}
/**
* 点击屏幕,进入引擎主界面
*/
function enter() {
if(!tryToEnter) return;
document.getElementById('Title_bg_container').style.opacity = '0'; // 调整标题背景的透明度
document.getElementById('Title_enter_text').style.opacity = '0'; // 调整标题文字的透明度
setTimeout(() => document.getElementById('Title_white_container').style.opacity = '1', 50); // 在50ms后开始显示白色渐变
const title = document.getElementById('Title_enter_page');
setTimeout(() => title.style.opacity = '0', 500); //500ms后开始降低落地页透明度
title.style.pointerEvents = 'none'; //落地页不再响应点击
title.style.background = 'linear-gradient( #a1c4fd 0%, #c2e9fb 100%)'; //改变标题渐变效果
setTimeout(() => title.style.display = 'none', 2000) // 将落地页设置为不显示
window.enterPromise()
delete window.enterPromise
}
/**
* 对标题页进行自动强制缩放
*/
function resizeTitle() {
const targetHeight = 900;
const targetWidth = 1600;
const h = window.innerHeight; // 窗口高度
const w = window.innerWidth; // 窗口宽度
const zoomH = h / targetHeight; // 以窗口高度为基准的变换比
const zoomW = w / targetWidth; // 以窗口宽度为基准的变换比
const zoomH2 = w / targetHeight; // 竖屏时以窗口高度为基础的变换比
const zoomW2 = h / targetWidth; // 竖屏时以窗口宽度为基础的变换比
let mh = (targetHeight - h) / 2; // y轴移动距离
let mw = (targetWidth - w) / 2; // x轴移动距离
let mh2os = targetWidth / 2 - w / 2; // 竖屏时 y轴移动距离
let mw2os = targetHeight / 2 - h / 2; // 竖屏时 x轴移动距离
const root = document.getElementById('Title_enter_page'); // 获取根元素
if (root) {
if (w > h) {
mw = -mw;
mh = -mh;
if (w * (9 / 16) >= h) {
root.style.transform = `translate(${mw}px, ${mh}px) scale(${zoomH},${zoomH})`;
}
if (w * (9 / 16) < h) {
root.style.transform = `translate(${mw}px, ${mh}px) scale(${zoomW},${zoomW})`;
}
} else {
mw2os = -mw2os;
if (h * (9 / 16) >= w) {
root.style.transform = `rotate(90deg) translate(${mw2os}px, ${mh2os}px) scale(${zoomH2},${zoomH2})`;
}
if (h * (9 / 16) < w) {
root.style.transform = `rotate(90deg) translate(${mw2os}px, ${mh2os}px) scale(${zoomW2},${zoomW2})`;
}
}
}
}
</script>
</body>
</html>