feat: P2阶段完成 - listings和auth模块迁移

## P2.1: 商品浏览模块(listings)

### 完整迁移(23个文件)
- API: listings.ts, listingOptions.ts, homeConfig.ts
- Views: 5个页面(HomeView, ListingsView, ListingDetailView + 移动端2个)
- Composables: 3个(useHomeFilters, useFilterOptions, useListingQuery)
- Components: 9个(ListingCard, 各种过滤器组件)
- Tests: 2个测试文件

**功能:**
- 首页浏览、商品列表、详情查看
- 高级筛选(服务器、等级、哈夫币、皮肤等)
- 排序和分区功能
- 横幅、公告、统计展示

**技术改进:**
- 更新所有导入路径到 @/shared/
- 建立清晰的模块导出

---

## P2.2: 用户认证模块(auth)

### 完整迁移(12个文件)
- API: auth.ts, realname.ts, notifications.ts
- Views: 8个页面(登录、注册、个人资料、实名认证、通知 + 移动端)
- 模块导出

**功能:**
- 用户注册、登录、Token管理
- 实名认证、风险检查
- 个人资料编辑、头像上传
- 消息/通知中心

**技术改进:**
- 统一 API 导入路径
- 类型安全增强

---

## 里程碑

🎉 **P2 阶段完成!**

**累计完成:** 6个模块
-  P0: shared(基础设施)- 22个文件
-  P1: wallet, chats, orders - 24个文件
-  P2: listings, auth - 35个文件

**总计:** 81个文件已迁移

