fix: 优化弹幕

This commit is contained in:
unanmed 2024-04-23 22:03:47 +08:00
parent ed3ef3c16a
commit 17d46fa158
2 changed files with 13 additions and 14 deletions

View File

@ -2,7 +2,13 @@ import BoxAnimate from '@/components/boxAnimate.vue';
import { EmitableEvent, EventEmitter } from '@/core/common/eventEmitter'; import { EmitableEvent, EventEmitter } from '@/core/common/eventEmitter';
import { logger } from '@/core/common/logger'; import { logger } from '@/core/common/logger';
import { ResponseBase } from '@/core/interface'; import { ResponseBase } from '@/core/interface';
import { deleteWith, ensureArray, parseCss, tip } from '@/plugin/utils'; import {
deleteWith,
ensureArray,
getIconHeight,
parseCss,
tip
} from '@/plugin/utils';
import axios, { AxiosResponse, toFormData } from 'axios'; import axios, { AxiosResponse, toFormData } from 'axios';
import { Component, VNode, h, shallowReactive } from 'vue'; import { Component, VNode, h, shallowReactive } from 'vue';
/* @__PURE__ */ import { id, password } from '../../../../user'; /* @__PURE__ */ import { id, password } from '../../../../user';
@ -484,22 +490,14 @@ export class Danmaku extends EventEmitter<DanmakuEvent> {
// 图标类型 // 图标类型
Danmaku.registerSpecContent('i', content => { Danmaku.registerSpecContent('i', content => {
const iconInfo = core.getBlockInfo(content as AllIds); const height = getIconHeight(content as AllIds);
if (!iconInfo) {
return h(BoxAnimate as Component, {
id: 'greenSlime',
noborder: true,
width: 32,
height: 32
});
}
return h(BoxAnimate as Component, { return h(BoxAnimate as Component, {
id: content, id: content,
noborder: true, noborder: true,
noAnimate: true, noAnimate: true,
width: 32, width: 32,
height: iconInfo.height height
}); });
}); });

View File

@ -97,7 +97,7 @@ ticker.add(time => {
if (!hover) { if (!hover) {
const dx = dt * speed; const dx = dt * speed;
value.pos -= dx; value.pos -= dx;
ele.style.left = `${value.pos.toFixed(2)}px`; ele.style.transform = `translateX(${value.pos.toFixed(2)}px)`;
} }
if (value.pos + width < 0) { if (value.pos + width < 0) {
@ -134,7 +134,7 @@ function touchStart(id: number) {
function calTop(id: number) { function calTop(id: number) {
const danmaku = eleMap.get(id)!; const danmaku = eleMap.get(id)!;
const fontSize = mainSetting.getValue('screen.fontSize', 16) * 1.25 + 10; const fontSize = mainSetting.getValue('screen.fontSize', 16) * 1.25 + 15;
const used: Set<number> = new Set(); const used: Set<number> = new Set();
eleMap.forEach(v => { eleMap.forEach(v => {
@ -177,7 +177,8 @@ onUnmounted(() => {
.danmaku-one { .danmaku-one {
position: fixed; position: fixed;
left: 100vw; left: 0;
transform: translateX(100vw);
width: max-content; width: max-content;
white-space: nowrap; white-space: nowrap;
text-wrap: nowrap; text-wrap: nowrap;