mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-09 16:41:04 +08:00
Compare commits
25 Commits
codex/refa
...
codex/crea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
efbb83924b | ||
|
|
26d1db79f4 | ||
|
|
f5b40feaa2 | ||
|
|
c47c318e6f | ||
|
|
c02d993e90 | ||
|
|
f36bcb74ca | ||
|
|
2263fd97db | ||
|
|
9234d1099e | ||
|
|
373dece19d | ||
|
|
b09828bcc2 | ||
|
|
8751a7707c | ||
|
|
f91b240802 | ||
|
|
062b289f7a | ||
|
|
c1dc77f6db | ||
|
|
cea60175c2 | ||
|
|
2bd3630512 | ||
|
|
a9d8181940 | ||
|
|
4cc108094d | ||
|
|
bfa57cce44 | ||
|
|
8ebdcd94f5 | ||
|
|
9991210db2 | ||
|
|
1c59815afa | ||
|
|
e7593c8ebf | ||
|
|
bc767a6ac9 | ||
|
|
1c1915285d |
@@ -101,8 +101,8 @@ public class SecurityConfig {
|
|||||||
"http://localhost",
|
"http://localhost",
|
||||||
"http://30.211.97.238:3000",
|
"http://30.211.97.238:3000",
|
||||||
"http://30.211.97.238",
|
"http://30.211.97.238",
|
||||||
"http://192.168.7.98",
|
"http://192.168.7.90",
|
||||||
"http://192.168.7.98:3000",
|
"http://192.168.7.90:3000",
|
||||||
"https://petstore.swagger.io",
|
"https://petstore.swagger.io",
|
||||||
// 允许自建OpenAPI地址
|
// 允许自建OpenAPI地址
|
||||||
"https://docs.open-isle.com",
|
"https://docs.open-isle.com",
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ public class UserMapper {
|
|||||||
private final PostReadService postReadService;
|
private final PostReadService postReadService;
|
||||||
private final LevelService levelService;
|
private final LevelService levelService;
|
||||||
private final MedalService medalService;
|
private final MedalService medalService;
|
||||||
private final TagMapper tagMapper;
|
|
||||||
private final CategoryMapper categoryMapper;
|
private final CategoryMapper categoryMapper;
|
||||||
|
private final TagMapper tagMapper;
|
||||||
|
|
||||||
@Value("${app.snippet-length}")
|
@Value("${app.snippet-length}")
|
||||||
private int snippetLength;
|
private int snippetLength;
|
||||||
@@ -93,11 +93,8 @@ public class UserMapper {
|
|||||||
dto.setCreatedAt(post.getCreatedAt());
|
dto.setCreatedAt(post.getCreatedAt());
|
||||||
dto.setCategory(categoryMapper.toDto(post.getCategory()));
|
dto.setCategory(categoryMapper.toDto(post.getCategory()));
|
||||||
dto.setTags(post.getTags().stream().map(tagMapper::toDto).collect(Collectors.toList()));
|
dto.setTags(post.getTags().stream().map(tagMapper::toDto).collect(Collectors.toList()));
|
||||||
if (post.getLastReplyAt() == null) {
|
|
||||||
commentService.updatePostCommentStats(post);
|
|
||||||
}
|
|
||||||
dto.setCommentCount(post.getCommentCount());
|
|
||||||
dto.setViews(post.getViews());
|
dto.setViews(post.getViews());
|
||||||
|
dto.setCommentCount(post.getCommentCount());
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
import com.openisle.dto.CommentInfoDto;
|
import com.openisle.dto.CommentInfoDto;
|
||||||
import com.openisle.dto.PostMetaDto;
|
import com.openisle.dto.PostMetaDto;
|
||||||
import com.openisle.dto.UserDto;
|
import com.openisle.dto.UserDto;
|
||||||
|
import com.openisle.mapper.CategoryMapper;
|
||||||
import com.openisle.mapper.TagMapper;
|
import com.openisle.mapper.TagMapper;
|
||||||
import com.openisle.mapper.UserMapper;
|
import com.openisle.mapper.UserMapper;
|
||||||
import com.openisle.model.User;
|
import com.openisle.model.User;
|
||||||
@@ -64,6 +65,9 @@ class UserControllerTest {
|
|||||||
@MockBean
|
@MockBean
|
||||||
private TagMapper tagMapper;
|
private TagMapper tagMapper;
|
||||||
|
|
||||||
|
@MockBean
|
||||||
|
private CategoryMapper categoryMapper;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getCurrentUser() throws Exception {
|
void getCurrentUser() throws Exception {
|
||||||
User u = new User();
|
User u = new User();
|
||||||
|
|||||||
65
docs/components/api-overview.tsx
Normal file
65
docs/components/api-overview.tsx
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
import { getOpenAPIOperations } from "@/lib/openapi-operations";
|
||||||
|
|
||||||
|
const methodColors: Record<string, string> = {
|
||||||
|
GET: "bg-emerald-100 text-emerald-700",
|
||||||
|
POST: "bg-blue-100 text-blue-700",
|
||||||
|
PUT: "bg-amber-100 text-amber-700",
|
||||||
|
PATCH: "bg-purple-100 text-purple-700",
|
||||||
|
DELETE: "bg-rose-100 text-rose-700",
|
||||||
|
};
|
||||||
|
|
||||||
|
function MethodBadge({ method }: { method: string }) {
|
||||||
|
const color = methodColors[method] ?? "bg-slate-100 text-slate-700";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={`font-semibold uppercase tracking-wide text-xs px-2 py-1 rounded ${color}`}
|
||||||
|
>
|
||||||
|
{method}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function APIOverviewTable() {
|
||||||
|
const operations = getOpenAPIOperations();
|
||||||
|
|
||||||
|
if (operations.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="not-prose mt-6 overflow-x-auto">
|
||||||
|
<table className="w-full border-separate border-spacing-y-2 text-sm">
|
||||||
|
<thead className="text-left text-muted-foreground">
|
||||||
|
<tr>
|
||||||
|
<th className="px-3 py-2 font-medium">路径</th>
|
||||||
|
<th className="px-3 py-2 font-medium">方法</th>
|
||||||
|
<th className="px-3 py-2 font-medium">摘要</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{operations.map((operation) => (
|
||||||
|
<tr
|
||||||
|
key={`${operation.method}-${operation.route}`}
|
||||||
|
className="bg-muted/30"
|
||||||
|
>
|
||||||
|
<td className="px-3 py-2 align-top font-mono">
|
||||||
|
<Link className="hover:underline" href={operation.href}>
|
||||||
|
{operation.route}
|
||||||
|
</Link>
|
||||||
|
</td>
|
||||||
|
<td className="px-3 py-2 align-top">
|
||||||
|
<MethodBadge method={operation.method} />
|
||||||
|
</td>
|
||||||
|
<td className="px-3 py-2 align-top text-muted-foreground">
|
||||||
|
{operation.summary || "—"}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -2,3 +2,11 @@
|
|||||||
title: API 概览
|
title: API 概览
|
||||||
description: Open API 接口文档
|
description: Open API 接口文档
|
||||||
---
|
---
|
||||||
|
|
||||||
|
import { APIOverviewTable } from "@/components/api-overview";
|
||||||
|
|
||||||
|
# 接口列表
|
||||||
|
|
||||||
|
以下列表聚合了所有已生成的接口页面,展示对应的路径、请求方法以及摘要,便于快速检索和跳转。
|
||||||
|
|
||||||
|
<APIOverviewTable />
|
||||||
|
|||||||
68
docs/lib/openapi-operations.ts
Normal file
68
docs/lib/openapi-operations.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import matter from "gray-matter";
|
||||||
|
|
||||||
|
import { source } from "@/lib/source";
|
||||||
|
|
||||||
|
interface OperationFrontmatter {
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
_openapi?: {
|
||||||
|
method?: string;
|
||||||
|
route?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OpenAPIOperation {
|
||||||
|
href: string;
|
||||||
|
method: string;
|
||||||
|
route: string;
|
||||||
|
summary: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseFrontmatter(content: string): OperationFrontmatter {
|
||||||
|
const result = matter(content);
|
||||||
|
|
||||||
|
return result.data as OperationFrontmatter;
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeSummary(frontmatter: OperationFrontmatter): string {
|
||||||
|
return frontmatter.title ?? frontmatter.description ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getOpenAPIOperations(): OpenAPIOperation[] {
|
||||||
|
return source
|
||||||
|
.getPages()
|
||||||
|
.filter((page) =>
|
||||||
|
page.url.startsWith("/openapi/") && page.url !== "/openapi"
|
||||||
|
)
|
||||||
|
.map((page) => {
|
||||||
|
if (typeof page.data.content !== "string") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const frontmatter = parseFrontmatter(page.data.content);
|
||||||
|
|
||||||
|
const method = frontmatter._openapi?.method?.toUpperCase();
|
||||||
|
const route = frontmatter._openapi?.route;
|
||||||
|
const summary = normalizeSummary(frontmatter);
|
||||||
|
|
||||||
|
if (!method || !route) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
href: page.url,
|
||||||
|
method,
|
||||||
|
route,
|
||||||
|
summary,
|
||||||
|
} satisfies OpenAPIOperation;
|
||||||
|
})
|
||||||
|
.filter((operation): operation is OpenAPIOperation => Boolean(operation))
|
||||||
|
.sort((a, b) => {
|
||||||
|
const routeCompare = a.route.localeCompare(b.route);
|
||||||
|
if (routeCompare !== 0) {
|
||||||
|
return routeCompare;
|
||||||
|
}
|
||||||
|
|
||||||
|
return a.method.localeCompare(b.method);
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,10 +1,18 @@
|
|||||||
|
import { rmSync } from "node:fs";
|
||||||
|
|
||||||
import { generateFiles } from "fumadocs-openapi";
|
import { generateFiles } from "fumadocs-openapi";
|
||||||
import { openapi } from "@/lib/openapi";
|
import { openapi } from "@/lib/openapi";
|
||||||
|
|
||||||
|
const outputDir = "./content/docs/openapi/(generated)";
|
||||||
|
|
||||||
|
rmSync(outputDir, { recursive: true, force: true });
|
||||||
|
|
||||||
void generateFiles({
|
void generateFiles({
|
||||||
input: openapi,
|
input: openapi,
|
||||||
output: "./content/docs/openapi/(generated)",
|
output: outputDir,
|
||||||
// we recommend to enable it
|
// we recommend to enable it
|
||||||
// make sure your endpoint description doesn't break MDX syntax.
|
// make sure your endpoint description doesn't break MDX syntax.
|
||||||
includeDescription: true,
|
includeDescription: true,
|
||||||
|
per: "operation",
|
||||||
|
groupBy: "route",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -121,6 +121,19 @@ body {
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-icon {
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
/* .vditor {
|
/* .vditor {
|
||||||
--textarea-background-color: transparent;
|
--textarea-background-color: transparent;
|
||||||
border: none !important;
|
border: none !important;
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="timeline" :class="{ 'hover-enabled': hover }">
|
<div class="timeline">
|
||||||
<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"
|
||||||
:class="{ clickable: !!item.iconClick }"
|
:class="{ clickable: !!item.iconClick && !item.src }"
|
||||||
@click="item.iconClick && item.iconClick()"
|
@click="!item.src && item.iconClick && item.iconClick()"
|
||||||
>
|
>
|
||||||
<BaseImage v-if="item.src" :src="item.src" class="timeline-img" alt="timeline item" />
|
<BaseUserAvatar
|
||||||
|
v-if="item.src"
|
||||||
|
:class="['timeline-img', { 'is-clickable': !!item.iconClick }]"
|
||||||
|
:user-id="item.userId"
|
||||||
|
:avatar="item.src"
|
||||||
|
:username="item.userName || item.username"
|
||||||
|
:width="32"
|
||||||
|
:link="!item.iconClick"
|
||||||
|
@click.stop="item.iconClick && item.iconClick()"
|
||||||
|
/>
|
||||||
<component
|
<component
|
||||||
v-else-if="item.icon && (typeof item.icon !== 'string' || !item.icon.includes(' '))"
|
v-else-if="item.icon && (typeof item.icon !== 'string' || !item.icon.includes(' '))"
|
||||||
:is="item.icon"
|
:is="item.icon"
|
||||||
@@ -26,7 +35,6 @@ export default {
|
|||||||
name: 'BaseTimeline',
|
name: 'BaseTimeline',
|
||||||
props: {
|
props: {
|
||||||
items: { type: Array, default: () => [] },
|
items: { type: Array, default: () => [] },
|
||||||
hover: { type: Boolean, default: false },
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -46,12 +54,6 @@ export default {
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hover-enabled .timeline-item:hover {
|
|
||||||
background-color: var(--menu-selected-background-color);
|
|
||||||
transition: background-color 0.2s;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-icon {
|
.timeline-icon {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -71,10 +73,12 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.timeline-img {
|
.timeline-img {
|
||||||
width: 100%;
|
width: 32px;
|
||||||
height: 100%;
|
height: 32px;
|
||||||
object-fit: cover;
|
}
|
||||||
border-radius: 50%;
|
|
||||||
|
.timeline-img.is-clickable {
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-emoji {
|
.timeline-emoji {
|
||||||
@@ -95,7 +99,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.timeline-item:last-child::before {
|
.timeline-item:last-child::before {
|
||||||
display: none;
|
bottom: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-content {
|
.timeline-content {
|
||||||
|
|||||||
116
frontend_nuxt/components/BaseUserAvatar.vue
Normal file
116
frontend_nuxt/components/BaseUserAvatar.vue
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<template>
|
||||||
|
<component :is="wrapperTag" v-bind="wrapperAttrs" :class="containerClass" :style="mergedStyle">
|
||||||
|
<BaseImage :src="currentSrc" :alt="altText" class="base-user-avatar-img" @error="handleError" />
|
||||||
|
</component>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed, ref, watch } from 'vue'
|
||||||
|
import { useAttrs } from 'vue'
|
||||||
|
|
||||||
|
const DEFAULT_AVATAR = '/default-avatar.svg'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
userId: {
|
||||||
|
type: [String, Number],
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
avatar: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
username: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
width: {
|
||||||
|
type: [Number, String],
|
||||||
|
default: 40,
|
||||||
|
},
|
||||||
|
alt: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
link: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const attrs = useAttrs()
|
||||||
|
const currentSrc = ref(props.avatar || DEFAULT_AVATAR)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.avatar,
|
||||||
|
(newVal) => {
|
||||||
|
currentSrc.value = newVal || DEFAULT_AVATAR
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
const wrapperTag = computed(() => (props.link ? 'NuxtLink' : 'div'))
|
||||||
|
const sizeStyle = computed(() => {
|
||||||
|
const value = typeof props.width === 'number' ? `${props.width}px` : props.width || '40px'
|
||||||
|
return {
|
||||||
|
width: value,
|
||||||
|
height: value,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const altText = computed(() => {
|
||||||
|
if (props.alt) return props.alt
|
||||||
|
if (props.username) return `${props.username}的头像`
|
||||||
|
return '用户头像'
|
||||||
|
})
|
||||||
|
|
||||||
|
const containerClass = computed(() => {
|
||||||
|
const classes = ['base-user-avatar']
|
||||||
|
if (props.link) classes.push('is-link')
|
||||||
|
if (attrs.class) classes.push(attrs.class)
|
||||||
|
return classes
|
||||||
|
})
|
||||||
|
|
||||||
|
const mergedStyle = computed(() => {
|
||||||
|
if (!attrs.style) return sizeStyle.value
|
||||||
|
return [sizeStyle.value, attrs.style]
|
||||||
|
})
|
||||||
|
|
||||||
|
const wrapperAttrs = computed(() => {
|
||||||
|
const { class: _class, style: _style, ...rest } = attrs
|
||||||
|
if (props.link) {
|
||||||
|
return {
|
||||||
|
...rest,
|
||||||
|
to: `/users/${props.userId}`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rest
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleError() {
|
||||||
|
if (currentSrc.value !== DEFAULT_AVATAR) {
|
||||||
|
currentSrc.value = DEFAULT_AVATAR
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.base-user-avatar {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: var(--avatar-background, rgba(0, 0, 0, 0.05));
|
||||||
|
}
|
||||||
|
|
||||||
|
.base-user-avatar.is-link {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.base-user-avatar-img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
发布评论
|
发布评论
|
||||||
<span class="shortcut-icon" v-if="!isMobile"> {{ isMac ? '⌘' : 'Ctrl' }} ⏎ </span>
|
<span class="shortcut-icon" v-if="!isMobile"> {{ isMac ? '⌘' : 'Ctrl' }} ⏎ </span>
|
||||||
</template>
|
</template>
|
||||||
<template v-else> <loading-four /> 发布中... </template>
|
<template v-else> <loading-four class="loading-icon" /> 发布中... </template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -26,10 +26,14 @@
|
|||||||
<span v-if="level >= 2" class="reply-item">
|
<span v-if="level >= 2" class="reply-item">
|
||||||
<next class="reply-icon" />
|
<next class="reply-icon" />
|
||||||
<span class="reply-info">
|
<span class="reply-info">
|
||||||
<BaseImage
|
<BaseUserAvatar
|
||||||
|
v-if="comment.parentUserName"
|
||||||
class="reply-avatar"
|
class="reply-avatar"
|
||||||
:src="comment.parentUserAvatar || '/default-avatar.svg'"
|
:user-id="comment.parentUserId"
|
||||||
alt="avatar"
|
:avatar="comment.parentUserAvatar"
|
||||||
|
:username="comment.parentUserName"
|
||||||
|
:width="20"
|
||||||
|
:link="Boolean(comment.parentUserId)"
|
||||||
@click="comment.parentUserClick && comment.parentUserClick()"
|
@click="comment.parentUserClick && comment.parentUserClick()"
|
||||||
/>
|
/>
|
||||||
<span class="reply-user-name">{{ comment.parentUserName }}</span>
|
<span class="reply-user-name">{{ comment.parentUserName }}</span>
|
||||||
@@ -253,16 +257,19 @@ const submitReply = async (parentUserName, text, clear) => {
|
|||||||
replyList.push({
|
replyList.push({
|
||||||
id: data.id,
|
id: data.id,
|
||||||
userName: data.author.username,
|
userName: data.author.username,
|
||||||
|
userId: data.author.id,
|
||||||
time: TimeManager.format(data.createdAt),
|
time: TimeManager.format(data.createdAt),
|
||||||
avatar: data.author.avatar,
|
avatar: data.author.avatar,
|
||||||
medal: data.author.displayMedal,
|
medal: data.author.displayMedal,
|
||||||
text: data.content,
|
text: data.content,
|
||||||
parentUserName: parentUserName,
|
parentUserName: parentUserName,
|
||||||
parentUserAvatar: props.comment.avatar,
|
parentUserAvatar: props.comment.avatar,
|
||||||
|
parentUserId: props.comment.userId,
|
||||||
reactions: [],
|
reactions: [],
|
||||||
reply: (data.replies || []).map((r) => ({
|
reply: (data.replies || []).map((r) => ({
|
||||||
id: r.id,
|
id: r.id,
|
||||||
userName: r.author.username,
|
userName: r.author.username,
|
||||||
|
userId: r.author.id,
|
||||||
time: TimeManager.format(r.createdAt),
|
time: TimeManager.format(r.createdAt),
|
||||||
avatar: r.author.avatar,
|
avatar: r.author.avatar,
|
||||||
text: r.content,
|
text: r.content,
|
||||||
@@ -394,9 +401,7 @@ const handleContentClick = (e) => {
|
|||||||
.reply-avatar {
|
.reply-avatar {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
border-radius: 50%;
|
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.reply-icon {
|
.reply-icon {
|
||||||
|
|||||||
@@ -70,7 +70,14 @@
|
|||||||
<DropdownMenu v-if="isLogin" ref="userMenu" :items="headerMenuItems">
|
<DropdownMenu v-if="isLogin" ref="userMenu" :items="headerMenuItems">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<div class="avatar-container">
|
<div class="avatar-container">
|
||||||
<img class="avatar-img" :src="avatar" alt="avatar" />
|
<BaseUserAvatar
|
||||||
|
class="avatar-img"
|
||||||
|
:user-id="authState.userId"
|
||||||
|
:avatar="avatar"
|
||||||
|
:username="authState.username"
|
||||||
|
:width="32"
|
||||||
|
:link="false"
|
||||||
|
/>
|
||||||
<down />
|
<down />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -434,7 +441,6 @@ onMounted(async () => {
|
|||||||
height: 32px;
|
height: 32px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background-color: lightgray;
|
background-color: lightgray;
|
||||||
object-fit: cover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-icon {
|
.dropdown-icon {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
发送
|
发送
|
||||||
<span class="shortcut-icon" v-if="!isMobile"> {{ isMac ? '⌘' : 'Ctrl' }} ⏎ </span>
|
<span class="shortcut-icon" v-if="!isMobile"> {{ isMac ? '⌘' : 'Ctrl' }} ⏎ </span>
|
||||||
</template>
|
</template>
|
||||||
<template v-else> <loading-four /> 发送中... </template>
|
<template v-else> <loading-four class="loading-icon" /> 发送中... </template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :id="`change-log-${log.id}`" class="change-log-container">
|
<div :id="`change-log-${log.id}`" class="change-log-container">
|
||||||
<div class="change-log-text">
|
<div class="change-log-text">
|
||||||
<BaseImage
|
<BaseUserAvatar
|
||||||
v-if="log.userAvatar"
|
v-if="log.userAvatar"
|
||||||
class="change-log-avatar"
|
class="change-log-avatar"
|
||||||
:src="log.userAvatar"
|
:user-id="log.userId"
|
||||||
alt="avatar"
|
:avatar="log.userAvatar"
|
||||||
@click="() => navigateTo(`/users/${log.username}`)"
|
:username="log.username"
|
||||||
|
:width="20"
|
||||||
/>
|
/>
|
||||||
<span v-if="log.username" class="change-log-user">{{ log.username }}</span>
|
<span v-if="log.username" class="change-log-user">{{ log.username }}</span>
|
||||||
<span v-if="log.type === 'CONTENT'" class="change-log-content">变更了文章内容</span>
|
<span v-if="log.type === 'CONTENT'" class="change-log-content">变更了文章内容</span>
|
||||||
@@ -57,8 +58,6 @@ import { html } from 'diff2html'
|
|||||||
import { createTwoFilesPatch } from 'diff'
|
import { createTwoFilesPatch } from 'diff'
|
||||||
import { useIsMobile } from '~/utils/screen'
|
import { useIsMobile } from '~/utils/screen'
|
||||||
import 'diff2html/bundles/css/diff2html.min.css'
|
import 'diff2html/bundles/css/diff2html.min.css'
|
||||||
import BaseImage from '~/components/BaseImage.vue'
|
|
||||||
import { navigateTo } from 'nuxt/app'
|
|
||||||
import { themeState } from '~/utils/theme'
|
import { themeState } from '~/utils/theme'
|
||||||
import ArticleCategory from '~/components/ArticleCategory.vue'
|
import ArticleCategory from '~/components/ArticleCategory.vue'
|
||||||
import ArticleTags from '~/components/ArticleTags.vue'
|
import ArticleTags from '~/components/ArticleTags.vue'
|
||||||
|
|||||||
@@ -53,24 +53,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="prize-member-container">
|
<div class="prize-member-container">
|
||||||
<BaseImage
|
<BaseUserAvatar
|
||||||
v-for="p in lotteryParticipants"
|
v-for="p in lotteryParticipants"
|
||||||
:key="p.id"
|
:key="p.id"
|
||||||
class="prize-member-avatar"
|
class="prize-member-avatar"
|
||||||
:src="p.avatar"
|
:user-id="p.id"
|
||||||
alt="avatar"
|
:avatar="p.avatar"
|
||||||
@click="gotoUser(p.id)"
|
:username="p.username"
|
||||||
|
:width="30"
|
||||||
/>
|
/>
|
||||||
<div v-if="lotteryEnded && lotteryWinners.length" class="prize-member-winner">
|
<div v-if="lotteryEnded && lotteryWinners.length" class="prize-member-winner">
|
||||||
<medal-one class="medal-icon"></medal-one>
|
<medal-one class="medal-icon"></medal-one>
|
||||||
<span class="prize-member-winner-name">获奖者: </span>
|
<span class="prize-member-winner-name">获奖者: </span>
|
||||||
<BaseImage
|
<BaseUserAvatar
|
||||||
v-for="w in lotteryWinners"
|
v-for="w in lotteryWinners"
|
||||||
:key="w.id"
|
:key="w.id"
|
||||||
class="prize-member-avatar"
|
class="prize-member-avatar"
|
||||||
:src="w.avatar"
|
:user-id="w.id"
|
||||||
alt="avatar"
|
:avatar="w.avatar"
|
||||||
@click="gotoUser(w.id)"
|
:username="w.username"
|
||||||
|
:width="30"
|
||||||
/>
|
/>
|
||||||
<div v-if="lotteryWinners.length === 1" class="prize-member-winner-name">
|
<div v-if="lotteryWinners.length === 1" class="prize-member-winner-name">
|
||||||
{{ lotteryWinners[0].username }}
|
{{ lotteryWinners[0].username }}
|
||||||
@@ -106,8 +108,6 @@ const hasJoined = computed(() => {
|
|||||||
return lotteryParticipants.value.some((p) => p.id === Number(authState.userId))
|
return lotteryParticipants.value.some((p) => p.id === Number(authState.userId))
|
||||||
})
|
})
|
||||||
|
|
||||||
const gotoUser = (id) => navigateTo(`/users/${id}`, { replace: true })
|
|
||||||
|
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
const API_BASE_URL = config.public.apiBaseUrl
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const joinLottery = async () => {
|
const joinLottery = async () => {
|
||||||
@@ -246,8 +246,6 @@ const joinLottery = async () => {
|
|||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
margin-left: 3px;
|
margin-left: 3px;
|
||||||
border-radius: 50%;
|
|
||||||
object-fit: cover;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,14 @@
|
|||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="poll-participants">
|
<div class="poll-participants">
|
||||||
<BaseImage
|
<BaseUserAvatar
|
||||||
v-for="p in pollOptionParticipants[idx] || []"
|
v-for="p in pollOptionParticipants[idx] || []"
|
||||||
:key="p.id"
|
:key="p.id"
|
||||||
class="poll-participant-avatar"
|
class="poll-participant-avatar"
|
||||||
:src="p.avatar"
|
:user-id="p.id"
|
||||||
alt="avatar"
|
:avatar="p.avatar"
|
||||||
@click="gotoUser(p.id)"
|
:username="p.username"
|
||||||
|
:width="30"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -152,8 +153,6 @@ watch([hasVoted, pollEnded], ([voted, ended]) => {
|
|||||||
if (voted || ended) showPollResult.value = true
|
if (voted || ended) showPollResult.value = true
|
||||||
})
|
})
|
||||||
|
|
||||||
const gotoUser = (id) => navigateTo(`/users/${id}`, { replace: true })
|
|
||||||
|
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
const API_BASE_URL = config.public.apiBaseUrl
|
const API_BASE_URL = config.public.apiBaseUrl
|
||||||
const voteOption = async (idx) => {
|
const voteOption = async (idx) => {
|
||||||
@@ -426,7 +425,6 @@ const submitMultiPoll = async () => {
|
|||||||
.poll-participant-avatar {
|
.poll-participant-avatar {
|
||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
border-radius: 50%;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,168 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="timeline-container">
|
|
||||||
<div class="timeline-header">
|
|
||||||
<div class="timeline-title">{{ headerText }}</div>
|
|
||||||
<div class="timeline-date">{{ headerDate }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="comment-content">
|
|
||||||
<div v-for="entry in entries" :key="entry.comment.id" class="comment-content-item">
|
|
||||||
<div class="comment-content-item-main">
|
|
||||||
<comment-one class="comment-content-item-icon" />
|
|
||||||
<template v-if="!entry.comment.parentComment">
|
|
||||||
<span class="comment-prefix">
|
|
||||||
在
|
|
||||||
<NuxtLink :to="entry.postLink" class="timeline-link">
|
|
||||||
{{ entry.comment.post.title }}
|
|
||||||
</NuxtLink>
|
|
||||||
下评论了
|
|
||||||
</span>
|
|
||||||
<NuxtLink :to="entry.commentLink" class="timeline-comment-link">
|
|
||||||
{{ stripContent(entry.comment.content) }}
|
|
||||||
</NuxtLink>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span class="comment-prefix">
|
|
||||||
在
|
|
||||||
<NuxtLink :to="entry.postLink" class="timeline-link">
|
|
||||||
{{ entry.comment.post.title }}
|
|
||||||
</NuxtLink>
|
|
||||||
下对
|
|
||||||
<NuxtLink :to="entry.parentLink" class="timeline-link">
|
|
||||||
{{ stripContent(entry.comment.parentComment.content) }}
|
|
||||||
</NuxtLink>
|
|
||||||
回复了
|
|
||||||
</span>
|
|
||||||
<NuxtLink :to="entry.commentLink" class="timeline-comment-link">
|
|
||||||
{{ stripContent(entry.comment.content) }}
|
|
||||||
</NuxtLink>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
<div class="timeline-date">{{ formatDate(entry.createdAt) }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { computed } from 'vue'
|
|
||||||
import { stripMarkdownLength } from '~/utils/markdown'
|
|
||||||
import TimeManager from '~/utils/time'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
item: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const entries = computed(() =>
|
|
||||||
(props.item.entries || []).map((entry) => ({
|
|
||||||
...entry,
|
|
||||||
postLink: `/posts/${entry.comment.post.id}`,
|
|
||||||
commentLink: `/posts/${entry.comment.post.id}#comment-${entry.comment.id}`,
|
|
||||||
parentLink: entry.comment.parentComment
|
|
||||||
? `/posts/${entry.comment.post.id}#comment-${entry.comment.parentComment.id}`
|
|
||||||
: undefined,
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
|
|
||||||
const commentCount = computed(
|
|
||||||
() => entries.value.filter((entry) => !entry.comment.parentComment).length,
|
|
||||||
)
|
|
||||||
|
|
||||||
const replyCount = computed(
|
|
||||||
() => entries.value.filter((entry) => entry.comment.parentComment).length,
|
|
||||||
)
|
|
||||||
|
|
||||||
const headerText = computed(() => {
|
|
||||||
if (commentCount.value && replyCount.value) {
|
|
||||||
return `发布了${commentCount.value}条评论和${replyCount.value}条回复`
|
|
||||||
}
|
|
||||||
if (commentCount.value) {
|
|
||||||
return `发布了${commentCount.value}条评论`
|
|
||||||
}
|
|
||||||
if (replyCount.value) {
|
|
||||||
return `发布了${replyCount.value}条回复`
|
|
||||||
}
|
|
||||||
return '发布了评论'
|
|
||||||
})
|
|
||||||
|
|
||||||
const headerDate = computed(() => TimeManager.format(props.item.createdAt))
|
|
||||||
|
|
||||||
const formatDate = (date) => TimeManager.format(date)
|
|
||||||
|
|
||||||
const stripContent = (content) => stripMarkdownLength(content || '', 200)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.timeline-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-title {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-date {
|
|
||||||
color: var(--text-color-secondary);
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comment-content {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comment-content-item {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comment-content-item-main {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comment-content-item-icon {
|
|
||||||
color: var(--primary-color);
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comment-prefix {
|
|
||||||
color: var(--text-color-secondary);
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-comment-link {
|
|
||||||
display: inline-flex;
|
|
||||||
gap: 6px;
|
|
||||||
align-items: center;
|
|
||||||
color: var(--text-color);
|
|
||||||
font-size: 15px;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-comment-link:hover {
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-link {
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-link:hover {
|
|
||||||
color: var(--primary-color-hover);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="timeline-container">
|
|
||||||
<div class="timeline-header">
|
|
||||||
<div class="timeline-title">发布了文章</div>
|
|
||||||
<div class="timeline-date">{{ formattedDate }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="article-container">
|
|
||||||
<NuxtLink :to="postLink" class="timeline-article-link">
|
|
||||||
{{ props.item.post.title }}
|
|
||||||
</NuxtLink>
|
|
||||||
<div class="timeline-snippet">
|
|
||||||
{{ postSnippet }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { computed } from 'vue'
|
|
||||||
import { stripMarkdown } from '~/utils/markdown'
|
|
||||||
import TimeManager from '~/utils/time'
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
item: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const formattedDate = computed(() => TimeManager.format(props.item.createdAt))
|
|
||||||
const postLink = computed(() => `/posts/${props.item.post.id}`)
|
|
||||||
const postSnippet = computed(() => stripMarkdown(props.item.post?.snippet ?? ''))
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.timeline-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-title {
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-date {
|
|
||||||
color: var(--text-color-secondary);
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-article-link {
|
|
||||||
font-size: 18px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-article-link:hover {
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-snippet {
|
|
||||||
color: var(--text-color-secondary);
|
|
||||||
font-size: 14px;
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -24,10 +24,13 @@
|
|||||||
</template>
|
</template>
|
||||||
<template #option="{ option }">
|
<template #option="{ option }">
|
||||||
<div class="search-option-item">
|
<div class="search-option-item">
|
||||||
<BaseImage
|
<BaseUserAvatar
|
||||||
:src="option.avatar || '/default-avatar.svg'"
|
|
||||||
class="avatar"
|
class="avatar"
|
||||||
@error="handleAvatarError"
|
:user-id="option.id"
|
||||||
|
:avatar="option.avatar"
|
||||||
|
:username="option.username"
|
||||||
|
:width="32"
|
||||||
|
:link="false"
|
||||||
/>
|
/>
|
||||||
<div class="result-body">
|
<div class="result-body">
|
||||||
<div class="result-main" v-html="highlight(option.username)"></div>
|
<div class="result-main" v-html="highlight(option.username)"></div>
|
||||||
@@ -87,10 +90,6 @@ const highlight = (text) => {
|
|||||||
return text.replace(reg, (m) => `<span class="highlight">${m}</span>`)
|
return text.replace(reg, (m) => `<span class="highlight">${m}</span>`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleAvatarError = (e) => {
|
|
||||||
e.target.src = '/default-avatar.svg'
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(selected, async (val) => {
|
watch(selected, async (val) => {
|
||||||
if (!val) return
|
if (!val) return
|
||||||
const user = results.value.find((u) => u.id === val)
|
const user = results.value.find((u) => u.id === val)
|
||||||
@@ -178,8 +177,6 @@ defineExpose({
|
|||||||
.avatar {
|
.avatar {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
border-radius: 50%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.result-body {
|
.result-body {
|
||||||
|
|||||||
167
frontend_nuxt/components/TimelineCommentGroup.vue
Normal file
167
frontend_nuxt/components/TimelineCommentGroup.vue
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
<template>
|
||||||
|
<div class="timeline-container">
|
||||||
|
<div class="timeline-header">
|
||||||
|
<div class="timeline-title">{{ headerText }}</div>
|
||||||
|
<div class="timeline-date">{{ formattedDate }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="comment-content" v-if="entries.length > 0">
|
||||||
|
<div class="comment-content-item" v-for="entry in entries" :key="entry.comment.id">
|
||||||
|
<div class="comment-content-item-main">
|
||||||
|
<comment-one class="comment-content-item-icon" />
|
||||||
|
<div class="comment-content-item-text">
|
||||||
|
<NuxtLink
|
||||||
|
:to="`/posts/${entry.comment.post.id}#comment-${entry.comment.id}`"
|
||||||
|
class="timeline-comment-link"
|
||||||
|
>
|
||||||
|
{{ stripContent(entry.comment.content) }}
|
||||||
|
</NuxtLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="timeline-date">{{ formatEntryDate(entry.createdAt) }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { stripMarkdownLength } from '~/utils/markdown'
|
||||||
|
import TimeManager from '~/utils/time'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
item: { type: Object, required: true },
|
||||||
|
})
|
||||||
|
|
||||||
|
const entries = computed(() => {
|
||||||
|
if (Array.isArray(props.item.entries)) {
|
||||||
|
return props.item.entries
|
||||||
|
}
|
||||||
|
if (props.item.comment) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: props.item.type,
|
||||||
|
comment: props.item.comment,
|
||||||
|
createdAt: props.item.createdAt,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
})
|
||||||
|
|
||||||
|
const formattedDate = computed(() => TimeManager.formatWithDay(props.item.createdAt))
|
||||||
|
|
||||||
|
const hasReplies = computed(() => entries.value.some((entry) => !!entry.comment.parentComment))
|
||||||
|
const hasComments = computed(() => entries.value.some((entry) => !entry.comment.parentComment))
|
||||||
|
|
||||||
|
const headerText = computed(() => {
|
||||||
|
const count = entries.value.length
|
||||||
|
if (count === 0) return ''
|
||||||
|
if (hasComments.value && hasReplies.value) {
|
||||||
|
return `发布了${count}条评论/回复`
|
||||||
|
}
|
||||||
|
if (hasReplies.value) {
|
||||||
|
return `发布了${count}条回复`
|
||||||
|
}
|
||||||
|
return `发布了${count}条评论`
|
||||||
|
})
|
||||||
|
|
||||||
|
const formatEntryDate = (date) => TimeManager.format(date)
|
||||||
|
const stripContent = (content) => stripMarkdownLength(content ?? '', 200)
|
||||||
|
const parentSnippet = (entry) =>
|
||||||
|
stripMarkdownLength(entry.comment.parentComment?.content ?? '', 200)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.timeline-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-date {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--timeline-date-color, #888);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-content-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-content-item:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-content-item-main {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-content-item-icon {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 18px;
|
||||||
|
height: 18px;
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-content-item-text {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-content-item-prefix {
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-comment-link {
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--link-color);
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-comment-link:hover {
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-link {
|
||||||
|
color: var(--link-color);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.comment-content-item-prefix,
|
||||||
|
.timeline-comment-link {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
147
frontend_nuxt/components/TimelinePostItem.vue
Normal file
147
frontend_nuxt/components/TimelinePostItem.vue
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
<template>
|
||||||
|
<div class="timeline-container">
|
||||||
|
<div class="timeline-header">
|
||||||
|
<div class="timeline-title">发布了文章</div>
|
||||||
|
<div class="timeline-date">{{ formattedDate }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="article-container">
|
||||||
|
<NuxtLink :to="postLink" class="timeline-article-link">
|
||||||
|
{{ item.post?.title }}
|
||||||
|
</NuxtLink>
|
||||||
|
<div class="timeline-snippet">
|
||||||
|
{{ strippedSnippet }}
|
||||||
|
</div>
|
||||||
|
<div class="article-meta" v-if="hasMeta">
|
||||||
|
<ArticleCategory v-if="item.post?.category" :category="item.post.category" />
|
||||||
|
<ArticleTags :tags="item.post?.tags" />
|
||||||
|
<div class="article-comment-count" v-if="item.post?.commentCount !== undefined">
|
||||||
|
<comment-one class="article-comment-count-icon" />
|
||||||
|
<span>{{ item.post?.commentCount }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import { stripMarkdown } from '~/utils/markdown'
|
||||||
|
import TimeManager from '~/utils/time'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
item: { type: Object, required: true },
|
||||||
|
})
|
||||||
|
|
||||||
|
const postLink = computed(() => {
|
||||||
|
const id = props.item.post?.id
|
||||||
|
return id ? `/posts/${id}` : '#'
|
||||||
|
})
|
||||||
|
|
||||||
|
const formattedDate = computed(() => TimeManager.format(props.item.createdAt))
|
||||||
|
const strippedSnippet = computed(() => stripMarkdown(props.item.post?.snippet ?? ''))
|
||||||
|
const hasMeta = computed(() => {
|
||||||
|
const tags = props.item.post?.tags ?? []
|
||||||
|
const hasTags = Array.isArray(tags) && tags.length > 0
|
||||||
|
const hasCategory = !!props.item.post?.category
|
||||||
|
const hasCommentCount =
|
||||||
|
props.item.post?.commentCount !== undefined && props.item.post?.commentCount !== null
|
||||||
|
return hasTags || hasCategory || hasCommentCount
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.timeline-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: 5px;
|
||||||
|
gap: 12px;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: var(--timeline-card-background, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-date {
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--timeline-date-color, #888);
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
border: 1px solid var(--normal-border-color);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-article-link {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--link-color);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-article-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-snippet {
|
||||||
|
color: var(--timeline-snippet-color, #666);
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-meta {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-tags {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-tag {
|
||||||
|
background-color: var(--article-info-background-color);
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 2px 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-comment-count {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-comment-count-icon {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.timeline-article-link {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-snippet {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
111
frontend_nuxt/components/TimelineTagItem.vue
Normal file
111
frontend_nuxt/components/TimelineTagItem.vue
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<template>
|
||||||
|
<div class="timeline-tag-item">
|
||||||
|
<div class="tags-container">
|
||||||
|
<div class="tags-container-item">
|
||||||
|
<div class="timeline-tag-title">创建了标签</div>
|
||||||
|
<ArticleTags v-if="tag" :tags="[tag]" />
|
||||||
|
<span class="timeline-tag-count" v-if="tag?.count"> x{{ tag.count }}</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="timelineDate" class="timeline-date">{{ timelineDate }}</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="hasDescription" class="timeline-snippet">
|
||||||
|
{{ tag?.description }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed } from 'vue'
|
||||||
|
import TimeManager from '~/utils/time'
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
item: { type: Object, required: true },
|
||||||
|
})
|
||||||
|
|
||||||
|
const emit = defineEmits(['tag-click'])
|
||||||
|
|
||||||
|
const tag = computed(() => props.item?.tag ?? null)
|
||||||
|
const hasDescription = computed(() => {
|
||||||
|
const description = tag.value?.description
|
||||||
|
return !!description
|
||||||
|
})
|
||||||
|
|
||||||
|
const timelineDate = computed(() => {
|
||||||
|
const date = props.item?.createdAt ?? tag.value?.createdAt
|
||||||
|
return date ? TimeManager.format(date) : ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const summaryDate = computed(() => {
|
||||||
|
const date = tag.value?.createdAt ?? props.item?.createdAt
|
||||||
|
return date ? TimeManager.format(date) : ''
|
||||||
|
})
|
||||||
|
|
||||||
|
const isClickable = computed(() => props.mode === 'summary' && !!tag.value)
|
||||||
|
|
||||||
|
const handleTagClick = () => {
|
||||||
|
if (!isClickable.value) return
|
||||||
|
emit('tag-click', tag.value)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.timeline-tag-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 10px;
|
||||||
|
padding-top: 5px;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-container-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 5px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-tag-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-tag-count {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-date {
|
||||||
|
font-size: 12px;
|
||||||
|
color: gray;
|
||||||
|
margin-top: 5px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-snippet {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #666;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-link {
|
||||||
|
font-weight: bold;
|
||||||
|
color: var(--primary-color);
|
||||||
|
text-decoration: none;
|
||||||
|
word-break: break-word;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-link.clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-link.clickable:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,7 +2,14 @@
|
|||||||
<div class="user-list">
|
<div class="user-list">
|
||||||
<BasePlaceholder v-if="users.length === 0" text="暂无用户" icon="inbox" />
|
<BasePlaceholder v-if="users.length === 0" text="暂无用户" icon="inbox" />
|
||||||
<div v-for="u in users" :key="u.id" class="user-item" @click="handleUserClick(u)">
|
<div v-for="u in users" :key="u.id" class="user-item" @click="handleUserClick(u)">
|
||||||
<BaseImage :src="u.avatar" alt="avatar" class="user-avatar" />
|
<BaseUserAvatar
|
||||||
|
class="user-avatar"
|
||||||
|
:user-id="u.id"
|
||||||
|
:avatar="u.avatar"
|
||||||
|
:username="u.username"
|
||||||
|
:width="50"
|
||||||
|
:link="false"
|
||||||
|
/>
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<div class="user-name">{{ u.username }}</div>
|
<div class="user-name">{{ u.username }}</div>
|
||||||
<div v-if="u.introduction" class="user-intro">{{ u.introduction }}</div>
|
<div v-if="u.introduction" class="user-intro">{{ u.introduction }}</div>
|
||||||
@@ -27,21 +34,21 @@ const handleUserClick = (user) => {
|
|||||||
.user-list {
|
.user-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
|
||||||
}
|
}
|
||||||
.user-item {
|
.user-item {
|
||||||
|
padding-top: 20px;
|
||||||
|
padding-bottom: 20px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
border-bottom: 1px solid var(--normal-border-color);
|
||||||
}
|
}
|
||||||
.user-avatar {
|
.user-avatar {
|
||||||
width: 40px;
|
width: 50px;
|
||||||
height: 40px;
|
height: 50px;
|
||||||
border-radius: 50%;
|
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
object-fit: cover;
|
|
||||||
}
|
}
|
||||||
.user-info {
|
.user-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -18,7 +18,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="about-api-title">API文档和调试入口</div>
|
<div class="about-api-title">API文档和调试入口</div>
|
||||||
<div class="about-api-link">API Playground <share /></div>
|
<a href="http://docs.open-isle.com" target="_blank" rel="noopener" class="about-api-link">
|
||||||
|
API 文档与 Playground <share />
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
@@ -233,6 +235,7 @@ export default {
|
|||||||
.about-api-link {
|
.about-api-link {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.about-api-link:hover {
|
.about-api-link:hover {
|
||||||
|
|||||||
@@ -85,14 +85,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="article-member-avatars-container">
|
<div class="article-member-avatars-container">
|
||||||
<NuxtLink
|
<BaseUserAvatar
|
||||||
v-for="member in article.members"
|
v-for="member in article.members"
|
||||||
:key="`${article.id}-${member.id}`"
|
:key="`${article.id}-${member.id}`"
|
||||||
class="article-member-avatar-item"
|
class="article-member-avatar-item"
|
||||||
:to="`/users/${member.id}`"
|
:user-id="member.id"
|
||||||
>
|
:avatar="member.avatar"
|
||||||
<BaseImage class="article-member-avatar-item-img" :src="member.avatar" alt="avatar" />
|
:username="member.username"
|
||||||
</NuxtLink>
|
:width="25"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="article-comments main-info-text">
|
<div class="article-comments main-info-text">
|
||||||
@@ -291,7 +292,11 @@ const {
|
|||||||
description: p.content,
|
description: p.content,
|
||||||
category: p.category,
|
category: p.category,
|
||||||
tags: p.tags || [],
|
tags: p.tags || [],
|
||||||
members: (p.participants || []).map((m) => ({ id: m.id, avatar: m.avatar })),
|
members: (p.participants || []).map((m) => ({
|
||||||
|
id: m.id,
|
||||||
|
avatar: m.avatar,
|
||||||
|
username: m.username,
|
||||||
|
})),
|
||||||
comments: p.commentCount,
|
comments: p.commentCount,
|
||||||
views: p.views,
|
views: p.views,
|
||||||
rssExcluded: p.rssExcluded || false,
|
rssExcluded: p.rssExcluded || false,
|
||||||
@@ -333,7 +338,11 @@ const fetchNextPage = async () => {
|
|||||||
description: p.content,
|
description: p.content,
|
||||||
category: p.category,
|
category: p.category,
|
||||||
tags: p.tags || [],
|
tags: p.tags || [],
|
||||||
members: (p.participants || []).map((m) => ({ id: m.id, avatar: m.avatar })),
|
members: (p.participants || []).map((m) => ({
|
||||||
|
id: m.id,
|
||||||
|
avatar: m.avatar,
|
||||||
|
username: m.username,
|
||||||
|
})),
|
||||||
comments: p.commentCount,
|
comments: p.commentCount,
|
||||||
views: p.views,
|
views: p.views,
|
||||||
rssExcluded: p.rssExcluded || false,
|
rssExcluded: p.rssExcluded || false,
|
||||||
@@ -383,7 +392,6 @@ watch([selectedCategory, selectedTags], ([newCategory, newTags]) => {
|
|||||||
selectedCategoryGlobal.value = newCategory
|
selectedCategoryGlobal.value = newCategory
|
||||||
selectedTagsGlobal.value = newTags
|
selectedTagsGlobal.value = newTags
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@@ -631,14 +639,7 @@ watch([selectedCategory, selectedTags], ([newCategory, newTags]) => {
|
|||||||
.article-member-avatar-item {
|
.article-member-avatar-item {
|
||||||
width: 25px;
|
width: 25px;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
border-radius: 50%;
|
flex-shrink: 0;
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.article-member-avatar-item-img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.placeholder-container {
|
.placeholder-container {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
<div v-else class="login-page-button-primary disabled">
|
<div v-else class="login-page-button-primary disabled">
|
||||||
<div class="login-page-button-text">
|
<div class="login-page-button-text">
|
||||||
<loading-four />
|
<loading-four class="loading-icon" />
|
||||||
登录中...
|
登录中...
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -44,7 +44,13 @@
|
|||||||
<div v-if="item.replyTo" class="reply-preview info-content-text">
|
<div v-if="item.replyTo" class="reply-preview info-content-text">
|
||||||
<div class="reply-header">
|
<div class="reply-header">
|
||||||
<next class="reply-icon" />
|
<next class="reply-icon" />
|
||||||
<BaseImage class="reply-avatar" :src="item.replyTo.sender.avatar" alt="avatar" />
|
<BaseUserAvatar
|
||||||
|
class="reply-avatar"
|
||||||
|
:user-id="item.replyTo.sender.id"
|
||||||
|
:avatar="item.replyTo.sender.avatar"
|
||||||
|
:username="item.replyTo.sender.username"
|
||||||
|
:width="20"
|
||||||
|
/>
|
||||||
<div class="reply-author">{{ item.replyTo.sender.username }}:</div>
|
<div class="reply-author">{{ item.replyTo.sender.username }}:</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="reply-content" v-html="renderMarkdown(item.replyTo.content)"></div>
|
<div class="reply-content" v-html="renderMarkdown(item.replyTo.content)"></div>
|
||||||
@@ -242,6 +248,8 @@ async function fetchMessages(page = 0) {
|
|||||||
|
|
||||||
const newMessages = pageData.content.reverse().map((item) => ({
|
const newMessages = pageData.content.reverse().map((item) => ({
|
||||||
...item,
|
...item,
|
||||||
|
userId: item.sender.id,
|
||||||
|
userName: item.sender.username,
|
||||||
src: item.sender.avatar,
|
src: item.sender.avatar,
|
||||||
iconClick: () => {
|
iconClick: () => {
|
||||||
openUser(item.sender.id)
|
openUser(item.sender.id)
|
||||||
@@ -327,6 +335,8 @@ async function sendMessage(content, clearInput) {
|
|||||||
const newMessage = await response.json()
|
const newMessage = await response.json()
|
||||||
messages.value.push({
|
messages.value.push({
|
||||||
...newMessage,
|
...newMessage,
|
||||||
|
userId: newMessage.sender.id,
|
||||||
|
userName: newMessage.sender.username,
|
||||||
src: newMessage.sender.avatar,
|
src: newMessage.sender.avatar,
|
||||||
iconClick: () => {
|
iconClick: () => {
|
||||||
openUser(newMessage.sender.id)
|
openUser(newMessage.sender.id)
|
||||||
@@ -402,6 +412,8 @@ const subscribeToConversation = () => {
|
|||||||
|
|
||||||
messages.value.push({
|
messages.value.push({
|
||||||
...parsedMessage,
|
...parsedMessage,
|
||||||
|
userId: parsedMessage.sender.id,
|
||||||
|
userName: parsedMessage.sender.username,
|
||||||
src: parsedMessage.sender.avatar,
|
src: parsedMessage.sender.avatar,
|
||||||
iconClick: () => openUser(parsedMessage.sender.id),
|
iconClick: () => openUser(parsedMessage.sender.id),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -33,11 +33,23 @@
|
|||||||
@click="goToConversation(convo.id)"
|
@click="goToConversation(convo.id)"
|
||||||
>
|
>
|
||||||
<div class="conversation-avatar">
|
<div class="conversation-avatar">
|
||||||
<BaseImage
|
<BaseUserAvatar
|
||||||
:src="getOtherParticipant(convo)?.avatar || '/default-avatar.svg'"
|
v-if="getOtherParticipant(convo)"
|
||||||
:alt="getOtherParticipant(convo)?.username || '用户'"
|
|
||||||
class="avatar-img"
|
class="avatar-img"
|
||||||
@error="handleAvatarError"
|
:user-id="getOtherParticipant(convo).id"
|
||||||
|
:avatar="getOtherParticipant(convo).avatar"
|
||||||
|
:username="getOtherParticipant(convo).username"
|
||||||
|
:width="40"
|
||||||
|
@click.stop
|
||||||
|
/>
|
||||||
|
<BaseUserAvatar
|
||||||
|
v-else
|
||||||
|
class="avatar-img"
|
||||||
|
:user-id="convo.id"
|
||||||
|
:avatar="''"
|
||||||
|
username="用户"
|
||||||
|
:width="40"
|
||||||
|
:link="false"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -431,7 +443,6 @@ function minimize() {
|
|||||||
width: 40px;
|
width: 40px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
object-fit: cover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.conversation-content {
|
.conversation-content {
|
||||||
|
|||||||
@@ -30,7 +30,9 @@
|
|||||||
>
|
>
|
||||||
发布
|
发布
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="post-submit-loading"><loading-four /> 发布中...</div>
|
<div v-else class="post-submit-loading">
|
||||||
|
<loading-four class="loading-icon" /> 发布中...
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<LotteryForm v-if="postType === 'LOTTERY'" :data="lottery" />
|
<LotteryForm v-if="postType === 'LOTTERY'" :data="lottery" />
|
||||||
|
|||||||
@@ -26,7 +26,9 @@
|
|||||||
>
|
>
|
||||||
更新
|
更新
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="post-submit-loading"><loading-four /> 更新中...</div>
|
<div v-else class="post-submit-loading">
|
||||||
|
<loading-four class="loading-icon" /> 更新中...
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -46,10 +46,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="info-content-container author-info-container">
|
<div class="info-content-container author-info-container">
|
||||||
<div class="user-avatar-container" @click="gotoProfile">
|
<div class="user-avatar-container">
|
||||||
<div class="user-avatar-item">
|
<BaseUserAvatar
|
||||||
<BaseImage class="user-avatar-item-img" :src="author.avatar" alt="avatar" />
|
class="user-avatar-item"
|
||||||
</div>
|
:user-id="author.id"
|
||||||
|
:avatar="author.avatar"
|
||||||
|
:username="author.username"
|
||||||
|
:width="50"
|
||||||
|
/>
|
||||||
<div v-if="isMobile" class="info-content-header">
|
<div v-if="isMobile" class="info-content-header">
|
||||||
<div class="user-name">
|
<div class="user-name">
|
||||||
{{ author.username }}
|
{{ author.username }}
|
||||||
@@ -340,6 +344,7 @@ const mapComment = (
|
|||||||
iconClick: () => navigateTo(`/users/${c.author.id}`),
|
iconClick: () => navigateTo(`/users/${c.author.id}`),
|
||||||
parentUserName: parentUserName,
|
parentUserName: parentUserName,
|
||||||
parentUserAvatar: parentUserAvatar,
|
parentUserAvatar: parentUserAvatar,
|
||||||
|
parentUserId: parentUserId,
|
||||||
parentUserClick: parentUserId ? () => navigateTo(`/users/${parentUserId}`) : null,
|
parentUserClick: parentUserId ? () => navigateTo(`/users/${parentUserId}`) : null,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -379,6 +384,7 @@ const mapChangeLog = (l) => ({
|
|||||||
id: l.id,
|
id: l.id,
|
||||||
kind: 'log',
|
kind: 'log',
|
||||||
username: l.username,
|
username: l.username,
|
||||||
|
userId: l.userId ?? l.username,
|
||||||
userAvatar: l.userAvatar,
|
userAvatar: l.userAvatar,
|
||||||
type: l.type,
|
type: l.type,
|
||||||
createdAt: l.time,
|
createdAt: l.time,
|
||||||
@@ -863,10 +869,6 @@ const jumpToHashComment = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const gotoProfile = () => {
|
|
||||||
navigateTo(`/users/${author.value.id}`, { replace: true })
|
|
||||||
}
|
|
||||||
|
|
||||||
const initPage = async () => {
|
const initPage = async () => {
|
||||||
scrollTo(0, 0)
|
scrollTo(0, 0)
|
||||||
await fetchTimeline()
|
await fetchTimeline()
|
||||||
@@ -960,6 +962,8 @@ onMounted(async () => {
|
|||||||
.user-avatar-container {
|
.user-avatar-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroller-middle {
|
.scroller-middle {
|
||||||
@@ -1172,18 +1176,13 @@ onMounted(async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.user-avatar-container {
|
.user-avatar-container {
|
||||||
cursor: pointer;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-avatar-item {
|
.user-avatar-item {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
}
|
flex-shrink: 0;
|
||||||
|
|
||||||
.user-avatar-item-img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 50%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-content {
|
.info-content {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else class="signup-page-button-primary disabled">
|
<div v-else class="signup-page-button-primary disabled">
|
||||||
<div class="signup-page-button-text">
|
<div class="signup-page-button-text">
|
||||||
<loading-four />
|
<loading-four class="loading-icon" />
|
||||||
发送中...
|
发送中...
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else class="signup-page-button-primary disabled">
|
<div v-else class="signup-page-button-primary disabled">
|
||||||
<div class="signup-page-button-text">
|
<div class="signup-page-button-text">
|
||||||
<loading-four />
|
<loading-four class="loading-icon" />
|
||||||
验证中...
|
验证中...
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,13 @@
|
|||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="profile-page-header">
|
<div class="profile-page-header">
|
||||||
<div class="profile-page-header-avatar">
|
<div class="profile-page-header-avatar">
|
||||||
<BaseImage :src="user.avatar" alt="avatar" class="profile-page-header-avatar-img" />
|
<BaseUserAvatar
|
||||||
|
class="profile-page-header-avatar-img"
|
||||||
|
:user-id="user.id"
|
||||||
|
:avatar="user.avatar"
|
||||||
|
:username="user.username"
|
||||||
|
:width="200"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="profile-page-header-user-info">
|
<div class="profile-page-header-user-info">
|
||||||
<div class="profile-page-header-user-info-name">{{ user.username }}</div>
|
<div class="profile-page-header-user-info-name">{{ user.username }}</div>
|
||||||
@@ -112,19 +118,18 @@
|
|||||||
{{ item.comment.post.title }}
|
{{ item.comment.post.title }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<template v-if="item.comment.parentComment">
|
<template v-if="item.comment.parentComment">
|
||||||
下对
|
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
:to="`/posts/${item.comment.post.id}#comment-${item.comment.parentComment.id}`"
|
:to="`/posts/${item.comment.post.id}#comment-${item.comment.parentComment.id}`"
|
||||||
class="timeline-link"
|
class="timeline-comment-link"
|
||||||
>
|
>
|
||||||
{{ stripMarkdownLength(item.comment.parentComment.content, 200) }}
|
{{ stripMarkdownLength(item.comment.parentComment.content, 200) }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
回复了
|
<next class="reply-icon" /> 回复了
|
||||||
</template>
|
</template>
|
||||||
<template v-else> 下评论了 </template>
|
<template v-else> 下评论了 </template>
|
||||||
<NuxtLink
|
<NuxtLink
|
||||||
:to="`/posts/${item.comment.post.id}#comment-${item.comment.id}`"
|
:to="`/posts/${item.comment.post.id}#comment-${item.comment.id}`"
|
||||||
class="timeline-link"
|
class="timeline-comment-link"
|
||||||
>
|
>
|
||||||
{{ stripMarkdownLength(item.comment.content, 200) }}
|
{{ stripMarkdownLength(item.comment.content, 200) }}
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
@@ -143,15 +148,7 @@
|
|||||||
<div class="summary-content" v-if="hotPosts.length > 0">
|
<div class="summary-content" v-if="hotPosts.length > 0">
|
||||||
<BaseTimeline :items="hotPosts">
|
<BaseTimeline :items="hotPosts">
|
||||||
<template #item="{ item }">
|
<template #item="{ item }">
|
||||||
<NuxtLink :to="`/posts/${item.post.id}`" class="timeline-link">
|
<TimelinePostItem :item="item" />
|
||||||
{{ item.post.title }}
|
|
||||||
</NuxtLink>
|
|
||||||
<div class="timeline-snippet">
|
|
||||||
{{ stripMarkdown(item.post.snippet) }}
|
|
||||||
</div>
|
|
||||||
<div class="timeline-date">
|
|
||||||
{{ formatDate(item.post.createdAt) }}
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</BaseTimeline>
|
</BaseTimeline>
|
||||||
</div>
|
</div>
|
||||||
@@ -164,15 +161,7 @@
|
|||||||
<div class="summary-content" v-if="hotTags.length > 0">
|
<div class="summary-content" v-if="hotTags.length > 0">
|
||||||
<BaseTimeline :items="hotTags">
|
<BaseTimeline :items="hotTags">
|
||||||
<template #item="{ item }">
|
<template #item="{ item }">
|
||||||
<span class="timeline-link" @click="gotoTag(item.tag)">
|
<TimelineTagItem :item="item" />
|
||||||
{{ item.tag.name }}<span v-if="item.tag.count"> x{{ item.tag.count }}</span>
|
|
||||||
</span>
|
|
||||||
<div class="timeline-snippet" v-if="item.tag.description">
|
|
||||||
{{ item.tag.description }}
|
|
||||||
</div>
|
|
||||||
<div class="timeline-date">
|
|
||||||
{{ formatDate(item.tag.createdAt) }}
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</BaseTimeline>
|
</BaseTimeline>
|
||||||
</div>
|
</div>
|
||||||
@@ -212,18 +201,17 @@
|
|||||||
<div class="timeline-list">
|
<div class="timeline-list">
|
||||||
<BaseTimeline :items="filteredTimelineItems">
|
<BaseTimeline :items="filteredTimelineItems">
|
||||||
<template #item="{ item }">
|
<template #item="{ item }">
|
||||||
<ProfileTimelinePostItem v-if="item.type === 'post'" :item="item" />
|
<template v-if="item.type === 'post'">
|
||||||
<ProfileTimelineCommentGroup v-else-if="item.type === 'comment'" :item="item" />
|
<TimelinePostItem :item="item" />
|
||||||
<ProfileTimelineCommentGroup v-else-if="item.type === 'reply'" :item="item" />
|
</template>
|
||||||
|
<template v-else-if="item.type === 'comment'">
|
||||||
|
<TimelineCommentGroup :item="item" />
|
||||||
|
</template>
|
||||||
|
<template v-else-if="item.type === 'reply'">
|
||||||
|
<TimelineCommentGroup :item="item" />
|
||||||
|
</template>
|
||||||
<template v-else-if="item.type === 'tag'">
|
<template v-else-if="item.type === 'tag'">
|
||||||
创建了标签
|
<TimelineTagItem :item="item" />
|
||||||
<span class="timeline-link" @click="gotoTag(item.tag)">
|
|
||||||
{{ item.tag.name }}<span v-if="item.tag.count"> x{{ item.tag.count }}</span>
|
|
||||||
</span>
|
|
||||||
<div class="timeline-snippet" v-if="item.tag.description">
|
|
||||||
{{ item.tag.description }}
|
|
||||||
</div>
|
|
||||||
<div class="timeline-date">{{ formatDate(item.createdAt) }}</div>
|
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</BaseTimeline>
|
</BaseTimeline>
|
||||||
@@ -287,8 +275,9 @@ import BasePlaceholder from '~/components/BasePlaceholder.vue'
|
|||||||
import BaseTimeline from '~/components/BaseTimeline.vue'
|
import BaseTimeline from '~/components/BaseTimeline.vue'
|
||||||
import BaseTabs from '~/components/BaseTabs.vue'
|
import BaseTabs from '~/components/BaseTabs.vue'
|
||||||
import LevelProgress from '~/components/LevelProgress.vue'
|
import LevelProgress from '~/components/LevelProgress.vue'
|
||||||
import ProfileTimelineCommentGroup from '~/components/ProfileTimelineCommentGroup.vue'
|
import TimelineCommentGroup from '~/components/TimelineCommentGroup.vue'
|
||||||
import ProfileTimelinePostItem from '~/components/ProfileTimelinePostItem.vue'
|
import TimelinePostItem from '~/components/TimelinePostItem.vue'
|
||||||
|
import TimelineTagItem from '~/components/TimelineTagItem.vue'
|
||||||
import UserList from '~/components/UserList.vue'
|
import UserList from '~/components/UserList.vue'
|
||||||
import { toast } from '~/main'
|
import { toast } from '~/main'
|
||||||
import { authState, getToken } from '~/utils/auth'
|
import { authState, getToken } from '~/utils/auth'
|
||||||
@@ -378,7 +367,12 @@ const fetchSummary = async () => {
|
|||||||
const postsRes = await fetch(`${API_BASE_URL}/api/users/${username}/hot-posts`)
|
const postsRes = await fetch(`${API_BASE_URL}/api/users/${username}/hot-posts`)
|
||||||
if (postsRes.ok) {
|
if (postsRes.ok) {
|
||||||
const data = await postsRes.json()
|
const data = await postsRes.json()
|
||||||
hotPosts.value = data.map((p) => ({ icon: 'file-text', post: p }))
|
hotPosts.value = data.map((p) => ({
|
||||||
|
icon: 'file-text',
|
||||||
|
type: 'post',
|
||||||
|
post: p,
|
||||||
|
createdAt: p.createdAt,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const repliesRes = await fetch(`${API_BASE_URL}/api/users/${username}/hot-replies`)
|
const repliesRes = await fetch(`${API_BASE_URL}/api/users/${username}/hot-replies`)
|
||||||
@@ -390,25 +384,65 @@ const fetchSummary = async () => {
|
|||||||
const tagsRes = await fetch(`${API_BASE_URL}/api/users/${username}/hot-tags`)
|
const tagsRes = await fetch(`${API_BASE_URL}/api/users/${username}/hot-tags`)
|
||||||
if (tagsRes.ok) {
|
if (tagsRes.ok) {
|
||||||
const data = await tagsRes.json()
|
const data = await tagsRes.json()
|
||||||
hotTags.value = data.map((t) => ({ icon: 'tag-one', tag: t }))
|
hotTags.value = data.map((t) => ({
|
||||||
|
icon: 'tag-one',
|
||||||
|
type: 'tag',
|
||||||
|
tag: t,
|
||||||
|
createdAt: t.createdAt,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const isSameDay = (a, b) => {
|
const isDiscussionItem = (item) => item && (item.type === 'comment' || item.type === 'reply')
|
||||||
const dateA = new Date(a)
|
|
||||||
const dateB = new Date(b)
|
const toDateKey = (value) => {
|
||||||
return (
|
const date = new Date(value)
|
||||||
dateA.getFullYear() === dateB.getFullYear() &&
|
if (Number.isNaN(date.getTime())) return ''
|
||||||
dateA.getMonth() === dateB.getMonth() &&
|
const month = `${date.getMonth() + 1}`.padStart(2, '0')
|
||||||
dateA.getDate() === dateB.getDate()
|
const day = `${date.getDate()}`.padStart(2, '0')
|
||||||
)
|
return `${date.getFullYear()}-${month}-${day}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const createCommentEntry = (item) => ({
|
const combineDiscussionItems = (items) => {
|
||||||
type: item.type,
|
const result = []
|
||||||
comment: item.comment,
|
items.forEach((item) => {
|
||||||
createdAt: item.createdAt,
|
if (!isDiscussionItem(item)) {
|
||||||
})
|
result.push(item)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const dateKey = toDateKey(item.createdAt)
|
||||||
|
const last = result[result.length - 1]
|
||||||
|
if (last && isDiscussionItem(last) && last.dateKey === dateKey) {
|
||||||
|
last.entries.push({
|
||||||
|
type: item.type,
|
||||||
|
comment: item.comment,
|
||||||
|
createdAt: item.createdAt,
|
||||||
|
})
|
||||||
|
if (item.type === 'comment' && last.type === 'reply') {
|
||||||
|
last.type = 'comment'
|
||||||
|
}
|
||||||
|
if (new Date(item.createdAt) > new Date(last.createdAt)) {
|
||||||
|
last.createdAt = item.createdAt
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.push({
|
||||||
|
type: item.type,
|
||||||
|
icon: item.icon,
|
||||||
|
createdAt: item.createdAt,
|
||||||
|
dateKey,
|
||||||
|
entries: [
|
||||||
|
{
|
||||||
|
type: item.type,
|
||||||
|
comment: item.comment,
|
||||||
|
createdAt: item.createdAt,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
const fetchTimeline = async () => {
|
const fetchTimeline = async () => {
|
||||||
const [postsRes, repliesRes, tagsRes] = await Promise.all([
|
const [postsRes, repliesRes, tagsRes] = await Promise.all([
|
||||||
@@ -440,32 +474,7 @@ const fetchTimeline = async () => {
|
|||||||
})),
|
})),
|
||||||
]
|
]
|
||||||
mapped.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
|
mapped.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
|
||||||
|
timelineItems.value = combineDiscussionItems(mapped)
|
||||||
const grouped = []
|
|
||||||
for (const item of mapped) {
|
|
||||||
if (item.type === 'comment') {
|
|
||||||
const last = grouped[grouped.length - 1]
|
|
||||||
if (last && last.type === 'comment' && isSameDay(last.createdAt, item.createdAt)) {
|
|
||||||
last.entries.push(createCommentEntry(item))
|
|
||||||
if (new Date(item.createdAt) > new Date(last.createdAt)) {
|
|
||||||
last.createdAt = item.createdAt
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
grouped.push({
|
|
||||||
...item,
|
|
||||||
entries: [createCommentEntry(item)],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} else if (item.type === 'reply') {
|
|
||||||
grouped.push({
|
|
||||||
...item,
|
|
||||||
entries: [createCommentEntry(item)],
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
grouped.push(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
timelineItems.value = grouped
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchFollowUsers = async () => {
|
const fetchFollowUsers = async () => {
|
||||||
@@ -648,8 +657,6 @@ watch(selectedTab, async (val) => {
|
|||||||
.profile-page-header-avatar-img {
|
.profile-page-header-avatar-img {
|
||||||
width: 200px;
|
width: 200px;
|
||||||
height: 200px;
|
height: 200px;
|
||||||
border-radius: 50%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.profile-page-header-user-info {
|
.profile-page-header-user-info {
|
||||||
@@ -666,6 +673,11 @@ watch(selectedTab, async (val) => {
|
|||||||
color: #666;
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.reply-icon {
|
||||||
|
color: var(--primary-color);
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.profile-page-header-user-info-buttons {
|
.profile-page-header-user-info-buttons {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@@ -918,8 +930,8 @@ watch(selectedTab, async (val) => {
|
|||||||
|
|
||||||
.timeline-link {
|
.timeline-link {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: var(--primary-color);
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
color: var(--text-color);
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -956,9 +968,25 @@ watch(selectedTab, async (val) => {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-title {
|
.tags-container {
|
||||||
font-size: 18px;
|
display: flex;
|
||||||
font-weight: bold;
|
flex-direction: row;
|
||||||
|
gap: 10px;
|
||||||
|
padding-top: 5px;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tags-container-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 5px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.timeline-tag-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment-content {
|
.comment-content {
|
||||||
@@ -994,6 +1022,7 @@ watch(selectedTab, async (val) => {
|
|||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-comment-link:hover {
|
.timeline-comment-link:hover {
|
||||||
|
|||||||
@@ -199,6 +199,8 @@ function createFetchNotifications() {
|
|||||||
arr.push({
|
arr.push({
|
||||||
...n,
|
...n,
|
||||||
src: n.comment.author.avatar,
|
src: n.comment.author.avatar,
|
||||||
|
userId: n.comment.author.id,
|
||||||
|
userName: n.comment.author.username,
|
||||||
iconClick: () => {
|
iconClick: () => {
|
||||||
markNotificationRead(n.id)
|
markNotificationRead(n.id)
|
||||||
navigateTo(`/users/${n.comment.author.id}`, { replace: true })
|
navigateTo(`/users/${n.comment.author.id}`, { replace: true })
|
||||||
@@ -219,6 +221,8 @@ function createFetchNotifications() {
|
|||||||
arr.push({
|
arr.push({
|
||||||
...n,
|
...n,
|
||||||
src: n.fromUser ? n.fromUser.avatar : null,
|
src: n.fromUser ? n.fromUser.avatar : null,
|
||||||
|
userId: n.fromUser ? n.fromUser.id : undefined,
|
||||||
|
userName: n.fromUser ? n.fromUser.username : undefined,
|
||||||
icon: n.fromUser ? undefined : iconMap[n.type],
|
icon: n.fromUser ? undefined : iconMap[n.type],
|
||||||
iconClick: () => {
|
iconClick: () => {
|
||||||
if (n.fromUser) {
|
if (n.fromUser) {
|
||||||
@@ -231,6 +235,8 @@ function createFetchNotifications() {
|
|||||||
arr.push({
|
arr.push({
|
||||||
...n,
|
...n,
|
||||||
src: n.fromUser ? n.fromUser.avatar : null,
|
src: n.fromUser ? n.fromUser.avatar : null,
|
||||||
|
userId: n.fromUser ? n.fromUser.id : undefined,
|
||||||
|
userName: n.fromUser ? n.fromUser.username : undefined,
|
||||||
icon: n.fromUser ? undefined : iconMap[n.type],
|
icon: n.fromUser ? undefined : iconMap[n.type],
|
||||||
iconClick: () => {
|
iconClick: () => {
|
||||||
if (n.fromUser) {
|
if (n.fromUser) {
|
||||||
@@ -269,6 +275,8 @@ function createFetchNotifications() {
|
|||||||
arr.push({
|
arr.push({
|
||||||
...n,
|
...n,
|
||||||
src: n.comment.author.avatar,
|
src: n.comment.author.avatar,
|
||||||
|
userId: n.comment.author.id,
|
||||||
|
userName: n.comment.author.username,
|
||||||
iconClick: () => {
|
iconClick: () => {
|
||||||
markNotificationRead(n.id)
|
markNotificationRead(n.id)
|
||||||
navigateTo(`/users/${n.comment.author.id}`, { replace: true })
|
navigateTo(`/users/${n.comment.author.id}`, { replace: true })
|
||||||
@@ -315,6 +323,8 @@ function createFetchNotifications() {
|
|||||||
arr.push({
|
arr.push({
|
||||||
...n,
|
...n,
|
||||||
src: n.fromUser ? n.fromUser.avatar : null,
|
src: n.fromUser ? n.fromUser.avatar : null,
|
||||||
|
userId: n.fromUser ? n.fromUser.id : undefined,
|
||||||
|
userName: n.fromUser ? n.fromUser.username : undefined,
|
||||||
icon: n.fromUser ? undefined : iconMap[n.type],
|
icon: n.fromUser ? undefined : iconMap[n.type],
|
||||||
iconClick: () => {
|
iconClick: () => {
|
||||||
if (n.post) {
|
if (n.post) {
|
||||||
|
|||||||
@@ -40,4 +40,33 @@ export default class TimeManager {
|
|||||||
|
|
||||||
return `${date.getFullYear()}.${month}.${day} ${timePart}`
|
return `${date.getFullYear()}.${month}.${day} ${timePart}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 仅显示日期(不含时间)
|
||||||
|
static formatWithDay(input) {
|
||||||
|
const date = new Date(input)
|
||||||
|
if (Number.isNaN(date.getTime())) return ''
|
||||||
|
|
||||||
|
const now = new Date()
|
||||||
|
|
||||||
|
const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate())
|
||||||
|
const startOfDate = new Date(date.getFullYear(), date.getMonth(), date.getDate())
|
||||||
|
const diffDays = Math.floor((startOfToday - startOfDate) / 86400000)
|
||||||
|
|
||||||
|
if (diffDays === 0) return '今天'
|
||||||
|
if (diffDays === 1) return '昨天'
|
||||||
|
if (diffDays === 2) return '前天'
|
||||||
|
|
||||||
|
const month = date.getMonth() + 1
|
||||||
|
const day = date.getDate()
|
||||||
|
|
||||||
|
if (date.getFullYear() === now.getFullYear()) {
|
||||||
|
return `${month}.${day}`
|
||||||
|
}
|
||||||
|
|
||||||
|
if (date.getFullYear() === now.getFullYear() - 1) {
|
||||||
|
return `去年 ${month}.${day}`
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${date.getFullYear()}.${month}.${day}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user