Add frontend messaging experience
This commit is contained in:
10
frontend/src/api/message.ts
Normal file
10
frontend/src/api/message.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { postJson } from './client'
|
||||
import type { DirectMessage, ListMessagesResponse } from './types'
|
||||
|
||||
export function sendMessage(toId: number, content: string) {
|
||||
return postJson<DirectMessage>('/message/send', { to_id: toId, content }, { authRequired: true })
|
||||
}
|
||||
|
||||
export function listMessages(peerId: number) {
|
||||
return postJson<ListMessagesResponse>('/message/list', { peer_id: peerId }, { authRequired: true })
|
||||
}
|
||||
@@ -1,6 +1,19 @@
|
||||
export type MessageResponse = { message: string }
|
||||
|
||||
export type TokenResponse = { token: string; refresh_token?: string; account_id?: number; username?: string }
|
||||
export type MessageResponse = { message: string }
|
||||
|
||||
export type DirectMessage = {
|
||||
id: number
|
||||
from_id: number
|
||||
to_id: number
|
||||
content: string
|
||||
is_read: boolean
|
||||
created_at: string
|
||||
}
|
||||
|
||||
export type ListMessagesResponse = {
|
||||
messages: DirectMessage[]
|
||||
}
|
||||
|
||||
export type TokenResponse = { token: string; refresh_token?: string; account_id?: number; username?: string }
|
||||
|
||||
export type Account = {
|
||||
id: number
|
||||
|
||||
249
frontend/src/components/AppShell.vue
vendored
249
frontend/src/components/AppShell.vue
vendored
@@ -58,11 +58,12 @@ async function goSettings() {
|
||||
|
||||
<nav class="dy-nav">
|
||||
<RouterLink class="dy-nav-link" to="/">推荐</RouterLink>
|
||||
<RouterLink class="dy-nav-link" to="/hot">热榜</RouterLink>
|
||||
<RouterLink class="dy-nav-link" to="/video">发布</RouterLink>
|
||||
<RouterLink class="dy-nav-link" to="/account">账号</RouterLink>
|
||||
<RouterLink class="dy-nav-link" to="/settings">设置</RouterLink>
|
||||
</nav>
|
||||
<RouterLink class="dy-nav-link" to="/hot">热榜</RouterLink>
|
||||
<RouterLink class="dy-nav-link" to="/video">发布</RouterLink>
|
||||
<RouterLink class="dy-nav-link" to="/account">账号</RouterLink>
|
||||
<RouterLink v-if="auth.isLoggedIn" class="dy-nav-link" to="/messages">私信</RouterLink>
|
||||
<RouterLink class="dy-nav-link" to="/settings">设置</RouterLink>
|
||||
</nav>
|
||||
|
||||
<div class="dy-aside-foot">
|
||||
<div class="dy-user">
|
||||
@@ -87,10 +88,18 @@ async function goSettings() {
|
||||
<button class="dy-btn dy-btn-primary" type="button" @click="onSearch">搜索</button>
|
||||
</div>
|
||||
|
||||
<div class="dy-top-right">
|
||||
<RouterLink class="dy-btn dy-btn-ghost" to="/video">+ 发布视频</RouterLink>
|
||||
</div>
|
||||
</header>
|
||||
<div class="dy-top-right">
|
||||
<RouterLink class="dy-btn dy-btn-ghost" to="/video">+ 发布视频</RouterLink>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<nav class="dy-mobile-nav">
|
||||
<RouterLink class="dy-mobile-link" to="/">推荐</RouterLink>
|
||||
<RouterLink class="dy-mobile-link" to="/hot">热榜</RouterLink>
|
||||
<RouterLink class="dy-mobile-link" to="/video">发布</RouterLink>
|
||||
<RouterLink v-if="auth.isLoggedIn" class="dy-mobile-link" to="/messages">私信</RouterLink>
|
||||
<RouterLink class="dy-mobile-link" to="/account">账号</RouterLink>
|
||||
</nav>
|
||||
|
||||
<div class="dy-content" :class="props.full ? 'full' : 'padded'">
|
||||
<template v-if="props.full">
|
||||
@@ -109,57 +118,60 @@ async function goSettings() {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.dy-shell {
|
||||
height: 100vh;
|
||||
display: grid;
|
||||
grid-template-columns: 240px 1fr;
|
||||
background: radial-gradient(1200px 900px at 20% -25%, rgba(254, 44, 85, 0.18), transparent 60%),
|
||||
radial-gradient(900px 700px at 90% 10%, rgba(37, 244, 238, 0.12), transparent 55%), transparent;
|
||||
}
|
||||
|
||||
.dy-aside {
|
||||
border-right: 1px solid rgba(255, 255, 255, 0.08);
|
||||
background: rgba(0, 0, 0, 0.35);
|
||||
backdrop-filter: blur(16px);
|
||||
padding: 14px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
.dy-shell {
|
||||
height: 100vh;
|
||||
display: grid;
|
||||
grid-template-columns: 232px 1fr;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.dy-aside {
|
||||
border-right: 1px solid var(--border);
|
||||
background: rgba(12, 16, 23, 0.78);
|
||||
backdrop-filter: blur(18px);
|
||||
padding: 14px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
.dy-logo {
|
||||
font-weight: 900;
|
||||
letter-spacing: 0.4px;
|
||||
font-size: 18px;
|
||||
padding: 10px 10px;
|
||||
border-radius: 12px;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
font-weight: 900;
|
||||
letter-spacing: 0;
|
||||
font-size: 18px;
|
||||
padding: 10px 10px;
|
||||
border-radius: 8px;
|
||||
background: rgba(43, 161, 255, 0.1);
|
||||
border: 1px solid rgba(43, 161, 255, 0.22);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.dy-nav {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.dy-nav-link {
|
||||
padding: 10px 10px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid transparent;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
.dy-nav-link.router-link-active {
|
||||
border-color: rgba(254, 44, 85, 0.42);
|
||||
background: rgba(254, 44, 85, 0.12);
|
||||
}
|
||||
.dy-nav-link {
|
||||
padding: 10px 10px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid transparent;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
color: rgba(246, 248, 251, 0.86);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.dy-nav-link.router-link-active {
|
||||
border-color: rgba(43, 161, 255, 0.42);
|
||||
background: rgba(43, 161, 255, 0.14);
|
||||
color: rgba(246, 248, 251, 0.96);
|
||||
}
|
||||
|
||||
.dy-aside-foot {
|
||||
margin-top: auto;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.dy-user {
|
||||
@@ -181,14 +193,14 @@ async function goSettings() {
|
||||
box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.14);
|
||||
}
|
||||
|
||||
.dy-user-dot.bad {
|
||||
background: rgba(254, 44, 85, 1);
|
||||
box-shadow: 0 0 0 3px rgba(254, 44, 85, 0.14);
|
||||
}
|
||||
|
||||
.dy-user-name {
|
||||
font-size: 13px;
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
.dy-user-dot.bad {
|
||||
background: rgba(255, 93, 115, 1);
|
||||
box-shadow: 0 0 0 3px rgba(255, 93, 115, 0.14);
|
||||
}
|
||||
|
||||
.dy-user-name {
|
||||
font-size: 13px;
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
@@ -199,12 +211,12 @@ async function goSettings() {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.dy-btn {
|
||||
.dy-btn {
|
||||
appearance: none;
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: var(--text);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
@@ -219,19 +231,19 @@ async function goSettings() {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.dy-btn-primary {
|
||||
border-color: rgba(254, 44, 85, 0.5);
|
||||
background: rgba(254, 44, 85, 0.16);
|
||||
}
|
||||
|
||||
.dy-btn-primary:hover {
|
||||
background: rgba(254, 44, 85, 0.24);
|
||||
}
|
||||
|
||||
.dy-btn-ghost {
|
||||
border-color: rgba(255, 255, 255, 0.14);
|
||||
background: rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
.dy-btn-primary {
|
||||
border-color: rgba(43, 161, 255, 0.5);
|
||||
background: rgba(43, 161, 255, 0.16);
|
||||
}
|
||||
|
||||
.dy-btn-primary:hover {
|
||||
background: rgba(43, 161, 255, 0.24);
|
||||
}
|
||||
|
||||
.dy-btn-ghost {
|
||||
border-color: var(--border);
|
||||
background: rgba(255, 255, 255, 0.045);
|
||||
}
|
||||
|
||||
.dy-main {
|
||||
height: 100vh;
|
||||
@@ -240,11 +252,11 @@ async function goSettings() {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.dy-topbar {
|
||||
height: 56px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||
background: rgba(0, 0, 0, 0.28);
|
||||
backdrop-filter: blur(16px);
|
||||
.dy-topbar {
|
||||
height: 56px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: rgba(12, 16, 23, 0.68);
|
||||
backdrop-filter: blur(18px);
|
||||
display: grid;
|
||||
grid-template-columns: 180px 1fr 180px;
|
||||
gap: 12px;
|
||||
@@ -252,12 +264,12 @@ async function goSettings() {
|
||||
padding: 0 14px;
|
||||
}
|
||||
|
||||
.dy-tabs-hint {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 255, 255, 0.55);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.16em;
|
||||
}
|
||||
.dy-tabs-hint {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.dy-search {
|
||||
display: grid;
|
||||
@@ -269,20 +281,20 @@ async function goSettings() {
|
||||
justify-self: center;
|
||||
}
|
||||
|
||||
.dy-search-input {
|
||||
.dy-search-input {
|
||||
width: 100%;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 999px;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
background: rgba(255, 255, 255, 0.055);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
color: var(--text);
|
||||
padding: 10px 14px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.dy-search-input:focus {
|
||||
border-color: rgba(37, 244, 238, 0.42);
|
||||
box-shadow: 0 0 0 3px rgba(37, 244, 238, 0.14);
|
||||
}
|
||||
.dy-search-input:focus {
|
||||
border-color: rgba(43, 161, 255, 0.52);
|
||||
box-shadow: 0 0 0 3px rgba(43, 161, 255, 0.14);
|
||||
}
|
||||
|
||||
.dy-top-right {
|
||||
display: flex;
|
||||
@@ -298,25 +310,54 @@ async function goSettings() {
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.dy-content.full {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.dy-shell {
|
||||
.dy-content.full {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dy-mobile-nav {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.dy-shell {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.dy-aside {
|
||||
display: none;
|
||||
}
|
||||
.dy-topbar {
|
||||
grid-template-columns: 1fr auto;
|
||||
}
|
||||
.dy-topbar {
|
||||
grid-template-columns: 1fr;
|
||||
padding: 0 10px;
|
||||
}
|
||||
.dy-top-left {
|
||||
display: none;
|
||||
}
|
||||
.dy-top-right {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
.dy-top-right {
|
||||
display: none;
|
||||
}
|
||||
.dy-mobile-nav {
|
||||
height: 48px;
|
||||
display: grid;
|
||||
grid-auto-flow: column;
|
||||
grid-auto-columns: 1fr;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: rgba(12, 16, 23, 0.74);
|
||||
backdrop-filter: blur(18px);
|
||||
}
|
||||
.dy-mobile-link {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
color: var(--muted);
|
||||
font-size: 13px;
|
||||
text-decoration: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
}
|
||||
.dy-mobile-link.router-link-active {
|
||||
color: var(--text);
|
||||
border-bottom-color: var(--primary);
|
||||
}
|
||||
.dy-search {
|
||||
max-width: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -6,10 +6,11 @@ import VideoView from '../views/VideoView.vue'
|
||||
import VideoDetailView from '../views/VideoDetailView.vue'
|
||||
import AccountView from '../views/AccountView.vue'
|
||||
import ChangePasswordView from '../views/ChangePasswordView.vue'
|
||||
import RegisterView from '../views/RegisterView.vue'
|
||||
import SettingsView from '../views/SettingsView.vue'
|
||||
import UserProfileView from '../views/UserProfileView.vue'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
import RegisterView from '../views/RegisterView.vue'
|
||||
import SettingsView from '../views/SettingsView.vue'
|
||||
import UserProfileView from '../views/UserProfileView.vue'
|
||||
import MessageView from '../views/MessageView.vue'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
@@ -22,10 +23,12 @@ const router = createRouter({
|
||||
{ path: '/account', name: 'account', component: AccountView },
|
||||
{ path: '/account/register', name: 'account-register', component: RegisterView },
|
||||
{ path: '/account/change-password', name: 'account-change-password', component: ChangePasswordView },
|
||||
{ path: '/settings', name: 'settings', component: SettingsView, meta: { requiresAuth: true } },
|
||||
{ path: '/u/:id', name: 'user-profile', component: UserProfileView, props: true },
|
||||
],
|
||||
})
|
||||
{ path: '/settings', name: 'settings', component: SettingsView, meta: { requiresAuth: true } },
|
||||
{ path: '/u/:id', name: 'user-profile', component: UserProfileView, props: true },
|
||||
{ path: '/messages', name: 'message-list', component: MessageView, meta: { requiresAuth: true } },
|
||||
{ path: '/messages/:peerId', name: 'messages', component: MessageView, meta: { requiresAuth: true } },
|
||||
],
|
||||
})
|
||||
|
||||
router.beforeEach((to, _from, next) => {
|
||||
const auth = useAuthStore()
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--bg: #0b0b0f;
|
||||
--panel: rgba(255, 255, 255, 0.06);
|
||||
--panel-2: rgba(255, 255, 255, 0.1);
|
||||
--text: rgba(255, 255, 255, 0.92);
|
||||
--muted: rgba(255, 255, 255, 0.64);
|
||||
--border: rgba(255, 255, 255, 0.12);
|
||||
--primary: #fe2c55;
|
||||
--primary-2: #25f4ee;
|
||||
--danger: #fe2c55;
|
||||
--ok: #22c55e;
|
||||
font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji',
|
||||
'Segoe UI Emoji';
|
||||
:root {
|
||||
color-scheme: dark;
|
||||
--bg: #0e1117;
|
||||
--bg-soft: #141922;
|
||||
--panel: rgba(22, 27, 37, 0.82);
|
||||
--panel-2: rgba(35, 42, 55, 0.78);
|
||||
--text: rgba(246, 248, 251, 0.94);
|
||||
--muted: rgba(205, 214, 226, 0.68);
|
||||
--border: rgba(155, 171, 195, 0.18);
|
||||
--primary: #2ba1ff;
|
||||
--primary-2: #22c55e;
|
||||
--danger: #ff5d73;
|
||||
--ok: #22c55e;
|
||||
--shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
|
||||
font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, 'Apple Color Emoji',
|
||||
'Segoe UI Emoji';
|
||||
line-height: 1.5;
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
@@ -25,55 +27,65 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* Hide scrollbars globally (still scrollable). */
|
||||
* {
|
||||
scrollbar-width: none; /* Firefox */
|
||||
-ms-overflow-style: none; /* IE/Edge legacy */
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: radial-gradient(1200px 900px at 20% -25%, rgba(254, 44, 85, 0.18), transparent 60%),
|
||||
radial-gradient(900px 700px at 90% 10%, rgba(37, 244, 238, 0.12), transparent 55%), var(--bg);
|
||||
color: var(--text);
|
||||
}
|
||||
* {
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: rgba(155, 171, 195, 0.35) transparent;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-thumb {
|
||||
background: rgba(155, 171, 195, 0.28);
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
*::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background:
|
||||
radial-gradient(1000px 720px at 10% -20%, rgba(43, 161, 255, 0.14), transparent 58%),
|
||||
linear-gradient(180deg, #10141d 0%, var(--bg) 42%, #0b0e14 100%);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1100px;
|
||||
margin: 0 auto;
|
||||
padding: 24px 16px 56px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 16px;
|
||||
padding: 16px;
|
||||
backdrop-filter: blur(10px);
|
||||
}
|
||||
|
||||
.card + .card {
|
||||
margin-top: 14px;
|
||||
}
|
||||
a:hover {
|
||||
color: #dceeff;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
padding: 22px 18px 56px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
padding: 18px;
|
||||
backdrop-filter: blur(14px);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.card + .card {
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
@@ -106,11 +118,12 @@ a:hover {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
margin: 0 0 6px;
|
||||
}
|
||||
.title {
|
||||
font-size: 18px;
|
||||
font-weight: 800;
|
||||
margin: 0 0 6px;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.subtle {
|
||||
font-size: 13px;
|
||||
@@ -124,53 +137,56 @@ label {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
input,
|
||||
textarea,
|
||||
select {
|
||||
width: 100%;
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
color: var(--text);
|
||||
padding: 10px 12px;
|
||||
outline: none;
|
||||
}
|
||||
input,
|
||||
textarea,
|
||||
select {
|
||||
width: 100%;
|
||||
background: rgba(255, 255, 255, 0.055);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
color: var(--text);
|
||||
padding: 11px 12px;
|
||||
outline: none;
|
||||
transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
|
||||
}
|
||||
|
||||
textarea {
|
||||
min-height: 88px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
input:focus,
|
||||
textarea:focus,
|
||||
select:focus {
|
||||
border-color: rgba(124, 92, 255, 0.8);
|
||||
box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.22);
|
||||
}
|
||||
|
||||
button {
|
||||
appearance: none;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
color: var(--text);
|
||||
border-radius: 12px;
|
||||
padding: 10px 14px;
|
||||
cursor: pointer;
|
||||
transition: 120ms ease;
|
||||
}
|
||||
input:focus,
|
||||
textarea:focus,
|
||||
select:focus {
|
||||
border-color: rgba(43, 161, 255, 0.72);
|
||||
box-shadow: 0 0 0 3px rgba(43, 161, 255, 0.18);
|
||||
background: rgba(255, 255, 255, 0.075);
|
||||
}
|
||||
|
||||
button {
|
||||
appearance: none;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
color: var(--text);
|
||||
border-radius: 8px;
|
||||
padding: 10px 14px;
|
||||
cursor: pointer;
|
||||
transition: 120ms ease;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
|
||||
button.primary {
|
||||
border-color: rgba(254, 44, 85, 0.55);
|
||||
background: rgba(254, 44, 85, 0.18);
|
||||
}
|
||||
|
||||
button.primary:hover {
|
||||
background: rgba(254, 44, 85, 0.26);
|
||||
}
|
||||
button.primary {
|
||||
border-color: rgba(43, 161, 255, 0.55);
|
||||
background: rgba(43, 161, 255, 0.18);
|
||||
}
|
||||
|
||||
button.primary:hover {
|
||||
background: rgba(43, 161, 255, 0.26);
|
||||
}
|
||||
|
||||
button.danger {
|
||||
border-color: rgba(255, 77, 109, 0.65);
|
||||
@@ -186,12 +202,12 @@ button:disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.pill {
|
||||
.pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 10px;
|
||||
border-radius: 999px;
|
||||
padding: 6px 10px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
font-size: 13px;
|
||||
@@ -211,14 +227,28 @@ button:disabled {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
||||
}
|
||||
|
||||
.pre {
|
||||
.pre {
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
font-size: 13px;
|
||||
line-height: 1.45;
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 12px;
|
||||
padding: 12px;
|
||||
margin: 0;
|
||||
}
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.container {
|
||||
padding: 14px 12px 76px;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.row {
|
||||
gap: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
100
frontend/src/views/AccountView.vue
vendored
100
frontend/src/views/AccountView.vue
vendored
@@ -349,23 +349,23 @@ watch(
|
||||
width: min(420px, 100%);
|
||||
}
|
||||
|
||||
.ghost {
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
background: rgba(0, 0, 0, 0.18);
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
border-radius: 12px;
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.ghost {
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.055);
|
||||
color: var(--text);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ghost:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.metric {
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border-radius: 16px;
|
||||
.metric {
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border-radius: 8px;
|
||||
padding: 12px 14px;
|
||||
min-width: 120px;
|
||||
cursor: pointer;
|
||||
@@ -378,10 +378,10 @@ watch(
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.metric.active {
|
||||
background: rgba(254, 44, 85, 0.14);
|
||||
border-color: rgba(254, 44, 85, 0.55);
|
||||
}
|
||||
.metric.active {
|
||||
background: rgba(43, 161, 255, 0.14);
|
||||
border-color: rgba(43, 161, 255, 0.55);
|
||||
}
|
||||
|
||||
.metric.static {
|
||||
cursor: default;
|
||||
@@ -398,18 +398,18 @@ watch(
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 255, 255, 0.65);
|
||||
}
|
||||
|
||||
.hint {
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
}
|
||||
|
||||
.hint.bad {
|
||||
color: rgba(254, 44, 85, 0.92);
|
||||
}
|
||||
.metric-label {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.hint {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.hint.bad {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.drawer-backdrop {
|
||||
position: fixed;
|
||||
@@ -423,12 +423,12 @@ watch(
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.drawer {
|
||||
.drawer {
|
||||
width: min(520px, calc(100vw - 18px));
|
||||
max-height: min(78vh, 720px);
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 18px;
|
||||
background: rgba(13, 18, 29, 0.92);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr;
|
||||
@@ -439,7 +439,7 @@ watch(
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 14px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.drawer-title {
|
||||
@@ -449,8 +449,8 @@ watch(
|
||||
.drawer-x {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
cursor: pointer;
|
||||
@@ -465,14 +465,14 @@ watch(
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.drawer-hint {
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
.drawer-hint {
|
||||
color: var(--muted);
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.drawer-hint.bad {
|
||||
color: rgba(254, 44, 85, 0.92);
|
||||
}
|
||||
.drawer-hint.bad {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.video-grid {
|
||||
display: grid;
|
||||
@@ -492,10 +492,10 @@ watch(
|
||||
}
|
||||
}
|
||||
|
||||
.video-card {
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 16px;
|
||||
.video-card {
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
@@ -539,8 +539,8 @@ watch(
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
padding: 10px 10px;
|
||||
border-radius: 14px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -557,10 +557,10 @@ watch(
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.user-id {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
.user-id {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
||||
|
||||
503
frontend/src/views/MessageView.vue
vendored
Normal file
503
frontend/src/views/MessageView.vue
vendored
Normal file
@@ -0,0 +1,503 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
import AppShell from '../components/AppShell.vue'
|
||||
import UserAvatar from '../components/UserAvatar.vue'
|
||||
import { ApiError } from '../api/client'
|
||||
import * as accountApi from '../api/account'
|
||||
import * as messageApi from '../api/message'
|
||||
import type { Account, DirectMessage } from '../api/types'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
import { useSocialStore } from '../stores/social'
|
||||
import { useToastStore } from '../stores/toast'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
const social = useSocialStore()
|
||||
const toast = useToastStore()
|
||||
|
||||
const peerId = computed(() => {
|
||||
const raw = route.params.peerId
|
||||
return typeof raw === 'string' ? Number(raw) : 0
|
||||
})
|
||||
const myId = computed(() => auth.claims?.account_id ?? 0)
|
||||
const hasPeer = computed(() => Number.isFinite(peerId.value) && peerId.value > 0)
|
||||
const listEl = ref<HTMLDivElement | null>(null)
|
||||
const content = ref('')
|
||||
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
sending: false,
|
||||
error: '',
|
||||
peer: null as Account | null,
|
||||
messages: [] as DirectMessage[],
|
||||
})
|
||||
|
||||
const orderedMessages = computed(() => [...state.messages].sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime()))
|
||||
const canSend = computed(() => content.value.trim().length > 0 && !state.sending && !!state.peer && peerId.value > 0)
|
||||
const contactItems = computed(() => {
|
||||
const map = new Map<number, Account>()
|
||||
for (const user of social.vloggers) map.set(user.id, user)
|
||||
for (const user of social.followers) map.set(user.id, user)
|
||||
return [...map.values()].filter((user) => user.id !== myId.value)
|
||||
})
|
||||
const contactLoading = computed(() => social.vloggersLoading || social.followersLoading)
|
||||
const contactError = computed(() => social.vloggersError || social.followersError)
|
||||
|
||||
function formatTime(value: string) {
|
||||
const date = new Date(value)
|
||||
if (Number.isNaN(date.getTime())) return ''
|
||||
return date.toLocaleString([], { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })
|
||||
}
|
||||
|
||||
async function scrollToBottom() {
|
||||
await nextTick()
|
||||
if (listEl.value) listEl.value.scrollTop = listEl.value.scrollHeight
|
||||
}
|
||||
|
||||
async function loadChat() {
|
||||
if (!auth.isLoggedIn) {
|
||||
await router.push({ path: '/account', query: { redirect: route.fullPath } })
|
||||
return
|
||||
}
|
||||
if (!hasPeer.value) {
|
||||
await social.refreshMine()
|
||||
state.loading = false
|
||||
state.error = ''
|
||||
state.peer = null
|
||||
state.messages = []
|
||||
return
|
||||
}
|
||||
if (!Number.isFinite(peerId.value) || peerId.value <= 0) {
|
||||
state.error = '无效的用户 id'
|
||||
return
|
||||
}
|
||||
if (peerId.value === myId.value) {
|
||||
state.error = '请选择其他用户发送私信'
|
||||
return
|
||||
}
|
||||
|
||||
state.loading = true
|
||||
state.error = ''
|
||||
try {
|
||||
const [peer, res] = await Promise.all([accountApi.findById(peerId.value), messageApi.listMessages(peerId.value)])
|
||||
state.peer = peer
|
||||
state.messages = res.messages ?? []
|
||||
await scrollToBottom()
|
||||
} catch (e) {
|
||||
state.error = e instanceof ApiError ? e.message : String(e)
|
||||
state.peer = null
|
||||
state.messages = []
|
||||
} finally {
|
||||
state.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
async function send() {
|
||||
const text = content.value.trim()
|
||||
if (!text || state.sending || !state.peer) return
|
||||
|
||||
state.sending = true
|
||||
try {
|
||||
const msg = await messageApi.sendMessage(peerId.value, text)
|
||||
state.messages = [msg, ...state.messages]
|
||||
content.value = ''
|
||||
await scrollToBottom()
|
||||
} catch (e) {
|
||||
const msg = e instanceof ApiError ? e.message : String(e)
|
||||
toast.error(msg)
|
||||
} finally {
|
||||
state.sending = false
|
||||
}
|
||||
}
|
||||
|
||||
async function goPeerProfile() {
|
||||
if (state.peer) await router.push(`/u/${state.peer.id}`)
|
||||
}
|
||||
|
||||
async function openChat(userId: number) {
|
||||
await router.push(`/messages/${userId}`)
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.params.peerId,
|
||||
() => {
|
||||
state.peer = null
|
||||
state.messages = []
|
||||
content.value = ''
|
||||
void loadChat()
|
||||
},
|
||||
)
|
||||
|
||||
onMounted(loadChat)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppShell>
|
||||
<section class="chat-shell">
|
||||
<div v-if="!hasPeer" class="contact-panel">
|
||||
<div class="contact-head">
|
||||
<div>
|
||||
<p class="title">私信</p>
|
||||
<p class="subtle">选择关注或粉丝里的用户开始聊天。</p>
|
||||
</div>
|
||||
<button class="ghost small" type="button" :disabled="contactLoading" @click="social.refreshMine">刷新</button>
|
||||
</div>
|
||||
|
||||
<div class="contact-body">
|
||||
<div v-if="contactLoading" class="chat-hint">加载中…</div>
|
||||
<div v-else-if="contactError" class="chat-hint bad">{{ contactError }}</div>
|
||||
<div v-else-if="contactItems.length === 0" class="empty">
|
||||
<div class="empty-title">暂无可聊天用户</div>
|
||||
<div class="empty-text">关注别人或拥有粉丝后,可以从这里开始私信。</div>
|
||||
</div>
|
||||
|
||||
<button v-for="user in contactItems" :key="user.id" class="contact-row" type="button" @click="openChat(user.id)">
|
||||
<UserAvatar :username="user.username" :id="user.id" :size="42" />
|
||||
<span class="contact-meta">
|
||||
<span class="contact-name">@{{ user.username }}</span>
|
||||
<span class="contact-id mono">#{{ user.id }}</span>
|
||||
</span>
|
||||
<span class="contact-action">聊天</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="chat-panel">
|
||||
<header class="chat-head">
|
||||
<button class="icon-btn" type="button" title="返回" @click="router.back()">‹</button>
|
||||
<button class="peer" type="button" :disabled="!state.peer" @click="goPeerProfile">
|
||||
<UserAvatar :username="state.peer?.username ?? 'User'" :id="state.peer?.id ?? peerId" :size="44" />
|
||||
<span class="peer-meta">
|
||||
<span class="peer-name">@{{ state.peer?.username ?? '加载中' }}</span>
|
||||
<span class="peer-id mono">#{{ state.peer?.id ?? peerId }}</span>
|
||||
</span>
|
||||
</button>
|
||||
<button class="ghost small" type="button" :disabled="state.loading" @click="loadChat">刷新</button>
|
||||
</header>
|
||||
|
||||
<div ref="listEl" class="message-list">
|
||||
<div v-if="state.loading" class="chat-hint">加载中…</div>
|
||||
<div v-else-if="state.error" class="chat-hint bad">{{ state.error }}</div>
|
||||
<div v-else-if="orderedMessages.length === 0" class="empty">
|
||||
<div class="empty-title">开始聊天</div>
|
||||
<div class="empty-text">给 @{{ state.peer?.username ?? '对方' }} 发第一条消息。</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-for="msg in orderedMessages"
|
||||
:key="msg.id"
|
||||
class="bubble-row"
|
||||
:class="{ mine: msg.from_id === myId }"
|
||||
>
|
||||
<UserAvatar
|
||||
v-if="msg.from_id !== myId"
|
||||
:username="state.peer?.username ?? 'User'"
|
||||
:id="state.peer?.id ?? msg.from_id"
|
||||
:size="32"
|
||||
/>
|
||||
<div class="bubble-wrap">
|
||||
<div class="bubble">{{ msg.content }}</div>
|
||||
<div class="bubble-time">{{ formatTime(msg.created_at) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="composer">
|
||||
<textarea
|
||||
v-model="content"
|
||||
placeholder="输入私信内容"
|
||||
:disabled="!!state.error || state.loading || state.sending"
|
||||
@keydown.enter.exact.prevent="send"
|
||||
/>
|
||||
<button class="primary send-btn" type="button" :disabled="!canSend" @click="send">
|
||||
{{ state.sending ? '发送中' : '发送' }}
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
</section>
|
||||
</AppShell>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.chat-shell {
|
||||
min-height: calc(100vh - 104px);
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.contact-panel,
|
||||
.chat-panel {
|
||||
height: min(760px, calc(100vh - 136px));
|
||||
min-height: 560px;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(13, 18, 29, 0.78);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
|
||||
}
|
||||
|
||||
.contact-panel,
|
||||
.chat-panel {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.contact-panel {
|
||||
grid-template-rows: auto 1fr;
|
||||
}
|
||||
|
||||
.chat-panel {
|
||||
grid-template-rows: auto 1fr auto;
|
||||
}
|
||||
|
||||
.contact-head,
|
||||
.chat-head {
|
||||
min-height: 68px;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
padding: 12px 14px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.035);
|
||||
}
|
||||
|
||||
.contact-head {
|
||||
grid-template-columns: 1fr auto;
|
||||
}
|
||||
|
||||
.contact-head .title {
|
||||
margin: 0 0 4px;
|
||||
}
|
||||
|
||||
.chat-head {
|
||||
grid-template-columns: auto 1fr auto;
|
||||
}
|
||||
|
||||
.contact-body {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 14px;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
.contact-row {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr) auto;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
text-align: left;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.contact-row:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.contact-meta {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.contact-name {
|
||||
font-weight: 800;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.contact-id,
|
||||
.contact-action {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.contact-action {
|
||||
color: rgba(190, 223, 255, 0.92);
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
padding: 0;
|
||||
border-radius: 8px;
|
||||
font-size: 28px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.peer {
|
||||
min-width: 0;
|
||||
display: inline-grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
justify-self: start;
|
||||
padding: 4px 8px 4px 4px;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.peer:disabled {
|
||||
opacity: 0.72;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.peer-meta {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.peer-name {
|
||||
font-weight: 800;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.peer-id {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.message-list {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 18px 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.chat-hint {
|
||||
margin: auto;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.chat-hint.bad {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.empty {
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.empty-title {
|
||||
color: var(--text);
|
||||
font-weight: 900;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.bubble-row {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
gap: 10px;
|
||||
align-items: end;
|
||||
}
|
||||
|
||||
.bubble-row.mine {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
justify-items: end;
|
||||
}
|
||||
|
||||
.bubble-wrap {
|
||||
max-width: min(68%, 560px);
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.bubble {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 8px;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.mine .bubble {
|
||||
border-color: rgba(43, 161, 255, 0.42);
|
||||
background: rgba(43, 161, 255, 0.22);
|
||||
}
|
||||
|
||||
.bubble-time {
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.mine .bubble-time {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.composer {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
align-items: end;
|
||||
padding: 12px 14px;
|
||||
border-top: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.035);
|
||||
}
|
||||
|
||||
.composer textarea {
|
||||
min-height: 44px;
|
||||
max-height: 132px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
min-width: 86px;
|
||||
height: 44px;
|
||||
}
|
||||
|
||||
.ghost.small {
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.chat-shell {
|
||||
min-height: calc(100vh - 56px);
|
||||
}
|
||||
|
||||
.chat-panel {
|
||||
min-height: calc(100vh - 92px);
|
||||
height: calc(100vh - 92px);
|
||||
}
|
||||
|
||||
.contact-panel {
|
||||
min-height: calc(100vh - 92px);
|
||||
height: calc(100vh - 92px);
|
||||
}
|
||||
|
||||
.contact-head {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.bubble-wrap {
|
||||
max-width: 86%;
|
||||
}
|
||||
|
||||
.composer {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.send-btn {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
133
frontend/src/views/UserProfileView.vue
vendored
133
frontend/src/views/UserProfileView.vue
vendored
@@ -82,9 +82,9 @@ async function loadSocialCounts() {
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleFollow() {
|
||||
if (isMe.value) return
|
||||
if (!auth.isLoggedIn) {
|
||||
async function toggleFollow() {
|
||||
if (isMe.value) return
|
||||
if (!auth.isLoggedIn) {
|
||||
toast.error('请先登录')
|
||||
await router.push('/account')
|
||||
return
|
||||
@@ -102,8 +102,18 @@ async function toggleFollow() {
|
||||
} catch (e) {
|
||||
const msg = e instanceof ApiError ? e.message : String(e)
|
||||
toast.error(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function goMessage() {
|
||||
if (isMe.value) return
|
||||
if (!auth.isLoggedIn) {
|
||||
toast.error('请先登录')
|
||||
await router.push({ path: '/account', query: { redirect: route.fullPath } })
|
||||
return
|
||||
}
|
||||
await router.push(`/messages/${userId.value}`)
|
||||
}
|
||||
|
||||
type ListTab = 'followers' | 'following'
|
||||
const drawer = reactive({
|
||||
@@ -167,13 +177,16 @@ onMounted(loadProfile)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<button v-if="isMe" class="ghost" type="button" @click="router.push('/account')">我的账号</button>
|
||||
<button v-else class="primary" type="button" :disabled="!state.user || state.loading" @click="toggleFollow">
|
||||
{{ isFollowing ? '已关注' : '关注' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<button v-if="isMe" class="ghost" type="button" @click="router.push('/account')">我的账号</button>
|
||||
<template v-else>
|
||||
<button class="ghost" type="button" :disabled="!state.user || state.loading" @click="goMessage">私信</button>
|
||||
<button class="primary" type="button" :disabled="!state.user || state.loading" @click="toggleFollow">
|
||||
{{ isFollowing ? '已关注' : '关注' }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="state.loading" class="hint" style="margin-top: 12px">加载中…</div>
|
||||
<div v-else-if="state.error" class="hint bad" style="margin-top: 12px">{{ state.error }}</div>
|
||||
@@ -240,25 +253,25 @@ onMounted(loadProfile)
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.ghost {
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
background: rgba(0, 0, 0, 0.18);
|
||||
color: rgba(255, 255, 255, 0.86);
|
||||
border-radius: 12px;
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.ghost {
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.055);
|
||||
color: var(--text);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ghost:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.metric {
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border-radius: 16px;
|
||||
padding: 12px 14px;
|
||||
min-width: 120px;
|
||||
.metric {
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
border-radius: 8px;
|
||||
padding: 12px 14px;
|
||||
min-width: 120px;
|
||||
cursor: pointer;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
@@ -284,18 +297,18 @@ onMounted(loadProfile)
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
.metric-label {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 255, 255, 0.65);
|
||||
}
|
||||
|
||||
.hint {
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
}
|
||||
|
||||
.hint.bad {
|
||||
color: rgba(254, 44, 85, 0.92);
|
||||
}
|
||||
.metric-label {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.hint {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.hint.bad {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.video-grid {
|
||||
display: grid;
|
||||
@@ -315,10 +328,10 @@ onMounted(loadProfile)
|
||||
}
|
||||
}
|
||||
|
||||
.video-card {
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 16px;
|
||||
.video-card {
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
@@ -367,12 +380,12 @@ onMounted(loadProfile)
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.drawer {
|
||||
.drawer {
|
||||
width: min(520px, calc(100vw - 18px));
|
||||
max-height: min(78vh, 720px);
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||
border-radius: 18px;
|
||||
background: rgba(13, 18, 29, 0.92);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr;
|
||||
@@ -383,7 +396,7 @@ onMounted(loadProfile)
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 14px 14px;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.drawer-title {
|
||||
@@ -393,8 +406,8 @@ onMounted(loadProfile)
|
||||
.drawer-x {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 12px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.14);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.06);
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
cursor: pointer;
|
||||
@@ -409,14 +422,14 @@ onMounted(loadProfile)
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.drawer-hint {
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
.drawer-hint {
|
||||
color: var(--muted);
|
||||
padding: 12px 0;
|
||||
}
|
||||
|
||||
.drawer-hint.bad {
|
||||
color: rgba(254, 44, 85, 0.92);
|
||||
}
|
||||
.drawer-hint.bad {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.user-row {
|
||||
text-align: left;
|
||||
@@ -425,8 +438,8 @@ onMounted(loadProfile)
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
padding: 10px 10px;
|
||||
border-radius: 14px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border);
|
||||
background: rgba(255, 255, 255, 0.05);
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -443,10 +456,10 @@ onMounted(loadProfile)
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.user-id {
|
||||
font-size: 12px;
|
||||
color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
.user-id {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.mono {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
|
||||
|
||||
Reference in New Issue
Block a user