mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-18 20:09:27 +08:00
优化开始界面代码
This commit is contained in:
parent
9e51b03a4d
commit
17e282a835
@ -197,9 +197,18 @@ export function download(content: string, name: string) {
|
||||
* @param funcs 函数列表
|
||||
* @param interval 调用间隔
|
||||
*/
|
||||
export async function doByInterval(funcs: (() => void)[], interval: number) {
|
||||
export async function doByInterval(
|
||||
funcs: (() => void)[],
|
||||
interval: number,
|
||||
awaitFirst: boolean = false
|
||||
) {
|
||||
for await (const fn of funcs) {
|
||||
await sleep(interval);
|
||||
if (awaitFirst) {
|
||||
await sleep(interval);
|
||||
}
|
||||
fn();
|
||||
if (!awaitFirst) {
|
||||
await sleep(interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ import { nextTick, onMounted, onUnmounted, reactive, ref } from 'vue';
|
||||
import { RightOutlined, SoundOutlined } from '@ant-design/icons-vue';
|
||||
import { sleep } from 'mutate-animate';
|
||||
import { Matrix4 } from '../plugin/webgl/matrix';
|
||||
import { keycode } from '../plugin/utils';
|
||||
import { doByInterval, keycode } from '../plugin/utils';
|
||||
import { KeyCode } from '../plugin/keyCodes';
|
||||
|
||||
let startdiv: HTMLDivElement;
|
||||
@ -184,20 +184,18 @@ async function showHard() {
|
||||
'left 0.4s ease-out, top 0.4s ease-out, opacity 0.4s linear';
|
||||
cursor.style.opacity = '0';
|
||||
buttons.forEach(v => (v.style.transition = ''));
|
||||
ids.unshift(toshow.pop()!);
|
||||
await sleep(150);
|
||||
ids.unshift(toshow.pop()!);
|
||||
await sleep(150);
|
||||
ids.unshift(toshow.pop()!);
|
||||
await sleep(150);
|
||||
ids.unshift(toshow.pop()!);
|
||||
await sleep(400);
|
||||
|
||||
await doByInterval(
|
||||
Array(4).fill(() => ids.unshift(toshow.pop()!)),
|
||||
150
|
||||
);
|
||||
await sleep(250);
|
||||
text.value = hard;
|
||||
toshow.push(hardIds.shift()!);
|
||||
await sleep(150);
|
||||
toshow.push(hardIds.shift()!);
|
||||
await sleep(150);
|
||||
toshow.push(hardIds.shift()!);
|
||||
|
||||
await doByInterval(
|
||||
Array(3).fill(() => toshow.push(hardIds.shift()!)),
|
||||
150
|
||||
);
|
||||
selected.value = 'easy';
|
||||
nextTick(() => {
|
||||
buttons = toshow
|
||||
@ -219,24 +217,22 @@ async function setButtonAnimate() {
|
||||
'left 0.4s ease-out, top 0.4s ease-out, opacity 0.4s linear';
|
||||
cursor.style.opacity = '0';
|
||||
buttons.forEach(v => (v.style.transition = ''));
|
||||
hardIds.unshift(toshow.pop()!);
|
||||
await sleep(150);
|
||||
hardIds.unshift(toshow.pop()!);
|
||||
await sleep(150);
|
||||
hardIds.unshift(toshow.pop()!);
|
||||
await doByInterval(
|
||||
Array(3).fill(() => hardIds.unshift(toshow.pop()!)),
|
||||
150
|
||||
);
|
||||
}
|
||||
text.value = text1;
|
||||
if (played) {
|
||||
text.value = text2;
|
||||
}
|
||||
await sleep(400);
|
||||
toshow.push(ids.shift()!);
|
||||
await sleep(150);
|
||||
toshow.push(ids.shift()!);
|
||||
await sleep(150);
|
||||
toshow.push(ids.shift()!);
|
||||
await sleep(150);
|
||||
toshow.push(ids.shift()!);
|
||||
await sleep(250);
|
||||
|
||||
await doByInterval(
|
||||
Array(4).fill(() => toshow.push(ids.shift()!)),
|
||||
150
|
||||
);
|
||||
|
||||
selected.value = 'start-game';
|
||||
nextTick(() => {
|
||||
buttons = toshow
|
||||
|
Loading…
Reference in New Issue
Block a user