mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-17 01:20:46 +08:00
Merge pull request #412 from nagisa77/codex/iconmap
refactor: centralize reaction emoji map
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<div class="reactions-viewer-item-container" @click="openPanel" @mouseenter="cancelHide"
|
<div class="reactions-viewer-item-container" @click="openPanel" @mouseenter="cancelHide"
|
||||||
@mouseleave="scheduleHide">
|
@mouseleave="scheduleHide">
|
||||||
<template v-if="displayedReactions.length">
|
<template v-if="displayedReactions.length">
|
||||||
<div v-for="r in displayedReactions" :key="r.type" class="reactions-viewer-item">{{ iconMap[r.type] }}</div>
|
<div v-for="r in displayedReactions" :key="r.type" class="reactions-viewer-item">{{ reactionEmojiMap[r.type] }}</div>
|
||||||
<div class="reactions-count">{{ totalCount }}</div>
|
<div class="reactions-count">{{ totalCount }}</div>
|
||||||
</template>
|
</template>
|
||||||
<div v-else class="reactions-viewer-item placeholder">
|
<div v-else class="reactions-viewer-item placeholder">
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
<div v-if="panelVisible" class="reactions-panel" @mouseenter="cancelHide" @mouseleave="scheduleHide">
|
<div v-if="panelVisible" class="reactions-panel" @mouseenter="cancelHide" @mouseleave="scheduleHide">
|
||||||
<div v-for="t in panelTypes" :key="t" class="reaction-option" @click="toggleReaction(t)"
|
<div v-for="t in panelTypes" :key="t" class="reaction-option" @click="toggleReaction(t)"
|
||||||
:class="{ selected: userReacted(t) }">
|
:class="{ selected: userReacted(t) }">
|
||||||
{{ iconMap[t] }}<span v-if="counts[t]">{{ counts[t] }}</span>
|
{{ reactionEmojiMap[t] }}<span v-if="counts[t]">{{ counts[t] }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
import { ref, computed, watch, onMounted } from 'vue'
|
import { ref, computed, watch, onMounted } from 'vue'
|
||||||
import { API_BASE_URL, toast } from '../main'
|
import { API_BASE_URL, toast } from '../main'
|
||||||
import { getToken, authState } from '../utils/auth'
|
import { getToken, authState } from '../utils/auth'
|
||||||
|
import { reactionEmojiMap } from '../utils/reactions'
|
||||||
|
|
||||||
let cachedTypes = null
|
let cachedTypes = null
|
||||||
const fetchTypes = async () => {
|
const fetchTypes = async () => {
|
||||||
@@ -54,32 +55,6 @@ const fetchTypes = async () => {
|
|||||||
return cachedTypes
|
return cachedTypes
|
||||||
}
|
}
|
||||||
|
|
||||||
const iconMap = {
|
|
||||||
LIKE: '❤️',
|
|
||||||
DISLIKE: '👎',
|
|
||||||
RECOMMEND: '👏',
|
|
||||||
ANGRY: '😡',
|
|
||||||
FLUSHED: '😳',
|
|
||||||
STAR_STRUCK: '🤩',
|
|
||||||
ROFL: '🤣',
|
|
||||||
HOLDING_BACK_TEARS: '🥹',
|
|
||||||
MIND_BLOWN: '🤯',
|
|
||||||
POOP: '💩',
|
|
||||||
CLOWN: '🤡',
|
|
||||||
SKULL: '☠️',
|
|
||||||
FIRE: '🔥',
|
|
||||||
EYES: '👀',
|
|
||||||
FROWN: '☹️',
|
|
||||||
HOT: '🥵',
|
|
||||||
EAGLE: '🦅',
|
|
||||||
SPIDER: '🕷️',
|
|
||||||
BAT: '🦇',
|
|
||||||
CHINA: '🇨🇳',
|
|
||||||
USA: '🇺🇸',
|
|
||||||
JAPAN: '🇯🇵',
|
|
||||||
KOREA: '🇰🇷'
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ReactionsGroup',
|
name: 'ReactionsGroup',
|
||||||
props: {
|
props: {
|
||||||
@@ -202,7 +177,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
iconMap,
|
reactionEmojiMap,
|
||||||
counts,
|
counts,
|
||||||
totalCount,
|
totalCount,
|
||||||
likeCount,
|
likeCount,
|
||||||
|
|||||||
25
frontend/src/utils/reactions.js
Normal file
25
frontend/src/utils/reactions.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
export const reactionEmojiMap = {
|
||||||
|
LIKE: '❤️',
|
||||||
|
DISLIKE: '👎',
|
||||||
|
RECOMMEND: '👏',
|
||||||
|
ANGRY: '😡',
|
||||||
|
FLUSHED: '😳',
|
||||||
|
STAR_STRUCK: '🤩',
|
||||||
|
ROFL: '🤣',
|
||||||
|
HOLDING_BACK_TEARS: '🥹',
|
||||||
|
MIND_BLOWN: '🤯',
|
||||||
|
POOP: '💩',
|
||||||
|
CLOWN: '🤡',
|
||||||
|
SKULL: '☠️',
|
||||||
|
FIRE: '🔥',
|
||||||
|
EYES: '👀',
|
||||||
|
FROWN: '☹️',
|
||||||
|
HOT: '🥵',
|
||||||
|
EAGLE: '🦅',
|
||||||
|
SPIDER: '🕷️',
|
||||||
|
BAT: '🦇',
|
||||||
|
CHINA: '🇨🇳',
|
||||||
|
USA: '🇺🇸',
|
||||||
|
JAPAN: '🇯🇵',
|
||||||
|
KOREA: '🇰🇷'
|
||||||
|
}
|
||||||
@@ -304,6 +304,7 @@ import { toast } from '../main'
|
|||||||
import { stripMarkdownLength } from '../utils/markdown'
|
import { stripMarkdownLength } from '../utils/markdown'
|
||||||
import TimeManager from '../utils/time'
|
import TimeManager from '../utils/time'
|
||||||
import { hatch } from 'ldrs'
|
import { hatch } from 'ldrs'
|
||||||
|
import { reactionEmojiMap } from '../utils/reactions'
|
||||||
hatch.register()
|
hatch.register()
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -378,32 +379,6 @@ export default {
|
|||||||
MENTION: 'fas fa-at'
|
MENTION: 'fas fa-at'
|
||||||
}
|
}
|
||||||
|
|
||||||
const reactionEmojiMap = {
|
|
||||||
LIKE: '❤️',
|
|
||||||
DISLIKE: '👎',
|
|
||||||
RECOMMEND: '👏',
|
|
||||||
ANGRY: '😡',
|
|
||||||
FLUSHED: '😳',
|
|
||||||
STAR_STRUCK: '🤩',
|
|
||||||
ROFL: '🤣',
|
|
||||||
HOLDING_BACK_TEARS: '🥹',
|
|
||||||
MIND_BLOWN: '🤯',
|
|
||||||
POOP: '💩',
|
|
||||||
CLOWN: '🤡',
|
|
||||||
SKULL: '☠️',
|
|
||||||
FIRE: '🔥',
|
|
||||||
EYES: '👀',
|
|
||||||
FROWN: '☹️',
|
|
||||||
HOT: '🥵',
|
|
||||||
EAGLE: '🦅',
|
|
||||||
SPIDER: '🕷️',
|
|
||||||
BAT: '🦇',
|
|
||||||
CHINA: '🇨🇳',
|
|
||||||
USA: '🇺🇸',
|
|
||||||
JAPAN: '🇯🇵',
|
|
||||||
KOREA: '🇰🇷'
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchNotifications = async () => {
|
const fetchNotifications = async () => {
|
||||||
try {
|
try {
|
||||||
const token = getToken()
|
const token = getToken()
|
||||||
|
|||||||
Reference in New Issue
Block a user