mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-09 00:21:13 +08:00
Compare commits
18 Commits
feature/da
...
codex/add-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd73747164 | ||
|
|
0ee58df868 | ||
|
|
6fed8131f6 | ||
|
|
d75c08396a | ||
|
|
3a742fbb00 | ||
|
|
9c2b1f6e98 | ||
|
|
28b33d8c44 | ||
|
|
1f99a10322 | ||
|
|
743c3dbc72 | ||
|
|
d46a446f2b | ||
|
|
75a785f612 | ||
|
|
e79b75f340 | ||
|
|
1f6f470ab5 | ||
|
|
583d4042f5 | ||
|
|
8437c1c714 | ||
|
|
2613fe6cf1 | ||
|
|
a15d541b72 | ||
|
|
809a78fee3 |
@@ -6,7 +6,9 @@ package com.openisle.model;
|
||||
public enum ReactionType {
|
||||
LIKE,
|
||||
DISLIKE,
|
||||
SMILE,
|
||||
RECOMMEND,
|
||||
CONGRATULATIONS,
|
||||
ANGRY,
|
||||
FLUSHED,
|
||||
STAR_STRUCK,
|
||||
@@ -26,5 +28,5 @@ public enum ReactionType {
|
||||
CHINA,
|
||||
USA,
|
||||
JAPAN,
|
||||
KOREA
|
||||
KOREA,
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
</div>
|
||||
<GlobalPopups />
|
||||
<ConfirmDialog />
|
||||
<ChatFloating />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -30,6 +31,7 @@ import HeaderComponent from '~/components/HeaderComponent.vue'
|
||||
import MenuComponent from '~/components/MenuComponent.vue'
|
||||
import GlobalPopups from '~/components/GlobalPopups.vue'
|
||||
import ConfirmDialog from '~/components/ConfirmDialog.vue'
|
||||
import ChatFloating from '~/components/ChatFloating.vue'
|
||||
import { useIsMobile } from '~/utils/screen'
|
||||
|
||||
const isMobile = useIsMobile()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="timeline">
|
||||
<div class="timeline" :class="{ 'hover-enabled': hover }">
|
||||
<div class="timeline-item" v-for="(item, idx) in items" :key="idx">
|
||||
<div
|
||||
class="timeline-icon"
|
||||
@@ -8,7 +8,7 @@
|
||||
>
|
||||
<img v-if="item.src" :src="item.src" class="timeline-img" alt="timeline item" />
|
||||
<i v-else-if="item.icon" :class="item.icon"></i>
|
||||
<span v-else-if="item.emoji" class="timeline-emoji">{{ item.emoji }}</span>
|
||||
<img v-else-if="item.emoji" :src="item.emoji" class="timeline-emoji" alt="emoji" />
|
||||
</div>
|
||||
<div class="timeline-content">
|
||||
<slot name="item" :item="item">{{ item.content }}</slot>
|
||||
@@ -22,6 +22,7 @@ export default {
|
||||
name: 'BaseTimeline',
|
||||
props: {
|
||||
items: { type: Array, default: () => [] },
|
||||
hover: { type: Boolean, default: false },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -41,7 +42,7 @@ export default {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.timeline-item:hover {
|
||||
.hover-enabled .timeline-item:hover {
|
||||
background-color: var(--menu-selected-background-color);
|
||||
transition: background-color 0.2s;
|
||||
border-radius: 10px;
|
||||
@@ -73,8 +74,9 @@ export default {
|
||||
}
|
||||
|
||||
.timeline-emoji {
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
.timeline-item::before {
|
||||
|
||||
56
frontend_nuxt/components/ChatFloating.vue
Normal file
56
frontend_nuxt/components/ChatFloating.vue
Normal file
@@ -0,0 +1,56 @@
|
||||
<template>
|
||||
<div v-if="chatFloating" class="chat-floating">
|
||||
<iframe :src="iframeSrc" class="chat-frame"></iframe>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
const chatFloating = useState('chatFloating', () => false)
|
||||
const chatPath = useState('chatPath', () => '/message-box')
|
||||
|
||||
const iframeSrc = computed(() =>
|
||||
chatPath.value.includes('?') ? `${chatPath.value}&float=1` : `${chatPath.value}?float=1`,
|
||||
)
|
||||
|
||||
if (process.client) {
|
||||
window.addEventListener('message', (event) => {
|
||||
if (event.data?.type === 'maximize-chat') {
|
||||
chatFloating.value = false
|
||||
navigateTo(event.data.path || chatPath.value)
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.chat-floating {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
width: 400px;
|
||||
height: 70vh;
|
||||
max-height: 600px;
|
||||
background: var(--background-color);
|
||||
border: 1px solid var(--normal-border-color);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||
z-index: 2000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.chat-frame {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
@media (max-width: 500px) {
|
||||
.chat-floating {
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 60vh;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -7,6 +7,7 @@
|
||||
@close="closeMilkTeaPopup"
|
||||
/>
|
||||
<NotificationSettingPopup :visible="showNotificationPopup" @close="closeNotificationPopup" />
|
||||
<MessagePopup :visible="showMessagePopup" @close="closeMessagePopup" />
|
||||
<MedalPopup :visible="showMedalPopup" :medals="newMedals" @close="closeMedalPopup" />
|
||||
|
||||
<ActivityPopup
|
||||
@@ -22,6 +23,7 @@
|
||||
import ActivityPopup from '~/components/ActivityPopup.vue'
|
||||
import MedalPopup from '~/components/MedalPopup.vue'
|
||||
import NotificationSettingPopup from '~/components/NotificationSettingPopup.vue'
|
||||
import MessagePopup from '~/components/MessagePopup.vue'
|
||||
import { authState } from '~/utils/auth'
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
@@ -33,6 +35,7 @@ const milkTeaIcon = ref('')
|
||||
const inviteCodeIcon = ref('')
|
||||
|
||||
const showNotificationPopup = ref(false)
|
||||
const showMessagePopup = ref(false)
|
||||
const showMedalPopup = ref(false)
|
||||
const newMedals = ref([])
|
||||
|
||||
@@ -43,6 +46,9 @@ onMounted(async () => {
|
||||
await checkInviteCodeActivity()
|
||||
if (showInviteCodePopup.value) return
|
||||
|
||||
await checkMessageFeature()
|
||||
if (showMessagePopup.value) return
|
||||
|
||||
await checkNotificationSetting()
|
||||
if (showNotificationPopup.value) return
|
||||
|
||||
@@ -97,6 +103,18 @@ const closeMilkTeaPopup = () => {
|
||||
showMilkTeaPopup.value = false
|
||||
}
|
||||
|
||||
const checkMessageFeature = async () => {
|
||||
if (!import.meta.client) return
|
||||
if (!authState.loggedIn) return
|
||||
if (localStorage.getItem('messageFeaturePopupShown')) return
|
||||
showMessagePopup.value = true
|
||||
}
|
||||
const closeMessagePopup = () => {
|
||||
if (!import.meta.client) return
|
||||
localStorage.setItem('messageFeaturePopupShown', 'true')
|
||||
showMessagePopup.value = false
|
||||
}
|
||||
|
||||
const checkNotificationSetting = async () => {
|
||||
if (!import.meta.client) return
|
||||
if (!authState.loggedIn) return
|
||||
|
||||
@@ -149,8 +149,20 @@ const copyInviteLink = async () => {
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
const inviteLink = data.token ? `${WEBSITE_BASE_URL}/signup?invite_token=${data.token}` : ''
|
||||
await navigator.clipboard.writeText(inviteLink)
|
||||
toast.success('邀请链接已复制')
|
||||
/**
|
||||
* navigator.clipboard在webkit中有点奇怪的行为
|
||||
* https://stackoverflow.com/questions/62327358/javascript-clipboard-api-safari-ios-notallowederror-message
|
||||
* https://webkit.org/blog/10247/new-webkit-features-in-safari-13-1/
|
||||
*/
|
||||
setTimeout(() => {
|
||||
navigator.clipboard.writeText(inviteLink)
|
||||
.then(() => {
|
||||
toast.success('邀请链接已复制')
|
||||
})
|
||||
.catch(() => {
|
||||
toast.error('邀请链接复制失败')
|
||||
})
|
||||
}, 0)
|
||||
} else {
|
||||
const data = await res.json().catch(() => ({}))
|
||||
toast.error(data.error || '生成邀请链接失败')
|
||||
|
||||
74
frontend_nuxt/components/MessagePopup.vue
Normal file
74
frontend_nuxt/components/MessagePopup.vue
Normal file
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<BasePopup :visible="visible" @close="close">
|
||||
<div class="message-popup">
|
||||
<div class="message-popup-title">📨 站内信上线啦</div>
|
||||
<div class="message-popup-text">现在可以在右上角使用站内信功能</div>
|
||||
<div class="message-popup-actions">
|
||||
<div class="message-popup-close" @click="close">知道了</div>
|
||||
<div class="message-popup-button" @click="gotoMessage">去看看</div>
|
||||
</div>
|
||||
</div>
|
||||
</BasePopup>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import BasePopup from '~/components/BasePopup.vue'
|
||||
|
||||
defineProps({
|
||||
visible: { type: Boolean, default: false },
|
||||
})
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
const gotoMessage = () => {
|
||||
emit('close')
|
||||
navigateTo('/message-box', { replace: true })
|
||||
}
|
||||
const close = () => emit('close')
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.message-popup {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
gap: 10px;
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
.message-popup-title {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.message-popup-actions {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.message-popup-button {
|
||||
background-color: var(--primary-color);
|
||||
color: #fff;
|
||||
padding: 8px 16px;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.message-popup-button:hover {
|
||||
background-color: var(--primary-color-hover);
|
||||
}
|
||||
|
||||
.message-popup-close {
|
||||
cursor: pointer;
|
||||
color: var(--primary-color);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.message-popup-close:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
@@ -3,20 +3,37 @@
|
||||
<div class="reactions-viewer">
|
||||
<div
|
||||
class="reactions-viewer-item-container"
|
||||
@click="openPanel"
|
||||
@mouseenter="cancelHide"
|
||||
@mouseleave="scheduleHide"
|
||||
>
|
||||
<template v-if="displayedReactions.length">
|
||||
<div v-for="r in displayedReactions" :key="r.type" class="reactions-viewer-item">
|
||||
{{ reactionEmojiMap[r.type] }}
|
||||
<template v-if="reactions.length < 4">
|
||||
<div
|
||||
v-for="r in displayedReactions"
|
||||
:key="r.type"
|
||||
class="reactions-viewer-single-item"
|
||||
:class="{ selected: userReacted(r.type) }"
|
||||
@click="toggleReaction(r.type)"
|
||||
>
|
||||
<img :src="reactionEmojiMap[r.type]" class="emoji" alt="emoji" />
|
||||
<div>{{ counts[r.type] }}</div>
|
||||
</div>
|
||||
|
||||
<div class="reactions-viewer-item placeholder" @click="openPanel">
|
||||
<i class="far fa-smile"></i>
|
||||
<!-- <span class="reactions-viewer-item-placeholder-text">点击以表态</span> -->
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="displayedReactions.length">
|
||||
<div
|
||||
v-for="r in displayedReactions"
|
||||
:key="r.type"
|
||||
class="reactions-viewer-item"
|
||||
@click="openPanel"
|
||||
>
|
||||
<img :src="reactionEmojiMap[r.type]" class="emoji" alt="emoji" />
|
||||
</div>
|
||||
<div class="reactions-count">{{ totalCount }}</div>
|
||||
</template>
|
||||
<div v-else class="reactions-viewer-item placeholder">
|
||||
<i class="far fa-smile"></i>
|
||||
<span class="reactions-viewer-item-placeholder-text">点击以表态</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="make-reaction-container">
|
||||
@@ -40,7 +57,9 @@
|
||||
@click="toggleReaction(t)"
|
||||
:class="{ selected: userReacted(t) }"
|
||||
>
|
||||
{{ reactionEmojiMap[t] }}<span v-if="counts[t]">{{ counts[t] }}</span>
|
||||
<img :src="reactionEmojiMap[t]" class="emoji" alt="emoji" /><span v-if="counts[t]">{{
|
||||
counts[t]
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -217,13 +236,6 @@ onMounted(async () => {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.reactions-viewer-item.placeholder {
|
||||
opacity: 0.5;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.reactions-viewer-item-placeholder-text {
|
||||
font-size: 14px;
|
||||
padding-left: 5px;
|
||||
@@ -262,18 +274,16 @@ onMounted(async () => {
|
||||
|
||||
.reactions-panel {
|
||||
position: absolute;
|
||||
bottom: 40px;
|
||||
left: -20px;
|
||||
bottom: 50px;
|
||||
background-color: var(--background-color);
|
||||
border: 1px solid var(--normal-border-color);
|
||||
border-radius: 5px;
|
||||
padding: 5px;
|
||||
max-width: 240px;
|
||||
border-radius: 20px;
|
||||
padding: 5px 10px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
z-index: 10;
|
||||
gap: 2px;
|
||||
gap: 5px;
|
||||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
@@ -287,6 +297,27 @@ onMounted(async () => {
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.reactions-viewer-item.placeholder,
|
||||
.reactions-viewer-single-item {
|
||||
display: flex;
|
||||
cursor: pointer;
|
||||
flex-direction: row;
|
||||
padding: 2px 10px;
|
||||
gap: 5px;
|
||||
border: 1px solid var(--normal-border-color);
|
||||
border-radius: 10px;
|
||||
margin-right: 5px;
|
||||
margin-bottom: 5px;
|
||||
font-size: 14px;
|
||||
color: var(--text-color);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.reactions-viewer-item.placeholder,
|
||||
.reactions-viewer-single-item.selected {
|
||||
background-color: var(--menu-selected-background-color);
|
||||
}
|
||||
|
||||
.reaction-option.selected {
|
||||
background-color: var(--menu-selected-background-color);
|
||||
}
|
||||
|
||||
@@ -652,6 +652,10 @@ const sanitizeDescription = (text) => stripMarkdown(text)
|
||||
}
|
||||
|
||||
@container home-page (max-width: 768px) {
|
||||
.topic-item-container {
|
||||
margin-left: 0px;
|
||||
gap: 0px;
|
||||
}
|
||||
.article-main-container,
|
||||
.header-item.main-item {
|
||||
width: calc(70% - 20px);
|
||||
@@ -709,6 +713,16 @@ const sanitizeDescription = (text) => stripMarkdown(text)
|
||||
|
||||
.topic-container {
|
||||
position: initial;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.topic-item {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.topic-select-container {
|
||||
margin-left: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
<h2 class="participant-name">
|
||||
{{ isChannel ? conversationName : otherParticipant?.username }}
|
||||
</h2>
|
||||
<div class="chat-controls">
|
||||
<i v-if="!isFloat" class="fas fa-window-minimize control-icon" @click="minimizeChat"></i>
|
||||
<i v-else class="fas fa-expand control-icon" @click="maximizeChat"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="messages-list" ref="messagesListEl">
|
||||
@@ -20,7 +24,7 @@
|
||||
{{ loadingMore ? '加载中...' : '查看更多消息' }}
|
||||
</div>
|
||||
</div>
|
||||
<BaseTimeline :items="messages">
|
||||
<BaseTimeline :items="messages" hover>
|
||||
<template #item="{ item }">
|
||||
<div class="message-header">
|
||||
<div class="user-name">
|
||||
@@ -82,6 +86,10 @@ const { fetchUnreadCount: refreshGlobalUnreadCount } = useUnreadCount()
|
||||
const { fetchChannelUnread: refreshChannelUnread } = useChannelsUnreadCount()
|
||||
let subscription = null
|
||||
|
||||
const chatFloating = useState('chatFloating', () => false)
|
||||
const chatPath = useState('chatPath', () => '/message-box')
|
||||
const isFloat = computed(() => route.query.float === '1')
|
||||
|
||||
const messages = ref([])
|
||||
const participants = ref([])
|
||||
const loading = ref(true)
|
||||
@@ -115,6 +123,24 @@ function handleAvatarError(event) {
|
||||
event.target.src = '/default-avatar.svg'
|
||||
}
|
||||
|
||||
function minimizeChat() {
|
||||
chatPath.value = route.fullPath
|
||||
chatFloating.value = true
|
||||
navigateTo('/')
|
||||
}
|
||||
|
||||
function maximizeChat() {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage(
|
||||
{
|
||||
type: 'maximize-chat',
|
||||
path: route.fullPath.replace('?float=1', '').replace('&float=1', ''),
|
||||
},
|
||||
'*',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// No changes needed here, as renderMarkdown is now imported.
|
||||
// The old function is removed.
|
||||
|
||||
@@ -411,6 +437,7 @@ onUnmounted(() => {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.messages-list {
|
||||
@@ -524,4 +551,15 @@ onUnmounted(() => {
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.chat-controls {
|
||||
margin-left: auto;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.control-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<template>
|
||||
<div class="messages-container">
|
||||
<div class="chat-controls">
|
||||
<i v-if="!isFloat" class="fas fa-window-minimize control-icon" @click="minimizeChat"></i>
|
||||
<i v-else class="fas fa-expand control-icon" @click="maximizeChat"></i>
|
||||
</div>
|
||||
<div class="tabs">
|
||||
<div :class="['tab', { active: activeTab === 'messages' }]" @click="activeTab = 'messages'">
|
||||
站内信
|
||||
@@ -114,8 +118,8 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onUnmounted, watch, onActivated } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ref, onUnmounted, watch, onActivated, computed } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { getToken, fetchCurrentUser } from '~/utils/auth'
|
||||
import { toast } from '~/main'
|
||||
import { useWebSocket } from '~/composables/useWebSocket'
|
||||
@@ -131,6 +135,7 @@ const conversations = ref([])
|
||||
const loading = ref(true)
|
||||
const error = ref(null)
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const currentUser = ref(null)
|
||||
const API_BASE_URL = config.public.apiBaseUrl
|
||||
const { connect, disconnect, subscribe, isConnected } = useWebSocket()
|
||||
@@ -139,6 +144,10 @@ const { fetchChannelUnread: refreshChannelUnread, setFromList: setChannelUnreadF
|
||||
useChannelsUnreadCount()
|
||||
let subscription = null
|
||||
|
||||
const chatFloating = useState('chatFloating', () => false)
|
||||
const chatPath = useState('chatPath', () => '/message-box')
|
||||
const isFloat = computed(() => route.query.float === '1')
|
||||
|
||||
const activeTab = ref('messages')
|
||||
const channels = ref([])
|
||||
const loadingChannels = ref(false)
|
||||
@@ -229,6 +238,24 @@ async function goToChannel(id) {
|
||||
}
|
||||
}
|
||||
|
||||
function minimizeChat() {
|
||||
chatPath.value = route.fullPath
|
||||
chatFloating.value = true
|
||||
navigateTo('/')
|
||||
}
|
||||
|
||||
function maximizeChat() {
|
||||
if (window.parent) {
|
||||
window.parent.postMessage(
|
||||
{
|
||||
type: 'maximize-chat',
|
||||
path: route.fullPath.replace('?float=1', '').replace('&float=1', ''),
|
||||
},
|
||||
'*',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
onActivated(async () => {
|
||||
loading.value = true
|
||||
currentUser.value = await fetchCurrentUser()
|
||||
@@ -278,6 +305,7 @@ function goToConversation(id) {
|
||||
|
||||
<style scoped>
|
||||
.messages-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
@@ -287,13 +315,13 @@ function goToConversation(id) {
|
||||
}
|
||||
|
||||
.tab {
|
||||
padding: 8px 16px;
|
||||
padding: 10px 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tab.active {
|
||||
font-weight: 600;
|
||||
border-bottom: 2px solid var(--primary-color);
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
.loading-message {
|
||||
@@ -437,6 +465,18 @@ function goToConversation(id) {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.chat-controls {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
cursor: pointer;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.control-icon {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.conversation-item {
|
||||
|
||||
@@ -1,25 +1,34 @@
|
||||
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: '🇰🇷',
|
||||
const toCdnUrl = (emoji) => {
|
||||
const codepoints = Array.from(emoji)
|
||||
.map((c) => c.codePointAt(0).toString(16))
|
||||
.join('_')
|
||||
return `https://fonts.gstatic.com/s/e/notoemoji/latest/${codepoints}/emoji.svg`
|
||||
}
|
||||
|
||||
export const reactionEmojiMap = {
|
||||
LIKE: toCdnUrl('❤️'),
|
||||
SMILE: toCdnUrl('😁'),
|
||||
DISLIKE: toCdnUrl('👎'),
|
||||
RECOMMEND: toCdnUrl('👏'),
|
||||
CONGRATULATIONS: toCdnUrl('🎉'),
|
||||
ANGRY: toCdnUrl('😡'),
|
||||
FLUSHED: toCdnUrl('😳'),
|
||||
STAR_STRUCK: toCdnUrl('🤩'),
|
||||
ROFL: toCdnUrl('🤣'),
|
||||
HOLDING_BACK_TEARS: toCdnUrl('🥹'),
|
||||
MIND_BLOWN: toCdnUrl('🤯'),
|
||||
POOP: toCdnUrl('💩'),
|
||||
CLOWN: toCdnUrl('🤡'),
|
||||
SKULL: toCdnUrl('☠️'),
|
||||
FIRE: toCdnUrl('🔥'),
|
||||
EYES: toCdnUrl('👀'),
|
||||
FROWN: toCdnUrl('☹️'),
|
||||
HOT: toCdnUrl('🥵'),
|
||||
EAGLE: toCdnUrl('🦅'),
|
||||
SPIDER: toCdnUrl('🕷️'),
|
||||
BAT: toCdnUrl('🦇'),
|
||||
CHINA: toCdnUrl('🇨🇳'),
|
||||
USA: toCdnUrl('🇺🇸'),
|
||||
JAPAN: toCdnUrl('🇯🇵'),
|
||||
KOREA: toCdnUrl('🇰🇷'),
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import Vditor from 'vditor'
|
||||
import { getToken, authState } from './auth'
|
||||
import { searchUsers, fetchFollowings, fetchAdmins } from './user'
|
||||
import { tiebaEmoji } from './tiebaEmoji'
|
||||
import vditorPostCitation from './vditorPostCitation.js'
|
||||
|
||||
export function getEditorTheme() {
|
||||
return document.documentElement.dataset.theme === 'dark' ? 'dark' : 'classic'
|
||||
@@ -79,6 +80,7 @@ export function createVditor(editorId, options = {}) {
|
||||
}))
|
||||
},
|
||||
},
|
||||
vditorPostCitation(API_BASE_URL),
|
||||
],
|
||||
},
|
||||
cdn: 'https://openisle-1307107697.cos.ap-guangzhou.myqcloud.com/assert/vditor',
|
||||
|
||||
37
frontend_nuxt/utils/vditorPostCitation.js
Normal file
37
frontend_nuxt/utils/vditorPostCitation.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { authState, getToken } from '~/utils/auth'
|
||||
|
||||
async function searchPost(apiBaseUrl, keyword) {
|
||||
return await fetch(`${apiBaseUrl}/api/search/posts/title?keyword=${keyword}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${getToken()}`,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export default (apiBaseUrl) => {
|
||||
return {
|
||||
key: '#',
|
||||
hint: async (keyword) => {
|
||||
if (!keyword.trim()) return []
|
||||
try {
|
||||
const response = await searchPost(apiBaseUrl, keyword)
|
||||
if (response.ok) {
|
||||
const body = await response.json()
|
||||
let value = ''
|
||||
return (
|
||||
body.map((item) => ({
|
||||
value: `[${item.title}](/posts/${item.id})`,
|
||||
html: `<div>${item.title}</div>`,
|
||||
})) ?? []
|
||||
)
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user