mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-06 23:21:16 +08:00
Compare commits
44 Commits
codex/inte
...
codex/add-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81dfddf6e1 | ||
|
|
8b93aa95cf | ||
|
|
425fc7d2b1 | ||
|
|
0fff73b682 | ||
|
|
e1171212d7 | ||
|
|
e96db5d0d6 | ||
|
|
1083c4241a | ||
|
|
1eeabab41a | ||
|
|
2b5f6f2208 | ||
|
|
bda377336d | ||
|
|
77507f7b18 | ||
|
|
a39f2f7c00 | ||
|
|
229439aa05 | ||
|
|
612881f1b1 | ||
|
|
05c7bc18d7 | ||
|
|
c68c5985f6 | ||
|
|
7d44791011 | ||
|
|
15b992b949 | ||
|
|
4b8229b0a1 | ||
|
|
6e4fbc3c42 | ||
|
|
779264623c | ||
|
|
76aef40de7 | ||
|
|
a1eccb3b1e | ||
|
|
0f75a95dbe | ||
|
|
efbb83924b | ||
|
|
26d1db79f4 | ||
|
|
dc13b2941f | ||
|
|
13c250d392 | ||
|
|
f5b40feaa2 | ||
|
|
c47c318e6f | ||
|
|
c02d993e90 | ||
|
|
f36bcb74ca | ||
|
|
2263fd97db | ||
|
|
9234d1099e | ||
|
|
373dece19d | ||
|
|
b09828bcc2 | ||
|
|
8751a7707c | ||
|
|
f91b240802 | ||
|
|
062b289f7a | ||
|
|
c1dc77f6db | ||
|
|
cea60175c2 | ||
|
|
2bd3630512 | ||
|
|
a9d8181940 | ||
|
|
4cc108094d |
@@ -101,8 +101,8 @@ public class SecurityConfig {
|
||||
"http://localhost",
|
||||
"http://30.211.97.238:3000",
|
||||
"http://30.211.97.238",
|
||||
"http://192.168.7.98",
|
||||
"http://192.168.7.98:3000",
|
||||
"http://192.168.7.90",
|
||||
"http://192.168.7.90:3000",
|
||||
"https://petstore.swagger.io",
|
||||
// 允许自建OpenAPI地址
|
||||
"https://docs.open-isle.com",
|
||||
|
||||
@@ -100,18 +100,32 @@ public class TagController {
|
||||
)
|
||||
public List<TagDto> list(
|
||||
@RequestParam(value = "keyword", required = false) String keyword,
|
||||
@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "pageSize", required = false) Integer pageSize,
|
||||
@RequestParam(value = "limit", required = false) Integer limit
|
||||
) {
|
||||
List<Tag> tags = tagService.searchTags(keyword);
|
||||
List<Long> tagIds = tags.stream().map(Tag::getId).toList();
|
||||
Map<Long, Long> postCntByTagIds = postService.countPostsByTagIds(tagIds);
|
||||
if (postCntByTagIds == null) {
|
||||
postCntByTagIds = java.util.Collections.emptyMap();
|
||||
}
|
||||
Map<Long, Long> finalPostCntByTagIds = postCntByTagIds;
|
||||
List<TagDto> dtos = tags
|
||||
.stream()
|
||||
.map(t -> tagMapper.toDto(t, postCntByTagIds.getOrDefault(t.getId(), 0L)))
|
||||
.map(t -> tagMapper.toDto(t, finalPostCntByTagIds.getOrDefault(t.getId(), 0L)))
|
||||
.sorted((a, b) -> Long.compare(b.getCount(), a.getCount()))
|
||||
.collect(Collectors.toList());
|
||||
if (page != null && pageSize != null && page >= 0 && pageSize > 0) {
|
||||
int fromIndex = page * pageSize;
|
||||
if (fromIndex >= dtos.size()) {
|
||||
return java.util.Collections.emptyList();
|
||||
}
|
||||
int toIndex = Math.min(fromIndex + pageSize, dtos.size());
|
||||
return new java.util.ArrayList<>(dtos.subList(fromIndex, toIndex));
|
||||
}
|
||||
if (limit != null && limit > 0 && dtos.size() > limit) {
|
||||
return dtos.subList(0, limit);
|
||||
return new java.util.ArrayList<>(dtos.subList(0, limit));
|
||||
}
|
||||
return dtos;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ class TagControllerTest {
|
||||
t.setIcon("i2");
|
||||
t.setSmallIcon("s2");
|
||||
Mockito.when(tagService.searchTags(null)).thenReturn(List.of(t));
|
||||
Mockito.when(postService.countPostsByTagIds(List.of(2L))).thenReturn(java.util.Map.of());
|
||||
|
||||
mockMvc
|
||||
.perform(get("/api/tags"))
|
||||
@@ -93,6 +94,31 @@ class TagControllerTest {
|
||||
.andExpect(jsonPath("$[0].smallIcon").value("s2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void listTagsWithPagination() throws Exception {
|
||||
Tag t1 = new Tag();
|
||||
t1.setId(1L);
|
||||
t1.setName("java");
|
||||
Tag t2 = new Tag();
|
||||
t2.setId(2L);
|
||||
t2.setName("spring");
|
||||
Mockito.when(tagService.searchTags(null)).thenReturn(List.of(t1, t2));
|
||||
Mockito.when(postService.countPostsByTagIds(List.of(1L, 2L))).thenReturn(
|
||||
java.util.Map.of(1L, 1L, 2L, 5L)
|
||||
);
|
||||
|
||||
mockMvc
|
||||
.perform(get("/api/tags").param("page", "1").param("pageSize", "1"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$", org.hamcrest.Matchers.hasSize(1)))
|
||||
.andExpect(jsonPath("$[0].id").value(1));
|
||||
|
||||
mockMvc
|
||||
.perform(get("/api/tags").param("page", "2").param("pageSize", "1"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$", org.hamcrest.Matchers.hasSize(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateTag() throws Exception {
|
||||
Tag t = new Tag();
|
||||
|
||||
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 概览
|
||||
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 { openapi } from "@/lib/openapi";
|
||||
|
||||
const outputDir = "./content/docs/openapi/(generated)";
|
||||
|
||||
rmSync(outputDir, { recursive: true, force: true });
|
||||
|
||||
void generateFiles({
|
||||
input: openapi,
|
||||
output: "./content/docs/openapi/(generated)",
|
||||
output: outputDir,
|
||||
// we recommend to enable it
|
||||
// make sure your endpoint description doesn't break MDX syntax.
|
||||
includeDescription: true,
|
||||
per: "operation",
|
||||
groupBy: "route",
|
||||
});
|
||||
|
||||
@@ -108,7 +108,6 @@ body {
|
||||
|
||||
.vditor-toolbar--pin {
|
||||
top: calc(var(--header-height) + 1px) !important;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.vditor-panel {
|
||||
@@ -121,26 +120,19 @@ body {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* .vditor {
|
||||
--textarea-background-color: transparent;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.vditor-reset {
|
||||
color: var(--text-color);
|
||||
.loading-icon {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
.vditor-toolbar {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
} */
|
||||
|
||||
/* .vditor-toolbar {
|
||||
position: relative !important;
|
||||
} */
|
||||
|
||||
/*************************
|
||||
* Markdown 渲染样式
|
||||
*************************/
|
||||
@@ -320,10 +312,6 @@ body {
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.vditor-toolbar {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.about-content h1,
|
||||
.info-content-text h1 {
|
||||
font-size: 20px;
|
||||
@@ -341,8 +329,8 @@ body {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.vditor-toolbar--pin {
|
||||
top: 0 !important;
|
||||
.vditor-panel {
|
||||
min-width: 330px;
|
||||
}
|
||||
|
||||
.about-content li,
|
||||
@@ -354,11 +342,6 @@ body {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.vditor-panel {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.d2h-file-name {
|
||||
font-size: 14px !important;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
<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-icon"
|
||||
:class="{ clickable: !!item.iconClick }"
|
||||
@click="item.iconClick && item.iconClick()"
|
||||
:class="{ clickable: !!item.iconClick || hasLink(item) }"
|
||||
@click="onIconClick(item, $event)"
|
||||
>
|
||||
<BaseImage v-if="item.src" :src="item.src" class="timeline-img" alt="timeline item" />
|
||||
<BaseUserAvatar
|
||||
v-if="item.src"
|
||||
:src="item.src"
|
||||
:user-id="item.userId"
|
||||
:to="item.avatarLink"
|
||||
class="timeline-img"
|
||||
alt="timeline item"
|
||||
:disable-link="!hasLink(item) || !!item.iconClick"
|
||||
/>
|
||||
<component
|
||||
v-else-if="item.icon && (typeof item.icon !== 'string' || !item.icon.includes(' '))"
|
||||
:is="item.icon"
|
||||
@@ -22,11 +30,27 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
|
||||
export default {
|
||||
name: 'BaseTimeline',
|
||||
components: { BaseUserAvatar },
|
||||
props: {
|
||||
items: { type: Array, default: () => [] },
|
||||
hover: { type: Boolean, default: false },
|
||||
},
|
||||
methods: {
|
||||
hasLink(item) {
|
||||
if (!item) return false
|
||||
if (item.avatarLink) return true
|
||||
const id = item?.userId
|
||||
return id !== undefined && id !== null && id !== ''
|
||||
},
|
||||
onIconClick(item, event) {
|
||||
if (item && item.iconClick) {
|
||||
event.preventDefault()
|
||||
item.iconClick()
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -46,12 +70,6 @@ export default {
|
||||
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 {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
@@ -73,8 +91,12 @@ export default {
|
||||
.timeline-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.timeline-img :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.timeline-emoji {
|
||||
@@ -95,7 +117,7 @@ export default {
|
||||
}
|
||||
|
||||
.timeline-item:last-child::before {
|
||||
display: none;
|
||||
bottom: 0px;
|
||||
}
|
||||
|
||||
.timeline-content {
|
||||
|
||||
134
frontend_nuxt/components/BaseUserAvatar.vue
Normal file
134
frontend_nuxt/components/BaseUserAvatar.vue
Normal file
@@ -0,0 +1,134 @@
|
||||
<template>
|
||||
<NuxtLink
|
||||
:to="resolvedLink"
|
||||
class="base-user-avatar"
|
||||
:class="wrapperClass"
|
||||
:style="wrapperStyle"
|
||||
v-bind="wrapperAttrs"
|
||||
>
|
||||
<BaseImage :src="currentSrc" :alt="altText" class="base-user-avatar-img" @error="onError" />
|
||||
</NuxtLink>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useAttrs } from 'vue'
|
||||
import BaseImage from './BaseImage.vue'
|
||||
|
||||
const DEFAULT_AVATAR = '/default-avatar.svg'
|
||||
|
||||
const props = defineProps({
|
||||
userId: {
|
||||
type: [String, Number],
|
||||
default: null,
|
||||
},
|
||||
src: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
alt: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
width: {
|
||||
type: [Number, String],
|
||||
default: null,
|
||||
},
|
||||
rounded: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
disableLink: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
to: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const attrs = useAttrs()
|
||||
|
||||
const currentSrc = ref(props.src || DEFAULT_AVATAR)
|
||||
|
||||
watch(
|
||||
() => props.src,
|
||||
(value) => {
|
||||
currentSrc.value = value || DEFAULT_AVATAR
|
||||
},
|
||||
)
|
||||
|
||||
const resolvedLink = computed(() => {
|
||||
if (props.to) return props.to
|
||||
if (props.userId !== null && props.userId !== undefined && props.userId !== '') {
|
||||
return `/users/${props.userId}`
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
||||
const altText = computed(() => props.alt || '用户头像')
|
||||
|
||||
const sizeStyle = computed(() => {
|
||||
if (!props.width && props.width !== 0) return null
|
||||
const value = typeof props.width === 'number' ? `${props.width}px` : props.width
|
||||
if (!value) return null
|
||||
return { width: value, height: value }
|
||||
})
|
||||
|
||||
const wrapperStyle = computed(() => {
|
||||
const attrStyle = attrs.style
|
||||
return [sizeStyle.value, attrStyle]
|
||||
})
|
||||
|
||||
const wrapperClass = computed(() => [attrs.class, { 'is-rounded': props.rounded }])
|
||||
|
||||
const wrapperAttrs = computed(() => {
|
||||
const { class: _class, style: _style, ...rest } = attrs
|
||||
return rest
|
||||
})
|
||||
|
||||
function onError() {
|
||||
if (currentSrc.value !== DEFAULT_AVATAR) {
|
||||
currentSrc.value = DEFAULT_AVATAR
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.base-user-avatar {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
background-color: var(--avatar-placeholder-color, #f0f0f0);
|
||||
/* 先用box-sizing: border-box,保证加border后宽高不变,圆形不变形 */
|
||||
box-sizing: border-box;
|
||||
border: 1.5px solid var(--normal-border-color);
|
||||
transition: all 0.6s ease;
|
||||
}
|
||||
|
||||
.base-user-avatar:hover {
|
||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.base-user-avatar:active {
|
||||
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.base-user-avatar.is-rounded {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.base-user-avatar:not(.is-rounded) {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.base-user-avatar-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
@@ -10,7 +10,7 @@
|
||||
发布评论
|
||||
<span class="shortcut-icon" v-if="!isMobile"> {{ isMac ? '⌘' : 'Ctrl' }} ⏎ </span>
|
||||
</template>
|
||||
<template v-else> <loading-four /> 发布中... </template>
|
||||
<template v-else> <loading-four class="loading-icon" /> 发布中... </template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<div class="common-info-content-header">
|
||||
<div class="info-content-header-left">
|
||||
<span class="user-name">{{ comment.userName }}</span>
|
||||
<span v-if="isCommentFromPostAuthor" class="op-badge" title="楼主">OP</span>
|
||||
<medal-one class="medal-icon" />
|
||||
<NuxtLink
|
||||
v-if="comment.medal"
|
||||
@@ -26,11 +27,12 @@
|
||||
<span v-if="level >= 2" class="reply-item">
|
||||
<next class="reply-icon" />
|
||||
<span class="reply-info">
|
||||
<BaseImage
|
||||
<BaseUserAvatar
|
||||
class="reply-avatar"
|
||||
:src="comment.parentUserAvatar || '/default-avatar.svg'"
|
||||
alt="avatar"
|
||||
@click="comment.parentUserClick && comment.parentUserClick()"
|
||||
:src="comment.parentUserAvatar"
|
||||
:user-id="comment.parentUserId"
|
||||
:alt="comment.parentUserName"
|
||||
:disable-link="!comment.parentUserId"
|
||||
/>
|
||||
<span class="reply-user-name">{{ comment.parentUserName }}</span>
|
||||
</span>
|
||||
@@ -111,6 +113,7 @@ import BaseTimeline from '~/components/BaseTimeline.vue'
|
||||
import CommentEditor from '~/components/CommentEditor.vue'
|
||||
import DropdownMenu from '~/components/DropdownMenu.vue'
|
||||
import ReactionsGroup from '~/components/ReactionsGroup.vue'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
const config = useRuntimeConfig()
|
||||
const API_BASE_URL = config.public.apiBaseUrl
|
||||
|
||||
@@ -155,6 +158,12 @@ const lightboxImgs = ref([])
|
||||
const loggedIn = computed(() => authState.loggedIn)
|
||||
const countReplies = (list) => list.reduce((sum, r) => sum + 1 + countReplies(r.reply || []), 0)
|
||||
const replyCount = computed(() => countReplies(props.comment.reply || []))
|
||||
const isCommentFromPostAuthor = computed(() => {
|
||||
if (props.comment.userId == null || props.postAuthorId == null) {
|
||||
return false
|
||||
}
|
||||
return String(props.comment.userId) === String(props.postAuthorId)
|
||||
})
|
||||
|
||||
const toggleReplies = () => {
|
||||
showReplies.value = !showReplies.value
|
||||
@@ -259,6 +268,7 @@ const submitReply = async (parentUserName, text, clear) => {
|
||||
text: data.content,
|
||||
parentUserName: parentUserName,
|
||||
parentUserAvatar: props.comment.avatar,
|
||||
parentUserId: props.comment.userId,
|
||||
reactions: [],
|
||||
reply: (data.replies || []).map((r) => ({
|
||||
id: r.id,
|
||||
@@ -270,10 +280,12 @@ const submitReply = async (parentUserName, text, clear) => {
|
||||
reply: [],
|
||||
openReplies: false,
|
||||
src: r.author.avatar,
|
||||
userId: r.author.id,
|
||||
iconClick: () => navigateTo(`/users/${r.author.id}`),
|
||||
})),
|
||||
openReplies: false,
|
||||
src: data.author.avatar,
|
||||
userId: data.author.id,
|
||||
iconClick: () => navigateTo(`/users/${data.author.id}`),
|
||||
})
|
||||
clear()
|
||||
@@ -421,6 +433,21 @@ const handleContentClick = (e) => {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.op-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-left: 6px;
|
||||
padding: 0 6px;
|
||||
height: 18px;
|
||||
border-radius: 9px;
|
||||
background-color: rgba(242, 100, 25, 0.12);
|
||||
color: #f26419;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.medal-icon {
|
||||
font-size: 12px;
|
||||
opacity: 0.6;
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
v-if="open && !isMobile && (loading || filteredOptions.length > 0 || showSearch)"
|
||||
:class="['dropdown-menu', menuClass]"
|
||||
v-click-outside="close"
|
||||
ref="menuRef"
|
||||
>
|
||||
<div v-if="showSearch" class="dropdown-search">
|
||||
<search-icon class="search-icon" />
|
||||
@@ -80,6 +81,7 @@
|
||||
<span>{{ o.name }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
<slot name="footer" :close="close" :loading="loading" />
|
||||
</template>
|
||||
</div>
|
||||
<Teleport to="body">
|
||||
@@ -88,7 +90,7 @@
|
||||
<next class="back-icon" @click="close" />
|
||||
<span class="mobile-title">{{ placeholder }}</span>
|
||||
</div>
|
||||
<div class="dropdown-mobile-menu">
|
||||
<div class="dropdown-mobile-menu" ref="mobileMenuRef">
|
||||
<div v-if="showSearch" class="dropdown-search">
|
||||
<search-icon class="search-icon" />
|
||||
<input type="text" v-model="search" placeholder="搜索" />
|
||||
@@ -116,6 +118,7 @@
|
||||
<span>{{ o.name }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
<slot name="footer" :close="close" :loading="loading" />
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -151,6 +154,8 @@ export default {
|
||||
const loaded = ref(false)
|
||||
const loading = ref(false)
|
||||
const wrapper = ref(null)
|
||||
const menuRef = ref(null)
|
||||
const mobileMenuRef = ref(null)
|
||||
const isMobile = useIsMobile()
|
||||
|
||||
const toggle = () => {
|
||||
@@ -200,6 +205,17 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
const scrollToBottom = () => {
|
||||
const el = isMobile.value ? mobileMenuRef.value : menuRef.value
|
||||
if (el) {
|
||||
el.scrollTop = el.scrollHeight
|
||||
}
|
||||
}
|
||||
|
||||
const reload = async () => {
|
||||
await loadOptions(props.remote ? search.value : undefined)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.initialOptions,
|
||||
(val) => {
|
||||
@@ -249,7 +265,7 @@ export default {
|
||||
return /^https?:\/\//.test(icon) || icon.startsWith('/')
|
||||
}
|
||||
|
||||
expose({ toggle, close })
|
||||
expose({ toggle, close, reload, scrollToBottom })
|
||||
|
||||
return {
|
||||
open,
|
||||
@@ -259,6 +275,8 @@ export default {
|
||||
search,
|
||||
filteredOptions,
|
||||
wrapper,
|
||||
menuRef,
|
||||
mobileMenuRef,
|
||||
selectedLabels,
|
||||
isSelected,
|
||||
loading,
|
||||
|
||||
@@ -70,7 +70,14 @@
|
||||
<DropdownMenu v-if="isLogin" ref="userMenu" :items="headerMenuItems">
|
||||
<template #trigger>
|
||||
<div class="avatar-container">
|
||||
<img class="avatar-img" :src="avatar" alt="avatar" />
|
||||
<BaseUserAvatar
|
||||
class="avatar-img"
|
||||
:user-id="authState.userId"
|
||||
:src="avatar"
|
||||
alt="avatar"
|
||||
:width="32"
|
||||
:disable-link="true"
|
||||
/>
|
||||
<down />
|
||||
</div>
|
||||
</template>
|
||||
@@ -93,6 +100,7 @@ import { computed, nextTick, ref, watch } from 'vue'
|
||||
import DropdownMenu from '~/components/DropdownMenu.vue'
|
||||
import ToolTip from '~/components/ToolTip.vue'
|
||||
import SearchDropdown from '~/components/SearchDropdown.vue'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
import { authState, clearToken, loadCurrentUser } from '~/utils/auth'
|
||||
import { useUnreadCount } from '~/composables/useUnreadCount'
|
||||
import { useChannelsUnreadCount } from '~/composables/useChannelsUnreadCount'
|
||||
|
||||
@@ -116,30 +116,42 @@
|
||||
<div v-if="isLoadingTag" class="menu-loading-container">
|
||||
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
v-for="t in tagData"
|
||||
:key="t.id"
|
||||
class="section-item"
|
||||
:class="{ selected: isTagSelected(t.id) }"
|
||||
<template v-else>
|
||||
<div
|
||||
v-for="t in tagData"
|
||||
:key="t.id"
|
||||
class="section-item"
|
||||
:class="{ selected: isTagSelected(t.id) }"
|
||||
@click="gotoTag(t)"
|
||||
>
|
||||
<BaseImage
|
||||
v-if="isImageIcon(t.smallIcon || t.icon)"
|
||||
:src="t.smallIcon || t.icon"
|
||||
class="section-item-icon"
|
||||
:alt="t.name"
|
||||
/>
|
||||
<component
|
||||
v-else-if="t.smallIcon || t.icon"
|
||||
:is="t.smallIcon || t.icon"
|
||||
class="section-item-icon"
|
||||
/>
|
||||
<tag-one v-else class="section-item-icon" />
|
||||
<span class="section-item-text"
|
||||
>{{ t.name }} <span class="section-item-text-count">x {{ t.count }}</span></span
|
||||
>
|
||||
</div>
|
||||
<BaseImage
|
||||
v-if="isImageIcon(t.smallIcon || t.icon)"
|
||||
:src="t.smallIcon || t.icon"
|
||||
class="section-item-icon"
|
||||
:alt="t.name"
|
||||
/>
|
||||
<component
|
||||
v-else-if="t.smallIcon || t.icon"
|
||||
:is="t.smallIcon || t.icon"
|
||||
class="section-item-icon"
|
||||
/>
|
||||
<tag-one v-else class="section-item-icon" />
|
||||
<span class="section-item-text"
|
||||
>{{ t.name }} <span class="section-item-text-count">x {{ t.count }}</span></span
|
||||
>
|
||||
</div>
|
||||
<div v-if="hasMoreTags || isLoadingMoreTags" class="section-item more-item">
|
||||
<a
|
||||
v-if="hasMoreTags && !isLoadingMoreTags"
|
||||
href="#"
|
||||
class="more-link"
|
||||
@click.prevent="loadMoreTags"
|
||||
>
|
||||
查看更多
|
||||
</a>
|
||||
<span v-else class="more-loading">加载中...</span>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -207,16 +219,88 @@ const {
|
||||
},
|
||||
)
|
||||
|
||||
const TAG_PAGE_SIZE = 10
|
||||
const tagPage = ref(0)
|
||||
const hasMoreTags = ref(true)
|
||||
const isLoadingMoreTags = ref(false)
|
||||
|
||||
const buildTagUrl = (page = 0) => {
|
||||
const base = API_BASE_URL || (import.meta.client ? window.location.origin : '')
|
||||
const url = new URL('/api/tags', base)
|
||||
url.searchParams.set('page', String(page))
|
||||
url.searchParams.set('pageSize', String(TAG_PAGE_SIZE))
|
||||
return url.toString()
|
||||
}
|
||||
|
||||
const fetchTagPage = async (page = 0) => {
|
||||
try {
|
||||
return await $fetch(buildTagUrl(page))
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch tags', e)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
const {
|
||||
data: tagData,
|
||||
pending: isLoadingTag,
|
||||
error: tagError,
|
||||
} = await useAsyncData('menu:tags', () => $fetch(`${API_BASE_URL}/api/tags?limit=10`), {
|
||||
} = await useAsyncData('menu:tags', () => fetchTagPage(0), {
|
||||
server: true,
|
||||
default: () => [],
|
||||
staleTime: 5 * 60 * 1000,
|
||||
})
|
||||
|
||||
const dedupeTags = (list) => Array.from(new Map(list.map((tag) => [tag.id, tag])).values())
|
||||
|
||||
const initializeTagState = (val) => {
|
||||
const initial = Array.isArray(val) ? val : []
|
||||
if (!Array.isArray(val)) {
|
||||
tagData.value = []
|
||||
}
|
||||
tagPage.value = 0
|
||||
hasMoreTags.value = initial.length === TAG_PAGE_SIZE
|
||||
}
|
||||
|
||||
initializeTagState(tagData.value)
|
||||
|
||||
watch(
|
||||
tagData,
|
||||
(val, oldVal) => {
|
||||
const next = Array.isArray(val) ? val : []
|
||||
if (!Array.isArray(val)) {
|
||||
tagData.value = []
|
||||
}
|
||||
const shouldReset =
|
||||
!Array.isArray(oldVal) || oldVal.length > next.length || next.length <= TAG_PAGE_SIZE
|
||||
if (shouldReset) {
|
||||
tagPage.value = 0
|
||||
hasMoreTags.value = next.length === TAG_PAGE_SIZE
|
||||
}
|
||||
},
|
||||
{ deep: false },
|
||||
)
|
||||
|
||||
const loadMoreTags = async () => {
|
||||
if (isLoadingMoreTags.value || !hasMoreTags.value) return
|
||||
isLoadingMoreTags.value = true
|
||||
const nextPage = tagPage.value + 1
|
||||
try {
|
||||
const result = await fetchTagPage(nextPage)
|
||||
const data = Array.isArray(result) ? result : []
|
||||
const existing = Array.isArray(tagData.value) ? tagData.value : []
|
||||
tagData.value = dedupeTags([...existing, ...data])
|
||||
tagPage.value = nextPage
|
||||
if (data.length < TAG_PAGE_SIZE) {
|
||||
hasMoreTags.value = false
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load more tags', e)
|
||||
} finally {
|
||||
isLoadingMoreTags.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 其余逻辑保持不变 */
|
||||
const iconClass = computed(() => {
|
||||
switch (themeState.mode) {
|
||||
@@ -433,6 +517,27 @@ const gotoTag = (t) => {
|
||||
transition: background-color 0.5s ease;
|
||||
}
|
||||
|
||||
.more-item {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.more-link {
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.more-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.more-loading {
|
||||
font-size: 13px;
|
||||
color: var(--menu-text-color);
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.section-item:hover {
|
||||
background-color: var(--menu-selected-background-color-hover);
|
||||
}
|
||||
@@ -441,7 +546,6 @@ const gotoTag = (t) => {
|
||||
background-color: var(--menu-selected-background-color);
|
||||
}
|
||||
|
||||
|
||||
.section-item-text-count {
|
||||
font-size: 12px;
|
||||
color: var(--menu-text-color);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
发送
|
||||
<span class="shortcut-icon" v-if="!isMobile"> {{ isMac ? '⌘' : 'Ctrl' }} ⏎ </span>
|
||||
</template>
|
||||
<template v-else> <loading-four /> 发送中... </template>
|
||||
<template v-else> <loading-four class="loading-icon" /> 发送中... </template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -159,12 +159,6 @@ export default {
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.vditor {
|
||||
min-height: 50px;
|
||||
max-height: 150px;
|
||||
}
|
||||
|
||||
.message-bottom-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<template>
|
||||
<div :id="`change-log-${log.id}`" class="change-log-container">
|
||||
<div class="change-log-text">
|
||||
<BaseImage
|
||||
<BaseUserAvatar
|
||||
v-if="log.userAvatar"
|
||||
class="change-log-avatar"
|
||||
:src="log.userAvatar"
|
||||
:to="log.username ? `/users/${log.username}` : ''"
|
||||
alt="avatar"
|
||||
@click="() => navigateTo(`/users/${log.username}`)"
|
||||
:disable-link="!log.username"
|
||||
/>
|
||||
<span v-if="log.username" class="change-log-user">{{ log.username }}</span>
|
||||
<span v-if="log.type === 'CONTENT'" class="change-log-content">变更了文章内容</span>
|
||||
@@ -55,10 +56,8 @@
|
||||
import { computed } from 'vue'
|
||||
import { html } from 'diff2html'
|
||||
import { createTwoFilesPatch } from 'diff'
|
||||
import { useIsMobile } from '~/utils/screen'
|
||||
import 'diff2html/bundles/css/diff2html.min.css'
|
||||
import BaseImage from '~/components/BaseImage.vue'
|
||||
import { navigateTo } from 'nuxt/app'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
import { themeState } from '~/utils/theme'
|
||||
import ArticleCategory from '~/components/ArticleCategory.vue'
|
||||
import ArticleTags from '~/components/ArticleTags.vue'
|
||||
@@ -135,6 +134,12 @@ const diffHtml = computed(() => {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.change-log-avatar :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.change-log-time {
|
||||
font-size: 12px;
|
||||
opacity: 0.6;
|
||||
|
||||
@@ -53,24 +53,24 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="prize-member-container">
|
||||
<BaseImage
|
||||
<BaseUserAvatar
|
||||
v-for="p in lotteryParticipants"
|
||||
:key="p.id"
|
||||
class="prize-member-avatar"
|
||||
:user-id="p.id"
|
||||
:src="p.avatar"
|
||||
alt="avatar"
|
||||
@click="gotoUser(p.id)"
|
||||
/>
|
||||
<div v-if="lotteryEnded && lotteryWinners.length" class="prize-member-winner">
|
||||
<medal-one class="medal-icon"></medal-one>
|
||||
<span class="prize-member-winner-name">获奖者: </span>
|
||||
<BaseImage
|
||||
<BaseUserAvatar
|
||||
v-for="w in lotteryWinners"
|
||||
:key="w.id"
|
||||
class="prize-member-avatar"
|
||||
:user-id="w.id"
|
||||
:src="w.avatar"
|
||||
alt="avatar"
|
||||
@click="gotoUser(w.id)"
|
||||
/>
|
||||
<div v-if="lotteryWinners.length === 1" class="prize-member-winner-name">
|
||||
{{ lotteryWinners[0].username }}
|
||||
@@ -87,6 +87,7 @@ import { toast } from '~/main'
|
||||
import { useRuntimeConfig } from '#imports'
|
||||
import { useIsMobile } from '~/utils/screen'
|
||||
import { useCountdown } from '~/composables/useCountdown'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
|
||||
const props = defineProps({
|
||||
lottery: { type: Object, required: true },
|
||||
@@ -106,8 +107,6 @@ const hasJoined = computed(() => {
|
||||
return lotteryParticipants.value.some((p) => p.id === Number(authState.userId))
|
||||
})
|
||||
|
||||
const gotoUser = (id) => navigateTo(`/users/${id}`, { replace: true })
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const API_BASE_URL = config.public.apiBaseUrl
|
||||
const joinLottery = async () => {
|
||||
@@ -247,10 +246,15 @@ const joinLottery = async () => {
|
||||
height: 30px;
|
||||
margin-left: 3px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.prize-member-avatar :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.prize-member-winner {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
></div>
|
||||
</div>
|
||||
<div class="poll-participants">
|
||||
<BaseImage
|
||||
<BaseUserAvatar
|
||||
v-for="p in pollOptionParticipants[idx] || []"
|
||||
:key="p.id"
|
||||
class="poll-participant-avatar"
|
||||
:user-id="p.id"
|
||||
:src="p.avatar"
|
||||
alt="avatar"
|
||||
@click="gotoUser(p.id)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -119,6 +119,7 @@ import { getToken, authState } from '~/utils/auth'
|
||||
import { toast } from '~/main'
|
||||
import { useRuntimeConfig } from '#imports'
|
||||
import { useCountdown } from '~/composables/useCountdown'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
|
||||
const props = defineProps({
|
||||
poll: { type: Object, required: true },
|
||||
@@ -152,8 +153,6 @@ watch([hasVoted, pollEnded], ([voted, ended]) => {
|
||||
if (voted || ended) showPollResult.value = true
|
||||
})
|
||||
|
||||
const gotoUser = (id) => navigateTo(`/users/${id}`, { replace: true })
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const API_BASE_URL = config.public.apiBaseUrl
|
||||
const voteOption = async (idx) => {
|
||||
@@ -429,4 +428,10 @@ const submitMultiPoll = async () => {
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.poll-participant-avatar :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
</template>
|
||||
<template #option="{ option }">
|
||||
<div class="search-option-item">
|
||||
<BaseImage
|
||||
:src="option.avatar || '/default-avatar.svg'"
|
||||
<BaseUserAvatar
|
||||
:src="option.avatar"
|
||||
:user-id="option.id"
|
||||
:alt="option.username"
|
||||
class="avatar"
|
||||
@error="handleAvatarError"
|
||||
:disable-link="true"
|
||||
/>
|
||||
<div class="result-body">
|
||||
<div class="result-main" v-html="highlight(option.username)"></div>
|
||||
@@ -49,6 +51,7 @@ import Dropdown from '~/components/Dropdown.vue'
|
||||
import { stripMarkdown } from '~/utils/markdown'
|
||||
import { useIsMobile } from '~/utils/screen'
|
||||
import { getToken } from '~/utils/auth'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
const config = useRuntimeConfig()
|
||||
const API_BASE_URL = config.public.apiBaseUrl
|
||||
|
||||
@@ -87,10 +90,6 @@ const highlight = (text) => {
|
||||
return text.replace(reg, (m) => `<span class="highlight">${m}</span>`)
|
||||
}
|
||||
|
||||
const handleAvatarError = (e) => {
|
||||
e.target.src = '/default-avatar.svg'
|
||||
}
|
||||
|
||||
watch(selected, async (val) => {
|
||||
if (!val) return
|
||||
const user = results.value.find((u) => u.id === val)
|
||||
@@ -179,6 +178,12 @@ defineExpose({
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.avatar :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<Dropdown
|
||||
ref="dropdownRef"
|
||||
v-model="selected"
|
||||
:fetch-options="fetchTags"
|
||||
multiple
|
||||
@@ -25,11 +26,23 @@
|
||||
<div v-if="option.description" class="option-desc">{{ option.description }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #footer>
|
||||
<div v-if="hasMoreRemoteTags" class="dropdown-footer">
|
||||
<a
|
||||
href="#"
|
||||
class="dropdown-more"
|
||||
:class="{ disabled: loadMoreRequested }"
|
||||
@click.prevent="loadMoreRemoteTags"
|
||||
>
|
||||
{{ loadMoreRequested ? '加载中...' : '查看更多' }}
|
||||
</a>
|
||||
</div>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { computed, reactive, ref, watch, nextTick } from 'vue'
|
||||
import { toast } from '~/main'
|
||||
import Dropdown from '~/components/Dropdown.vue'
|
||||
const config = useRuntimeConfig()
|
||||
@@ -42,9 +55,19 @@ const props = defineProps({
|
||||
options: { type: Array, default: () => [] },
|
||||
})
|
||||
|
||||
const dropdownRef = ref(null)
|
||||
const localTags = ref([])
|
||||
const providedTags = ref(Array.isArray(props.options) ? [...props.options] : [])
|
||||
|
||||
const TAG_PAGE_SIZE = 10
|
||||
const remoteState = reactive({
|
||||
keyword: '',
|
||||
nextPage: 0,
|
||||
hasMore: true,
|
||||
options: [],
|
||||
})
|
||||
const loadMoreRequested = ref(false)
|
||||
|
||||
watch(
|
||||
() => props.options,
|
||||
(val) => {
|
||||
@@ -53,7 +76,7 @@ watch(
|
||||
)
|
||||
|
||||
const mergedOptions = computed(() => {
|
||||
const arr = [...providedTags.value, ...localTags.value]
|
||||
const arr = [...providedTags.value, ...localTags.value, ...remoteState.options]
|
||||
return arr.filter((v, i, a) => a.findIndex((t) => t.id === v.id) === i)
|
||||
})
|
||||
|
||||
@@ -62,44 +85,93 @@ const isImageIcon = (icon) => {
|
||||
return /^https?:\/\//.test(icon) || icon.startsWith('/')
|
||||
}
|
||||
|
||||
const buildTagsUrl = (kw = '') => {
|
||||
const buildTagsUrl = (kw = '', page = 0) => {
|
||||
const base = API_BASE_URL || (import.meta.client ? window.location.origin : '')
|
||||
const url = new URL('/api/tags', base)
|
||||
|
||||
if (kw) url.searchParams.set('keyword', kw)
|
||||
url.searchParams.set('limit', '10')
|
||||
url.searchParams.set('page', String(page))
|
||||
url.searchParams.set('pageSize', String(TAG_PAGE_SIZE))
|
||||
|
||||
return url.toString()
|
||||
}
|
||||
|
||||
const fetchRemoteTags = async (kw = '', page = 0) => {
|
||||
const url = buildTagsUrl(kw, page)
|
||||
try {
|
||||
const res = await fetch(url)
|
||||
if (res.ok) {
|
||||
const data = await res.json()
|
||||
return Array.isArray(data) ? data : []
|
||||
}
|
||||
throw new Error('failed to fetch tags')
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch tags', e)
|
||||
toast.error('获取标签失败')
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
const combineOptions = (remoteOptions = []) => {
|
||||
const options = [...providedTags.value, ...localTags.value, ...remoteOptions]
|
||||
return Array.from(new Map(options.map((t) => [t.id, t])).values())
|
||||
}
|
||||
|
||||
const fetchTags = async (kw = '') => {
|
||||
const defaultOption = { id: 0, name: '无标签' }
|
||||
|
||||
// 1) 先拼 URL(自动兜底到 window.location.origin)
|
||||
const url = buildTagsUrl(kw)
|
||||
|
||||
// 2) 拉数据
|
||||
let data = []
|
||||
try {
|
||||
const res = await fetch(url)
|
||||
if (res.ok) data = await res.json()
|
||||
} catch {
|
||||
toast.error('获取标签失败')
|
||||
if (kw !== remoteState.keyword) {
|
||||
remoteState.keyword = kw
|
||||
remoteState.nextPage = 0
|
||||
remoteState.options = []
|
||||
remoteState.hasMore = true
|
||||
}
|
||||
|
||||
// 3) 合并、去重、可创建
|
||||
let options = [...data, ...localTags.value]
|
||||
const shouldFetch = remoteState.options.length === 0 || loadMoreRequested.value
|
||||
if (shouldFetch) {
|
||||
const pageToFetch = loadMoreRequested.value ? remoteState.nextPage : 0
|
||||
try {
|
||||
const data = await fetchRemoteTags(remoteState.keyword, pageToFetch)
|
||||
if (pageToFetch === 0) {
|
||||
remoteState.options = data
|
||||
} else {
|
||||
const existing = Array.isArray(remoteState.options) ? remoteState.options : []
|
||||
const merged = [...existing, ...data]
|
||||
remoteState.options = Array.from(new Map(merged.map((t) => [t.id, t])).values())
|
||||
}
|
||||
remoteState.hasMore = data.length === TAG_PAGE_SIZE
|
||||
remoteState.nextPage = pageToFetch + 1
|
||||
} catch (e) {
|
||||
return [defaultOption, ...combineOptions(remoteState.options)]
|
||||
} finally {
|
||||
loadMoreRequested.value = false
|
||||
}
|
||||
}
|
||||
|
||||
let options = combineOptions(remoteState.options)
|
||||
|
||||
if (props.creatable && kw && !options.some((t) => t.name.toLowerCase() === kw.toLowerCase())) {
|
||||
options.push({ id: `__create__:${kw}`, name: `创建"${kw}"` })
|
||||
}
|
||||
|
||||
options = Array.from(new Map(options.map((t) => [t.id, t])).values())
|
||||
|
||||
// 4) 最终结果
|
||||
return [defaultOption, ...options]
|
||||
}
|
||||
|
||||
const hasMoreRemoteTags = computed(() => remoteState.hasMore)
|
||||
|
||||
const loadMoreRemoteTags = async () => {
|
||||
if (!remoteState.hasMore || loadMoreRequested.value) return
|
||||
loadMoreRequested.value = true
|
||||
try {
|
||||
await dropdownRef.value?.reload()
|
||||
await nextTick()
|
||||
dropdownRef.value?.scrollToBottom?.()
|
||||
} catch (e) {
|
||||
console.error('Failed to load more tags', e)
|
||||
loadMoreRequested.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const selected = computed({
|
||||
get: () => props.modelValue,
|
||||
set: (v) => {
|
||||
@@ -151,4 +223,21 @@ const selected = computed({
|
||||
font-weight: bold;
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.dropdown-footer {
|
||||
padding: 8px 20px;
|
||||
text-align: center;
|
||||
border-top: 1px solid var(--normal-border-color);
|
||||
}
|
||||
|
||||
.dropdown-more {
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.dropdown-more.disabled {
|
||||
pointer-events: none;
|
||||
opacity: 0.6;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
<template>
|
||||
<div class="timeline-tag-item">
|
||||
<template v-if="mode === 'timeline'">
|
||||
<div class="tags-container">
|
||||
<div class="tags-container-item">
|
||||
<div class="timeline-tag-title">{{ title }}</div>
|
||||
<ArticleTags v-if="tag" :tags="[tag]" />
|
||||
</div>
|
||||
<div v-if="timelineDate" class="timeline-date">{{ timelineDate }}</div>
|
||||
<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="hasDescription" class="timeline-snippet">
|
||||
{{ tag?.description }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="timeline-link" :class="{ clickable: isClickable }" @click="handleTagClick">
|
||||
{{ tag?.name }}<span v-if="tag?.count"> x{{ tag.count }}</span>
|
||||
</span>
|
||||
<div v-if="hasDescription" class="timeline-snippet">
|
||||
{{ tag?.description }}
|
||||
</div>
|
||||
<div v-if="summaryDate" class="timeline-date">{{ summaryDate }}</div>
|
||||
</template>
|
||||
<div v-if="timelineDate" class="timeline-date">{{ timelineDate }}</div>
|
||||
</div>
|
||||
<div v-if="hasDescription" class="timeline-snippet">
|
||||
{{ tag?.description }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -30,15 +20,6 @@ import TimeManager from '~/utils/time'
|
||||
|
||||
const props = defineProps({
|
||||
item: { type: Object, required: true },
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'timeline',
|
||||
validator: (value) => ['timeline', 'summary'].includes(value),
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: '创建了标签',
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['tag-click'])
|
||||
@@ -95,6 +76,10 @@ const handleTagClick = () => {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.timeline-tag-count {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.timeline-date {
|
||||
font-size: 12px;
|
||||
color: gray;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="user-list">
|
||||
<BasePlaceholder v-if="users.length === 0" text="暂无用户" icon="inbox" />
|
||||
<div v-for="u in users" :key="u.id" class="user-item" @click="handleUserClick(u)">
|
||||
<BaseImage :src="u.avatar" alt="avatar" class="user-avatar" />
|
||||
<div v-for="u in users" :key="u.id" class="user-item">
|
||||
<BaseUserAvatar :src="u.avatar" :user-id="u.id" alt="avatar" class="user-avatar" />
|
||||
<div class="user-info">
|
||||
<div class="user-name">{{ u.username }}</div>
|
||||
<div v-if="u.introduction" class="user-intro">{{ u.introduction }}</div>
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
<script setup>
|
||||
import BasePlaceholder from '~/components/BasePlaceholder.vue'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
|
||||
defineProps({
|
||||
users: { type: Array, default: () => [] },
|
||||
@@ -27,20 +28,27 @@ const handleUserClick = (user) => {
|
||||
.user-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.user-item {
|
||||
padding-top: 20px;
|
||||
padding-bottom: 20px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
cursor: pointer;
|
||||
border-bottom: 1px solid var(--normal-border-color);
|
||||
}
|
||||
.user-avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-avatar :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
.user-info {
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
</div>
|
||||
</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>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -233,6 +235,7 @@ export default {
|
||||
.about-api-link {
|
||||
color: var(--primary-color);
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.about-api-link:hover {
|
||||
|
||||
@@ -85,14 +85,16 @@
|
||||
</div>
|
||||
|
||||
<div class="article-member-avatars-container">
|
||||
<NuxtLink
|
||||
v-for="member in article.members"
|
||||
:key="`${article.id}-${member.id}`"
|
||||
class="article-member-avatar-item"
|
||||
:to="`/users/${member.id}`"
|
||||
>
|
||||
<BaseImage class="article-member-avatar-item-img" :src="member.avatar" alt="avatar" />
|
||||
</NuxtLink>
|
||||
<div v-for="member in article.members" class="article-member-avatar-item">
|
||||
<BaseUserAvatar
|
||||
class="article-member-avatar-item-img"
|
||||
:src="member.avatar"
|
||||
:user-id="member.id"
|
||||
alt="avatar"
|
||||
:disable-link="true"
|
||||
:width="25"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="article-comments main-info-text">
|
||||
@@ -138,6 +140,7 @@ import InfiniteLoadMore from '~/components/InfiniteLoadMore.vue'
|
||||
import { getToken } from '~/utils/auth'
|
||||
import { stripMarkdown } from '~/utils/markdown'
|
||||
import { useIsMobile } from '~/utils/screen'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
import TimeManager from '~/utils/time'
|
||||
import { selectedCategoryGlobal, selectedTagsGlobal } from '~/composables/postFilter'
|
||||
useHead({
|
||||
@@ -383,7 +386,6 @@ watch([selectedCategory, selectedTags], ([newCategory, newTags]) => {
|
||||
selectedCategoryGlobal.value = newCategory
|
||||
selectedTagsGlobal.value = newTags
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@@ -628,14 +630,12 @@ watch([selectedCategory, selectedTags], ([newCategory, newTags]) => {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.article-member-avatar-item {
|
||||
width: 25px;
|
||||
height: 25px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
.article-member-avatar-item-img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.article-member-avatar-item-img {
|
||||
.article-member-avatar-item-img :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
@@ -692,6 +692,7 @@ watch([selectedCategory, selectedTags], ([newCategory, newTags]) => {
|
||||
margin-left: 0px;
|
||||
gap: 0px;
|
||||
}
|
||||
|
||||
.article-main-container,
|
||||
.header-item.main-item {
|
||||
width: calc(70% - 20px);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<div v-else class="login-page-button-primary disabled">
|
||||
<div class="login-page-button-text">
|
||||
<loading-four />
|
||||
<loading-four class="loading-icon" />
|
||||
登录中...
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -44,7 +44,12 @@
|
||||
<div v-if="item.replyTo" class="reply-preview info-content-text">
|
||||
<div class="reply-header">
|
||||
<next class="reply-icon" />
|
||||
<BaseImage class="reply-avatar" :src="item.replyTo.sender.avatar" alt="avatar" />
|
||||
<BaseUserAvatar
|
||||
class="reply-avatar"
|
||||
:src="item.replyTo.sender.avatar"
|
||||
:user-id="item.replyTo.sender.id"
|
||||
:alt="item.replyTo.sender.username"
|
||||
/>
|
||||
<div class="reply-author">{{ item.replyTo.sender.username }}:</div>
|
||||
</div>
|
||||
<div class="reply-content" v-html="renderMarkdown(item.replyTo.content)"></div>
|
||||
@@ -121,6 +126,7 @@ import TimeManager from '~/utils/time'
|
||||
import BaseTimeline from '~/components/BaseTimeline.vue'
|
||||
import BasePlaceholder from '~/components/BasePlaceholder.vue'
|
||||
import VueEasyLightbox from 'vue-easy-lightbox'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const route = useRoute()
|
||||
@@ -243,6 +249,7 @@ async function fetchMessages(page = 0) {
|
||||
const newMessages = pageData.content.reverse().map((item) => ({
|
||||
...item,
|
||||
src: item.sender.avatar,
|
||||
userId: item.sender.id,
|
||||
iconClick: () => {
|
||||
openUser(item.sender.id)
|
||||
},
|
||||
@@ -328,6 +335,7 @@ async function sendMessage(content, clearInput) {
|
||||
messages.value.push({
|
||||
...newMessage,
|
||||
src: newMessage.sender.avatar,
|
||||
userId: newMessage.sender.id,
|
||||
iconClick: () => {
|
||||
openUser(newMessage.sender.id)
|
||||
},
|
||||
@@ -403,6 +411,7 @@ const subscribeToConversation = () => {
|
||||
messages.value.push({
|
||||
...parsedMessage,
|
||||
src: parsedMessage.sender.avatar,
|
||||
userId: parsedMessage.sender.id,
|
||||
iconClick: () => openUser(parsedMessage.sender.id),
|
||||
})
|
||||
|
||||
@@ -686,6 +695,12 @@ function goBack() {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.reply-avatar :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.reply-preview {
|
||||
margin-top: 10px;
|
||||
padding: 10px;
|
||||
|
||||
@@ -33,11 +33,12 @@
|
||||
@click="goToConversation(convo.id)"
|
||||
>
|
||||
<div class="conversation-avatar">
|
||||
<BaseImage
|
||||
:src="getOtherParticipant(convo)?.avatar || '/default-avatar.svg'"
|
||||
<BaseUserAvatar
|
||||
:src="getOtherParticipant(convo)?.avatar"
|
||||
:user-id="getOtherParticipant(convo)?.id"
|
||||
:alt="getOtherParticipant(convo)?.username || '用户'"
|
||||
class="avatar-img"
|
||||
@error="handleAvatarError"
|
||||
:disable-link="true"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -130,6 +131,7 @@ import { stripMarkdownLength } from '~/utils/markdown'
|
||||
import SearchPersonDropdown from '~/components/SearchPersonDropdown.vue'
|
||||
import BasePlaceholder from '~/components/BasePlaceholder.vue'
|
||||
import BaseTabs from '~/components/BaseTabs.vue'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const conversations = ref([])
|
||||
@@ -431,6 +433,11 @@ function minimize() {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.avatar-img :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
>
|
||||
发布
|
||||
</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>
|
||||
<LotteryForm v-if="postType === 'LOTTERY'" :data="lottery" />
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
>
|
||||
更新
|
||||
</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>
|
||||
|
||||
@@ -48,7 +48,13 @@
|
||||
<div class="info-content-container author-info-container">
|
||||
<div class="user-avatar-container" @click="gotoProfile">
|
||||
<div class="user-avatar-item">
|
||||
<BaseImage class="user-avatar-item-img" :src="author.avatar" alt="avatar" />
|
||||
<BaseUserAvatar
|
||||
class="user-avatar-item-img"
|
||||
:src="author.avatar"
|
||||
:user-id="author.id"
|
||||
alt="avatar"
|
||||
:disable-link="true"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="isMobile" class="info-content-header">
|
||||
<div class="user-name">
|
||||
@@ -193,6 +199,7 @@ import ReactionsGroup from '~/components/ReactionsGroup.vue'
|
||||
import DropdownMenu from '~/components/DropdownMenu.vue'
|
||||
import PostLottery from '~/components/PostLottery.vue'
|
||||
import PostPoll from '~/components/PostPoll.vue'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
import { renderMarkdown, handleMarkdownClick, stripMarkdownLength } from '~/utils/markdown'
|
||||
import { getMedalTitle } from '~/utils/medal'
|
||||
import { toast } from '~/main'
|
||||
@@ -340,7 +347,7 @@ const mapComment = (
|
||||
iconClick: () => navigateTo(`/users/${c.author.id}`),
|
||||
parentUserName: parentUserName,
|
||||
parentUserAvatar: parentUserAvatar,
|
||||
parentUserClick: parentUserId ? () => navigateTo(`/users/${parentUserId}`) : null,
|
||||
parentUserId: parentUserId,
|
||||
})
|
||||
|
||||
const changeLogIcon = (l) => {
|
||||
@@ -1186,6 +1193,12 @@ onMounted(async () => {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.user-avatar-item-img :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.info-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -15,7 +15,13 @@
|
||||
<div class="avatar-row">
|
||||
<!-- label 充当点击区域,内部隐藏 input -->
|
||||
<label class="avatar-container">
|
||||
<BaseImage :src="avatar" class="avatar-preview" alt="avatar" />
|
||||
<BaseUserAvatar
|
||||
:src="avatar"
|
||||
:user-id="userId"
|
||||
alt="avatar"
|
||||
class="avatar-preview"
|
||||
:disable-link="true"
|
||||
/>
|
||||
<!-- 半透明蒙层:hover 时出现 -->
|
||||
<div class="avatar-overlay">更换头像</div>
|
||||
<input type="file" class="avatar-input" accept="image/*" @change="onAvatarChange" />
|
||||
@@ -74,6 +80,7 @@ import AvatarCropper from '~/components/AvatarCropper.vue'
|
||||
import BaseInput from '~/components/BaseInput.vue'
|
||||
import Dropdown from '~/components/Dropdown.vue'
|
||||
import BaseSwitch from '~/components/BaseSwitch.vue'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
import { toast } from '~/main'
|
||||
import { fetchCurrentUser, getToken, setToken } from '~/utils/auth'
|
||||
import { frostedState, setFrosted } from '~/utils/frosted'
|
||||
@@ -87,6 +94,7 @@ const avatarFile = ref(null)
|
||||
const tempAvatar = ref('')
|
||||
const showCropper = ref(false)
|
||||
const role = ref('')
|
||||
const userId = ref(null)
|
||||
const publishMode = ref('DIRECT')
|
||||
const passwordStrength = ref('LOW')
|
||||
const aiFormatLimit = ref(3)
|
||||
@@ -103,6 +111,7 @@ onMounted(async () => {
|
||||
username.value = user.username
|
||||
introduction.value = user.introduction || ''
|
||||
avatar.value = user.avatar
|
||||
userId.value = user.id
|
||||
role.value = user.role
|
||||
if (role.value === 'ADMIN') {
|
||||
loadAdminConfig()
|
||||
@@ -271,6 +280,11 @@ const save = async () => {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 40px;
|
||||
}
|
||||
|
||||
.avatar-preview :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
</div>
|
||||
<div v-else class="signup-page-button-primary disabled">
|
||||
<div class="signup-page-button-text">
|
||||
<loading-four />
|
||||
<loading-four class="loading-icon" />
|
||||
发送中...
|
||||
</div>
|
||||
</div>
|
||||
@@ -56,7 +56,7 @@
|
||||
</div>
|
||||
<div v-else class="signup-page-button-primary disabled">
|
||||
<div class="signup-page-button-text">
|
||||
<loading-four />
|
||||
<loading-four class="loading-icon" />
|
||||
验证中...
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,12 @@
|
||||
<div v-else>
|
||||
<div class="profile-page-header">
|
||||
<div class="profile-page-header-avatar">
|
||||
<BaseImage :src="user.avatar" alt="avatar" class="profile-page-header-avatar-img" />
|
||||
<BaseUserAvatar
|
||||
:src="user.avatar"
|
||||
:user-id="user.id"
|
||||
alt="avatar"
|
||||
class="profile-page-header-avatar-img"
|
||||
/>
|
||||
</div>
|
||||
<div class="profile-page-header-user-info">
|
||||
<div class="profile-page-header-user-info-name">{{ user.username }}</div>
|
||||
@@ -112,19 +117,18 @@
|
||||
{{ item.comment.post.title }}
|
||||
</NuxtLink>
|
||||
<template v-if="item.comment.parentComment">
|
||||
下对
|
||||
<NuxtLink
|
||||
:to="`/posts/${item.comment.post.id}#comment-${item.comment.parentComment.id}`"
|
||||
class="timeline-link"
|
||||
class="timeline-comment-link"
|
||||
>
|
||||
{{ stripMarkdownLength(item.comment.parentComment.content, 200) }}
|
||||
</NuxtLink>
|
||||
回复了
|
||||
<next class="reply-icon" /> 回复了
|
||||
</template>
|
||||
<template v-else> 下评论了 </template>
|
||||
<NuxtLink
|
||||
:to="`/posts/${item.comment.post.id}#comment-${item.comment.id}`"
|
||||
class="timeline-link"
|
||||
class="timeline-comment-link"
|
||||
>
|
||||
{{ stripMarkdownLength(item.comment.content, 200) }}
|
||||
</NuxtLink>
|
||||
@@ -156,7 +160,7 @@
|
||||
<div class="summary-content" v-if="hotTags.length > 0">
|
||||
<BaseTimeline :items="hotTags">
|
||||
<template #item="{ item }">
|
||||
<TimelineTagItem :item="item" mode="summary" @tag-click="gotoTag" />
|
||||
<TimelineTagItem :item="item" />
|
||||
</template>
|
||||
</BaseTimeline>
|
||||
</div>
|
||||
@@ -273,6 +277,7 @@ import LevelProgress from '~/components/LevelProgress.vue'
|
||||
import TimelineCommentGroup from '~/components/TimelineCommentGroup.vue'
|
||||
import TimelinePostItem from '~/components/TimelinePostItem.vue'
|
||||
import TimelineTagItem from '~/components/TimelineTagItem.vue'
|
||||
import BaseUserAvatar from '~/components/BaseUserAvatar.vue'
|
||||
import UserList from '~/components/UserList.vue'
|
||||
import { toast } from '~/main'
|
||||
import { authState, getToken } from '~/utils/auth'
|
||||
@@ -653,6 +658,11 @@ watch(selectedTab, async (val) => {
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.profile-page-header-avatar-img :deep(.base-user-avatar-img) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
@@ -670,6 +680,11 @@ watch(selectedTab, async (val) => {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.reply-icon {
|
||||
color: var(--primary-color);
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.profile-page-header-user-info-buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -922,8 +937,8 @@ watch(selectedTab, async (val) => {
|
||||
|
||||
.timeline-link {
|
||||
font-weight: bold;
|
||||
color: var(--primary-color);
|
||||
text-decoration: none;
|
||||
color: var(--text-color);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
@@ -1014,6 +1029,7 @@ watch(selectedTab, async (val) => {
|
||||
color: var(--text-color);
|
||||
word-break: break-word;
|
||||
text-decoration: underline;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.timeline-comment-link:hover {
|
||||
@@ -1075,6 +1091,7 @@ watch(selectedTab, async (val) => {
|
||||
.profile-page-header-avatar-img {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
:deep(.base-tabs-item) {
|
||||
|
||||
Reference in New Issue
Block a user