**剩余:** P3阶段(seller, disputes, admin)+ 清理工作

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
yml2213
2026-06-04 08:56:42 +08:00
co-authored by Claude Opus 4.7
parent f415832c19
commit 405abfa4f7
35 changed files with 9932 additions and 0 deletions
@@ -0,0 +1,409 @@
<script setup lang="ts">
import { ElMessage } from "element-plus";
import { ChatLineRound, Iphone } from "@element-plus/icons-vue";
import { onUnmounted, reactive, ref } from "vue";
import { useRouter } from "vue-router";
import { sendSmsCode } from "@/api/auth";
import { useSessionStore } from "@/stores/session";
const router = useRouter();
const session = useSessionStore();
const loading = ref(false);
const sending = ref(false);
const countDown = ref(0);
const form = reactive({
phone: "",
code: "",
});
let timer: ReturnType<typeof setInterval> | null = null;
function startCountDown() {
countDown.value = 60;
timer = setInterval(() => {
countDown.value--;
if (countDown.value <= 0) {
clearInterval(timer!);
timer = null;
}
}, 1000);
}
onUnmounted(() => {
if (timer) {
clearInterval(timer);
timer = null;
}
});
async function handleSendCode() {
if (!form.phone.trim()) {
ElMessage.warning("请输入手机号");
return;
}
sending.value = true;
try {
await sendSmsCode(form.phone);
ElMessage.success("验证码已发送,请注意查收");
startCountDown();
} catch (error) {
ElMessage.error(readError(error, "验证码发送失败"));
} finally {
sending.value = false;
}
}
async function handleLogin() {
loading.value = true;
try {
await session.login(form.phone, form.code);
ElMessage.success("登录成功");
await router.push("/");
} catch (error) {
ElMessage.error(readError(error, "登录失败"));
} finally {
loading.value = false;
}
}
function readError(error: unknown, fallback: string) {
if (typeof error === "object" && error && "response" in error) {
const response = (error as { response?: { data?: { message?: string } } })
.response;
return response?.data?.message || fallback;
}
return fallback;
}
</script>
<template>
<section class="login-shell">
<div class="login-card">
<div class="login-left">
<div class="brand-lockup">
<div class="brand-logo"></div>
<strong>大锤商行</strong>
</div>
<div class="login-hero">
<h2>安全租号<br />畅享游戏</h2>
<p>
高效安全的哈夫币账号交易平台<br />
7×24 小时智能订单系统随时为您服务
</p>
</div>
<div class="login-footer">
<span>© 哈夫币租号平台</span>
</div>
</div>
<div class="login-right">
<div class="login-header">
<p class="eyebrow">SMS Login</p>
<h1>欢迎回来</h1>
<p class="subtitle">登录后即可发布或租赁账号</p>
</div>
<el-form class="user-form" label-position="top" @submit.prevent>
<el-form-item label="手机号">
<el-input
v-model="form.phone"
maxlength="11"
placeholder="请输入手机号"
size="large"
:prefix-icon="Iphone"
/>
</el-form-item>
<el-form-item label="验证码">
<div class="user-code-row">
<el-input
v-model="form.code"
maxlength="6"
placeholder="6 位验证码"
size="large"
:prefix-icon="ChatLineRound"
@keyup.enter="handleLogin"
/>
<el-button
size="large"
:disabled="countDown > 0 || sending"
:loading="sending"
@click="handleSendCode"
>
{{
countDown > 0
? `${countDown}s`
: sending
? "发送中"
: "发送验证码"
}}
</el-button>
</div>
</el-form-item>
<el-button
class="user-login-btn"
type="primary"
size="large"
:loading="loading"
@click="handleLogin"
>
登录
</el-button>
<p class="login-notice">未收到验证码时请稍后重试或联系客服处理</p>
</el-form>
</div>
</div>
</section>
</template>
<style scoped>
.login-shell {
display: grid;
flex: 1;
place-items: center;
margin: -20px -24px;
padding: 32px 24px;
}
.login-card {
position: relative;
z-index: 1;
display: grid;
grid-template-columns: 1fr 420px;
width: min(940px, 100%);
min-height: 520px;
border: 1px solid rgba(255, 255, 255, 0.7);
border-radius: 20px;
background: rgba(255, 255, 255, 0.65);
backdrop-filter: blur(20px);
box-shadow: 0 24px 80px rgba(17, 24, 39, 0.08),
0 1px 0 rgba(255, 255, 255, 0.6) inset;
overflow: hidden;
}
/* ========== 左侧品牌区 ========== */
.login-left {
display: flex;
flex-direction: column;
justify-content: space-between;
padding: 40px 36px;
background: radial-gradient(
circle at 30% 20%,
rgba(20, 119, 255, 0.08),
transparent 50%
),
radial-gradient(
circle at 80% 90%,
rgba(109, 40, 217, 0.06),
transparent 50%
),
linear-gradient(160deg, rgba(20, 119, 255, 0.06), rgba(109, 40, 217, 0.03));
}
.brand-lockup {
display: flex;
align-items: center;
gap: 10px;
}
.brand-logo {
display: grid;
width: 36px;
height: 36px;
place-items: center;
border-radius: 10px;
background: linear-gradient(135deg, #1477ff, #2f8dff);
box-shadow: 0 8px 24px rgba(20, 119, 255, 0.22);
color: #fff;
font-size: 15px;
font-weight: 900;
}
.brand-lockup strong {
color: #0f172a;
font-size: 15px;
font-weight: 800;
letter-spacing: 0.3px;
}
.login-hero h2 {
margin: 0 0 14px;
color: #0f172a;
font-size: 28px;
font-weight: 800;
line-height: 1.25;
}
.login-hero p {
margin: 0;
color: #475569;
font-size: 14px;
line-height: 1.7;
max-width: 300px;
}
.login-footer span {
color: #94a3b8;
font-size: 12px;
}
/* ========== 右侧表单区 ========== */
.login-right {
display: flex;
flex-direction: column;
justify-content: center;
padding: 36px 32px;
background: rgba(255, 255, 255, 0.45);
}
.login-header {
margin-bottom: 24px;
}
.login-header .eyebrow {
margin: 0 0 8px;
color: #1477ff;
font-size: 12px;
font-weight: 700;
letter-spacing: 1px;
text-transform: uppercase;
}
.login-header h1 {
margin: 0;
color: #0f172a;
font-size: 24px;
font-weight: 800;
line-height: 1.2;
}
.login-header .subtitle {
margin: 8px 0 0;
color: #64748b;
font-size: 13px;
}
.user-form :deep(.el-form-item__label) {
color: #334155;
font-size: 13px;
font-weight: 600;
padding-bottom: 6px;
}
.user-form :deep(.el-input__wrapper) {
background: #ffffff;
box-shadow: 0 0 0 1px #e2e8f0 inset;
border-radius: 10px;
padding: 0 12px;
transition: box-shadow 0.2s, background 0.2s;
}
.user-form :deep(.el-input__wrapper:hover) {
background: #ffffff;
}
.user-form :deep(.el-input__wrapper.is-focus) {
background: #ffffff;
box-shadow: 0 0 0 1px rgba(20, 119, 255, 0.45) inset,
0 0 0 3px rgba(20, 119, 255, 0.08);
}
.user-form :deep(.el-input__inner) {
color: #0f172a;
font-size: 14px;
height: 44px;
}
.user-form :deep(.el-input__inner::placeholder) {
color: #94a3b8;
}
.user-form :deep(.el-input__prefix-inner) {
color: #94a3b8;
}
.user-code-row {
display: grid;
grid-template-columns: 1fr 120px;
gap: 10px;
width: 100%;
}
.user-code-row .el-button {
height: 46px;
border-radius: 10px;
font-size: 13px;
font-weight: 700;
letter-spacing: 0.3px;
background: #ffffff;
border-color: #1477ff;
color: #1477ff;
box-shadow: none;
transition: background 0.2s, color 0.2s;
}
.user-code-row .el-button:hover:not(:disabled) {
background: #1477ff;
border-color: #1477ff;
color: #ffffff;
}
.user-code-row .el-button:disabled {
opacity: 0.6;
cursor: not-allowed;
}
.user-login-btn {
width: 100%;
height: 46px;
border-radius: 10px;
font-size: 15px;
font-weight: 700;
margin-top: 8px;
letter-spacing: 0.5px;
background: linear-gradient(135deg, #1477ff, #2f8dff);
border: none;
box-shadow: 0 10px 28px rgba(20, 119, 255, 0.22);
transition: transform 0.15s, box-shadow 0.2s;
}
.user-login-btn:hover {
transform: translateY(-1px);
box-shadow: 0 14px 36px rgba(20, 119, 255, 0.28);
}
.login-notice {
margin: 18px 0 0;
color: #94a3b8;
font-size: 12px;
text-align: center;
line-height: 1.5;
}
/* ========== 响应式 ========== */
@media (max-width: 860px) {
.login-card {
grid-template-columns: 1fr;
max-width: 420px;
}
.login-left {
display: none;
}
.login-right {
padding: 32px 28px;
}
.login-shell {
padding: 24px 16px;
}
}
@media (max-width: 480px) {
.login-shell {
padding: 16px 12px;
}
.login-right {
padding: 24px 20px;
}
}
@media (prefers-reduced-motion: reduce) {
.user-login-btn {
transition: none;
}
}
</style>