mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-02 01:50:46 +08:00
feat: update page view
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { API_BASE_URL } from '../main'
|
import { API_BASE_URL } from '../main'
|
||||||
import BaseTimeline from '../components/BaseTimeline.vue'
|
import BaseTimeline from '../components/BaseTimeline.vue'
|
||||||
|
import { getToken } from '../utils/auth'
|
||||||
|
import { toast } from '../main'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'MessagePageView',
|
name: 'MessagePageView',
|
||||||
@@ -33,8 +35,20 @@ export default {
|
|||||||
|
|
||||||
const fetchNotifications = async () => {
|
const fetchNotifications = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`${API_BASE_URL}/api/notifications`)
|
const token = getToken()
|
||||||
if (!res.ok) return
|
if (!token) {
|
||||||
|
toast.error('请先登录')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const res = await fetch(`${API_BASE_URL}/api/notifications`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${token}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (!res.ok) {
|
||||||
|
toast.error('获取通知失败')
|
||||||
|
return
|
||||||
|
}
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
notifications.value = data.map(n => ({ ...n, icon: iconMap[n.type] }))
|
notifications.value = data.map(n => ({ ...n, icon: iconMap[n.type] }))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
<div class="info-content">
|
<div class="info-content">
|
||||||
<div class="info-content-header">
|
<div class="info-content-header">
|
||||||
<div class="user-name">Nagisa77</div>
|
<div class="user-name">{{ author.username }}</div>
|
||||||
<div class="post-time">{{ postTime }}</div>
|
<div class="post-time">{{ postTime }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="info-content-text" v-html="renderMarkdown(postContent)"></div>
|
<div class="info-content-text" v-html="renderMarkdown(postContent)"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user