mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-24 15:10:48 +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 {
|
public enum ReactionType {
|
||||||
LIKE,
|
LIKE,
|
||||||
DISLIKE,
|
DISLIKE,
|
||||||
|
SMILE,
|
||||||
RECOMMEND,
|
RECOMMEND,
|
||||||
|
CONGRATULATIONS,
|
||||||
ANGRY,
|
ANGRY,
|
||||||
FLUSHED,
|
FLUSHED,
|
||||||
STAR_STRUCK,
|
STAR_STRUCK,
|
||||||
@@ -26,5 +28,5 @@ public enum ReactionType {
|
|||||||
CHINA,
|
CHINA,
|
||||||
USA,
|
USA,
|
||||||
JAPAN,
|
JAPAN,
|
||||||
KOREA
|
KOREA,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<GlobalPopups />
|
<GlobalPopups />
|
||||||
<ConfirmDialog />
|
<ConfirmDialog />
|
||||||
|
<ChatFloating />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ import HeaderComponent from '~/components/HeaderComponent.vue'
|
|||||||
import MenuComponent from '~/components/MenuComponent.vue'
|
import MenuComponent from '~/components/MenuComponent.vue'
|
||||||
import GlobalPopups from '~/components/GlobalPopups.vue'
|
import GlobalPopups from '~/components/GlobalPopups.vue'
|
||||||
import ConfirmDialog from '~/components/ConfirmDialog.vue'
|
import ConfirmDialog from '~/components/ConfirmDialog.vue'
|
||||||
|
import ChatFloating from '~/components/ChatFloating.vue'
|
||||||
import { useIsMobile } from '~/utils/screen'
|
import { useIsMobile } from '~/utils/screen'
|
||||||
|
|
||||||
const isMobile = useIsMobile()
|
const isMobile = useIsMobile()
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<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-item" v-for="(item, idx) in items" :key="idx">
|
||||||
<div
|
<div
|
||||||
class="timeline-icon"
|
class="timeline-icon"
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
>
|
>
|
||||||
<img v-if="item.src" :src="item.src" class="timeline-img" alt="timeline item" />
|
<img v-if="item.src" :src="item.src" class="timeline-img" alt="timeline item" />
|
||||||
<i v-else-if="item.icon" :class="item.icon"></i>
|
<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>
|
||||||
<div class="timeline-content">
|
<div class="timeline-content">
|
||||||
<slot name="item" :item="item">{{ item.content }}</slot>
|
<slot name="item" :item="item">{{ item.content }}</slot>
|
||||||
@@ -22,6 +22,7 @@ export default {
|
|||||||
name: 'BaseTimeline',
|
name: 'BaseTimeline',
|
||||||
props: {
|
props: {
|
||||||
items: { type: Array, default: () => [] },
|
items: { type: Array, default: () => [] },
|
||||||
|
hover: { type: Boolean, default: false },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -41,7 +42,7 @@ export default {
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-item:hover {
|
.hover-enabled .timeline-item:hover {
|
||||||
background-color: var(--menu-selected-background-color);
|
background-color: var(--menu-selected-background-color);
|
||||||
transition: background-color 0.2s;
|
transition: background-color 0.2s;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
@@ -73,8 +74,9 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.timeline-emoji {
|
.timeline-emoji {
|
||||||
font-size: 20px;
|
width: 20px;
|
||||||
line-height: 1;
|
height: 20px;
|
||||||
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-item::before {
|
.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"
|
@close="closeMilkTeaPopup"
|
||||||
/>
|
/>
|
||||||
<NotificationSettingPopup :visible="showNotificationPopup" @close="closeNotificationPopup" />
|
<NotificationSettingPopup :visible="showNotificationPopup" @close="closeNotificationPopup" />
|
||||||
|
<MessagePopup :visible="showMessagePopup" @close="closeMessagePopup" />
|
||||||
<MedalPopup :visible="showMedalPopup" :medals="newMedals" @close="closeMedalPopup" />
|
<MedalPopup :visible="showMedalPopup" :medals="newMedals" @close="closeMedalPopup" />
|
||||||
|
|
||||||
<ActivityPopup
|
<ActivityPopup
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
import ActivityPopup from '~/components/ActivityPopup.vue'
|
import ActivityPopup from '~/components/ActivityPopup.vue'
|
||||||
import MedalPopup from '~/components/MedalPopup.vue'
|
import MedalPopup from '~/components/MedalPopup.vue'
|
||||||
import NotificationSettingPopup from '~/components/NotificationSettingPopup.vue'
|
import NotificationSettingPopup from '~/components/NotificationSettingPopup.vue'
|
||||||
|
import MessagePopup from '~/components/MessagePopup.vue'
|
||||||
import { authState } from '~/utils/auth'
|
import { authState } from '~/utils/auth'
|
||||||
|
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
@@ -33,6 +35,7 @@ const milkTeaIcon = ref('')
|
|||||||
const inviteCodeIcon = ref('')
|
const inviteCodeIcon = ref('')
|
||||||
|
|
||||||
const showNotificationPopup = ref(false)
|
const showNotificationPopup = ref(false)
|
||||||
|
const showMessagePopup = ref(false)
|
||||||
const showMedalPopup = ref(false)
|
const showMedalPopup = ref(false)
|
||||||
const newMedals = ref([])
|
const newMedals = ref([])
|
||||||
|
|
||||||
@@ -43,6 +46,9 @@ onMounted(async () => {
|
|||||||
await checkInviteCodeActivity()
|
await checkInviteCodeActivity()
|
||||||
if (showInviteCodePopup.value) return
|
if (showInviteCodePopup.value) return
|
||||||
|
|
||||||
|
await checkMessageFeature()
|
||||||
|
if (showMessagePopup.value) return
|
||||||
|
|
||||||
await checkNotificationSetting()
|
await checkNotificationSetting()
|
||||||
if (showNotificationPopup.value) return
|
if (showNotificationPopup.value) return
|
||||||
|
|
||||||
@@ -97,6 +103,18 @@ const closeMilkTeaPopup = () => {
|
|||||||
showMilkTeaPopup.value = false
|
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 () => {
|
const checkNotificationSetting = async () => {
|
||||||
if (!import.meta.client) return
|
if (!import.meta.client) return
|
||||||
if (!authState.loggedIn) return
|
if (!authState.loggedIn) return
|
||||||
|
|||||||
@@ -149,8 +149,20 @@ const copyInviteLink = async () => {
|
|||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
const inviteLink = data.token ? `${WEBSITE_BASE_URL}/signup?invite_token=${data.token}` : ''
|
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 {
|
} else {
|
||||||
const data = await res.json().catch(() => ({}))
|
const data = await res.json().catch(() => ({}))
|
||||||
toast.error(data.error || '生成邀请链接失败')
|
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">
|
||||||
<div
|
<div
|
||||||
class="reactions-viewer-item-container"
|
class="reactions-viewer-item-container"
|
||||||
@click="openPanel"
|
|
||||||
@mouseenter="cancelHide"
|
@mouseenter="cancelHide"
|
||||||
@mouseleave="scheduleHide"
|
@mouseleave="scheduleHide"
|
||||||
>
|
>
|
||||||
<template v-if="displayedReactions.length">
|
<template v-if="reactions.length < 4">
|
||||||
<div v-for="r in displayedReactions" :key="r.type" class="reactions-viewer-item">
|
<div
|
||||||
{{ reactionEmojiMap[r.type] }}
|
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>
|
||||||
<div class="reactions-count">{{ totalCount }}</div>
|
<div class="reactions-count">{{ totalCount }}</div>
|
||||||
</template>
|
</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>
|
</div>
|
||||||
<div class="make-reaction-container">
|
<div class="make-reaction-container">
|
||||||
@@ -40,7 +57,9 @@
|
|||||||
@click="toggleReaction(t)"
|
@click="toggleReaction(t)"
|
||||||
:class="{ selected: userReacted(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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -217,13 +236,6 @@ onMounted(async () => {
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.reactions-viewer-item.placeholder {
|
|
||||||
opacity: 0.5;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.reactions-viewer-item-placeholder-text {
|
.reactions-viewer-item-placeholder-text {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
@@ -262,18 +274,16 @@ onMounted(async () => {
|
|||||||
|
|
||||||
.reactions-panel {
|
.reactions-panel {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 40px;
|
bottom: 50px;
|
||||||
left: -20px;
|
|
||||||
background-color: var(--background-color);
|
background-color: var(--background-color);
|
||||||
border: 1px solid var(--normal-border-color);
|
border: 1px solid var(--normal-border-color);
|
||||||
border-radius: 5px;
|
border-radius: 20px;
|
||||||
padding: 5px;
|
padding: 5px 10px;
|
||||||
max-width: 240px;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
gap: 2px;
|
gap: 5px;
|
||||||
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
|
box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +297,27 @@ onMounted(async () => {
|
|||||||
gap: 2px;
|
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 {
|
.reaction-option.selected {
|
||||||
background-color: var(--menu-selected-background-color);
|
background-color: var(--menu-selected-background-color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -652,6 +652,10 @@ const sanitizeDescription = (text) => stripMarkdown(text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@container home-page (max-width: 768px) {
|
@container home-page (max-width: 768px) {
|
||||||
|
.topic-item-container {
|
||||||
|
margin-left: 0px;
|
||||||
|
gap: 0px;
|
||||||
|
}
|
||||||
.article-main-container,
|
.article-main-container,
|
||||||
.header-item.main-item {
|
.header-item.main-item {
|
||||||
width: calc(70% - 20px);
|
width: calc(70% - 20px);
|
||||||
@@ -709,6 +713,16 @@ const sanitizeDescription = (text) => stripMarkdown(text)
|
|||||||
|
|
||||||
.topic-container {
|
.topic-container {
|
||||||
position: initial;
|
position: initial;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topic-item {
|
||||||
|
padding: 10px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topic-select-container {
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
<h2 class="participant-name">
|
<h2 class="participant-name">
|
||||||
{{ isChannel ? conversationName : otherParticipant?.username }}
|
{{ isChannel ? conversationName : otherParticipant?.username }}
|
||||||
</h2>
|
</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>
|
||||||
|
|
||||||
<div class="messages-list" ref="messagesListEl">
|
<div class="messages-list" ref="messagesListEl">
|
||||||
@@ -20,7 +24,7 @@
|
|||||||
{{ loadingMore ? '加载中...' : '查看更多消息' }}
|
{{ loadingMore ? '加载中...' : '查看更多消息' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<BaseTimeline :items="messages">
|
<BaseTimeline :items="messages" hover>
|
||||||
<template #item="{ item }">
|
<template #item="{ item }">
|
||||||
<div class="message-header">
|
<div class="message-header">
|
||||||
<div class="user-name">
|
<div class="user-name">
|
||||||
@@ -82,6 +86,10 @@ const { fetchUnreadCount: refreshGlobalUnreadCount } = useUnreadCount()
|
|||||||
const { fetchChannelUnread: refreshChannelUnread } = useChannelsUnreadCount()
|
const { fetchChannelUnread: refreshChannelUnread } = useChannelsUnreadCount()
|
||||||
let subscription = null
|
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 messages = ref([])
|
||||||
const participants = ref([])
|
const participants = ref([])
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
@@ -115,6 +123,24 @@ function handleAvatarError(event) {
|
|||||||
event.target.src = '/default-avatar.svg'
|
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.
|
// No changes needed here, as renderMarkdown is now imported.
|
||||||
// The old function is removed.
|
// The old function is removed.
|
||||||
|
|
||||||
@@ -411,6 +437,7 @@ onUnmounted(() => {
|
|||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.messages-list {
|
.messages-list {
|
||||||
@@ -524,4 +551,15 @@ onUnmounted(() => {
|
|||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-controls {
|
||||||
|
margin-left: auto;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-icon {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="messages-container">
|
<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="tabs">
|
||||||
<div :class="['tab', { active: activeTab === 'messages' }]" @click="activeTab = 'messages'">
|
<div :class="['tab', { active: activeTab === 'messages' }]" @click="activeTab = 'messages'">
|
||||||
站内信
|
站内信
|
||||||
@@ -114,8 +118,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onUnmounted, watch, onActivated } from 'vue'
|
import { ref, onUnmounted, watch, onActivated, computed } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { getToken, fetchCurrentUser } from '~/utils/auth'
|
import { getToken, fetchCurrentUser } from '~/utils/auth'
|
||||||
import { toast } from '~/main'
|
import { toast } from '~/main'
|
||||||
import { useWebSocket } from '~/composables/useWebSocket'
|
import { useWebSocket } from '~/composables/useWebSocket'
|
||||||
@@ -131,6 +135,7 @@ const conversations = ref([])
|
|||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const error = ref(null)
|
const error = ref(null)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
const currentUser = ref(null)
|
const currentUser = ref(null)
|
||||||
const API_BASE_URL = config.public.apiBaseUrl
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const { connect, disconnect, subscribe, isConnected } = useWebSocket()
|
const { connect, disconnect, subscribe, isConnected } = useWebSocket()
|
||||||
@@ -139,6 +144,10 @@ const { fetchChannelUnread: refreshChannelUnread, setFromList: setChannelUnreadF
|
|||||||
useChannelsUnreadCount()
|
useChannelsUnreadCount()
|
||||||
let subscription = null
|
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 activeTab = ref('messages')
|
||||||
const channels = ref([])
|
const channels = ref([])
|
||||||
const loadingChannels = ref(false)
|
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 () => {
|
onActivated(async () => {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
currentUser.value = await fetchCurrentUser()
|
currentUser.value = await fetchCurrentUser()
|
||||||
@@ -278,6 +305,7 @@ function goToConversation(id) {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.messages-container {
|
.messages-container {
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tabs {
|
.tabs {
|
||||||
@@ -287,13 +315,13 @@ function goToConversation(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tab {
|
.tab {
|
||||||
padding: 8px 16px;
|
padding: 10px 20px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab.active {
|
.tab.active {
|
||||||
font-weight: 600;
|
|
||||||
border-bottom: 2px solid var(--primary-color);
|
border-bottom: 2px solid var(--primary-color);
|
||||||
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.loading-message {
|
.loading-message {
|
||||||
@@ -437,6 +465,18 @@ function goToConversation(id) {
|
|||||||
margin-left: 4px;
|
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) {
|
@media (max-width: 768px) {
|
||||||
.conversation-item {
|
.conversation-item {
|
||||||
|
|||||||
@@ -1,25 +1,34 @@
|
|||||||
export const reactionEmojiMap = {
|
const toCdnUrl = (emoji) => {
|
||||||
LIKE: '❤️',
|
const codepoints = Array.from(emoji)
|
||||||
DISLIKE: '👎',
|
.map((c) => c.codePointAt(0).toString(16))
|
||||||
RECOMMEND: '👏',
|
.join('_')
|
||||||
ANGRY: '😡',
|
return `https://fonts.gstatic.com/s/e/notoemoji/latest/${codepoints}/emoji.svg`
|
||||||
FLUSHED: '😳',
|
}
|
||||||
STAR_STRUCK: '🤩',
|
|
||||||
ROFL: '🤣',
|
export const reactionEmojiMap = {
|
||||||
HOLDING_BACK_TEARS: '🥹',
|
LIKE: toCdnUrl('❤️'),
|
||||||
MIND_BLOWN: '🤯',
|
SMILE: toCdnUrl('😁'),
|
||||||
POOP: '💩',
|
DISLIKE: toCdnUrl('👎'),
|
||||||
CLOWN: '🤡',
|
RECOMMEND: toCdnUrl('👏'),
|
||||||
SKULL: '☠️',
|
CONGRATULATIONS: toCdnUrl('🎉'),
|
||||||
FIRE: '🔥',
|
ANGRY: toCdnUrl('😡'),
|
||||||
EYES: '👀',
|
FLUSHED: toCdnUrl('😳'),
|
||||||
FROWN: '☹️',
|
STAR_STRUCK: toCdnUrl('🤩'),
|
||||||
HOT: '🥵',
|
ROFL: toCdnUrl('🤣'),
|
||||||
EAGLE: '🦅',
|
HOLDING_BACK_TEARS: toCdnUrl('🥹'),
|
||||||
SPIDER: '🕷️',
|
MIND_BLOWN: toCdnUrl('🤯'),
|
||||||
BAT: '🦇',
|
POOP: toCdnUrl('💩'),
|
||||||
CHINA: '🇨🇳',
|
CLOWN: toCdnUrl('🤡'),
|
||||||
USA: '🇺🇸',
|
SKULL: toCdnUrl('☠️'),
|
||||||
JAPAN: '🇯🇵',
|
FIRE: toCdnUrl('🔥'),
|
||||||
KOREA: '🇰🇷',
|
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 { getToken, authState } from './auth'
|
||||||
import { searchUsers, fetchFollowings, fetchAdmins } from './user'
|
import { searchUsers, fetchFollowings, fetchAdmins } from './user'
|
||||||
import { tiebaEmoji } from './tiebaEmoji'
|
import { tiebaEmoji } from './tiebaEmoji'
|
||||||
|
import vditorPostCitation from './vditorPostCitation.js'
|
||||||
|
|
||||||
export function getEditorTheme() {
|
export function getEditorTheme() {
|
||||||
return document.documentElement.dataset.theme === 'dark' ? 'dark' : 'classic'
|
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',
|
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