Files
vtsuru.live/src/views/obs/blivechat/constants.js
Megghy 45338ffe7d feat: Enhance message content handling and improve UI components
- Updated `getShowContentParts` function to handle message content more robustly, ensuring proper display of content parts.
- Refactored `GamepadViewer.vue` to use async component loading for `GamepadDisplay`, added a toggle for real-time preview.
- Implemented debounced search functionality in `PointGoodsView.vue` for improved performance during keyword searches.
- Enhanced `PointOrderView.vue` with order filtering capabilities and added statistics display for better user insights.
- Improved `PointUserHistoryView.vue` by adding export functionality for history data and enhanced filtering options.
- Updated `PointUserLayout.vue` to improve card styling and tab navigation experience.
- Refined `PointUserSettings.vue` layout for better user interaction and added responsive design adjustments.
- Adjusted `vite.config.mts` for better dependency management and build optimization.
2025-10-05 15:13:47 +08:00

219 lines
5.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
export const AUTHOR_TYPE_NORMAL = 0
export const AUTHOR_TYPE_MEMBER = 1
export const AUTHOR_TYPE_ADMIN = 2
export const AUTHOR_TYPE_OWNER = 3
export const AUTHOR_TYPE_TO_TEXT = [
'',
'member', // 舰队
'moderator', // 房管
'owner', // 主播
]
export function getShowGuardLevelText(guardLevel) {
switch (guardLevel) {
case 1:
return '总督'
case 2:
return '提督'
case 3:
return '舰长'
default:
return ''
}
}
export const MESSAGE_TYPE_TEXT = 0
export const MESSAGE_TYPE_GIFT = 1
export const MESSAGE_TYPE_MEMBER = 2
export const MESSAGE_TYPE_SUPER_CHAT = 3
export const MESSAGE_TYPE_DEL = 4
export const MESSAGE_TYPE_UPDATE = 5
export const CONTENT_TYPE_TEXT = 0
export const CONTENT_TYPE_IMAGE = 1
// 美元 -> 人民币 汇率
const EXCHANGE_RATE = 7
const PRICE_CONFIGS = [
// 0 淡蓝
{
price: 0,
colors: {
contentBg: 'rgba(153, 236, 255, 1)',
headerBg: 'rgba(153, 236, 255, 1)',
header: 'rgba(0,0,0,1)',
authorName: 'rgba(0,0,0,0.701961)',
time: 'rgba(0,0,0,0.501961)',
content: 'rgba(0,0,0,1)',
},
pinTime: 0,
priceLevel: 0,
},
// ¥0.01 蓝
{
price: 0.01,
colors: {
contentBg: 'rgba(30,136,229,1)',
headerBg: 'rgba(21,101,192,1)',
header: 'rgba(255,255,255,1)',
authorName: 'rgba(255,255,255,0.701961)',
time: 'rgba(255,255,255,0.501961)',
content: 'rgba(255,255,255,1)',
},
pinTime: 0,
priceLevel: 1,
},
// $2 浅蓝
{
price: 2 * EXCHANGE_RATE,
colors: {
contentBg: 'rgba(0,229,255,1)',
headerBg: 'rgba(0,184,212,1)',
header: 'rgba(0,0,0,1)',
authorName: 'rgba(0,0,0,0.701961)',
time: 'rgba(0,0,0,0.501961)',
content: 'rgba(0,0,0,1)',
},
pinTime: 0,
priceLevel: 2,
},
// $5 绿
{
price: 5 * EXCHANGE_RATE,
colors: {
contentBg: 'rgba(29,233,182,1)',
headerBg: 'rgba(0,191,165,1)',
header: 'rgba(0,0,0,1)',
authorName: 'rgba(0,0,0,0.541176)',
time: 'rgba(0,0,0,0.501961)',
content: 'rgba(0,0,0,1)',
},
pinTime: 2,
priceLevel: 3,
},
// $10 黄
{
price: 10 * EXCHANGE_RATE,
colors: {
contentBg: 'rgba(255,202,40,1)',
headerBg: 'rgba(255,179,0,1)',
header: 'rgba(0,0,0,0.87451)',
authorName: 'rgba(0,0,0,0.541176)',
time: 'rgba(0,0,0,0.501961)',
content: 'rgba(0,0,0,0.87451)',
},
pinTime: 5,
priceLevel: 4,
},
// $20 橙
{
price: 20 * EXCHANGE_RATE,
colors: {
contentBg: 'rgba(245,124,0,1)',
headerBg: 'rgba(230,81,0,1)',
header: 'rgba(255,255,255,0.87451)',
authorName: 'rgba(255,255,255,0.701961)',
time: 'rgba(255,255,255,0.501961)',
content: 'rgba(255,255,255,0.87451)',
},
pinTime: 10,
priceLevel: 5,
},
// $50 品红
{
price: 50 * EXCHANGE_RATE,
colors: {
contentBg: 'rgba(233,30,99,1)',
headerBg: 'rgba(194,24,91,1)',
header: 'rgba(255,255,255,1)',
authorName: 'rgba(255,255,255,0.701961)',
time: 'rgba(255,255,255,0.501961)',
content: 'rgba(255,255,255,1)',
},
pinTime: 30,
priceLevel: 6,
},
// $100 红
{
price: 100 * EXCHANGE_RATE,
colors: {
contentBg: 'rgba(230,33,23,1)',
headerBg: 'rgba(208,0,0,1)',
header: 'rgba(255,255,255,1)',
authorName: 'rgba(255,255,255,0.701961)',
time: 'rgba(255,255,255,0.501961)',
content: 'rgba(255,255,255,1)',
},
pinTime: 60,
priceLevel: 7,
},
]
export function getPriceConfig(price) {
let i = 0
// 根据先验知识,从小找到大通常更快结束
for (; i < PRICE_CONFIGS.length - 1; i++) {
const nextConfig = PRICE_CONFIGS[i + 1]
if (price < nextConfig.price) {
return PRICE_CONFIGS[i]
}
}
return PRICE_CONFIGS[i]
}
export function getShowContent(message) {
if (message.translation) {
return `${message.content}${message.translation}`
}
return message.content
}
export function getShowRichContent(message) {
const richContent = [...message.richContent]
if (message.translation) {
richContent.push({
type: CONTENT_TYPE_TEXT,
text: `${message.translation}`,
})
}
return richContent
}
export function getShowContentParts(message) {
const contentParts = Array.isArray(message.contentParts)
? [...message.contentParts]
: []
if (contentParts.length === 0 && message.content) {
contentParts.push({
type: CONTENT_TYPE_TEXT,
text: message.content,
})
}
if (message.translation) {
contentParts.push({
type: CONTENT_TYPE_TEXT,
text: `${message.translation}`,
})
}
return contentParts
}
export function getGiftShowContent(message, showGiftName) {
if (!showGiftName) {
return ''
}
return `赠送 ${message.giftName}x${message.num}`
}
export function getGiftShowNameAndNum(message) {
return `${message.giftName}x${message.num}`
}
export function getShowAuthorName(message) {
if (message.authorNamePronunciation && message.authorNamePronunciation !== message.authorName) {
return `${message.authorName}(${message.authorNamePronunciation})`
}
return message.authorName
}