- 在系统设置「功能开关」中新增邀请返利总开关,默认关闭;
关闭态:菜单隐藏、注册忽略 aff、新充值不返利,但已有 quota 仍可转余额
- 支持管理员为指定用户设置专属邀请码(覆盖随机码,全局唯一)
- 支持管理员为指定用户设置专属返利比例(覆盖全局比例,可单条/批量调整)
- 在系统设置邀请返利卡片内嵌入专属用户管理表格(搜索/编辑/批量/删除),
删除采用项目通用 ConfirmDialog,会同时清除专属比例并把邀请码重置为系统随机码
- /affiliate 用户页新增「我的返利比例」卡片与动态使用说明,让用户直观看到
分享后能拿到多少(同源 resolveRebateRatePercent 计算,与实际充值一致)
- 新增数据库迁移 132 添加 aff_rebate_rate_percent 与 aff_code_custom 列
- 新增 admin 路由组 /api/v1/admin/affiliates/users/* 共 5 个端点
- AffiliateService 改为只依赖 *SettingService,去除冗余的 SettingRepository
- 邀请码格式校验放宽到 [A-Z0-9_-]{4,32},兼容旧 12 位系统码与新自定义码
- 补充单元测试与集成测试覆盖新方法、冲突路径与边界值
Layout Components
Vue 3 layout components for the Sub2API frontend, built with Composition API, TypeScript, and TailwindCSS.
Components
1. AppLayout.vue
Main application layout with sidebar and header.
Usage:
<template>
<AppLayout>
<!-- Your page content here -->
<h1>Dashboard</h1>
<p>Welcome to your dashboard!</p>
</AppLayout>
</template>
<script setup lang="ts">
import { AppLayout } from '@/components/layout'
</script>
Features:
- Responsive sidebar (collapsible)
- Fixed header at top
- Main content area with slot
- Automatically adjusts margin based on sidebar state
2. AppSidebar.vue
Navigation sidebar with user and admin sections.
Features:
- Logo/brand at top
- User navigation links:
- Dashboard
- API Keys
- Usage
- Redeem
- Profile
- Admin navigation links (shown only if user is admin):
- Admin Dashboard
- Users
- Groups
- Accounts
- Proxies
- Redeem Codes
- Collapsible sidebar with toggle button
- Active route highlighting
- Icons using HTML entities
- Responsive (mobile-friendly)
Used automatically by AppLayout - no need to import separately.
3. AppHeader.vue
Top header with user info and actions.
Features:
- Mobile menu toggle button
- Page title (from route meta or slot)
- User balance display (desktop only)
- User dropdown menu with:
- Profile link
- Logout button
- User avatar with initials
- Click-outside handling for dropdown
- Responsive design
Usage with custom title:
<template>
<AppLayout>
<template #title> Custom Page Title </template>
<!-- Your content -->
</AppLayout>
</template>
Used automatically by AppLayout - no need to import separately.
4. AuthLayout.vue
Simple centered layout for authentication pages (login/register).
Usage:
<template>
<AuthLayout>
<!-- Login/Register form content -->
<h2 class="mb-6 text-2xl font-bold">Login</h2>
<form @submit.prevent="handleLogin">
<!-- Form fields -->
</form>
<!-- Optional footer slot -->
<template #footer>
<p>
Don't have an account?
<router-link to="/register" class="text-indigo-600 hover:underline"> Sign up </router-link>
</p>
</template>
</AuthLayout>
</template>
<script setup lang="ts">
import { AuthLayout } from '@/components/layout'
function handleLogin() {
// Login logic
}
</script>
Features:
- Centered card container
- Gradient background
- Logo/brand at top
- Main content slot
- Optional footer slot for links
- Fully responsive
Route Configuration
To set page titles in the header, add meta to your routes:
// router/index.ts
const routes = [
{
path: '/dashboard',
component: DashboardView,
meta: { title: 'Dashboard' }
},
{
path: '/api-keys',
component: ApiKeysView,
meta: { title: 'API Keys' }
}
// ...
]
Store Dependencies
These components use the following Pinia stores:
- useAuthStore: For user authentication state, role checking, and logout
- useAppStore: For sidebar state management and toast notifications
Make sure these stores are properly initialized in your app.
Styling
All components use TailwindCSS utility classes. Make sure your tailwind.config.js includes the component paths:
module.exports = {
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}']
// ...
}
Icons
Components use HTML entity icons for simplicity:
- 📈 Chart (Dashboard)
- 🔑 Key (API Keys)
- 📊 Bar Chart (Usage)
- 🎁 Gift (Redeem)
- 👤 User (Profile)
- 🔌 Admin
- 👥 Users
- 📁 Folder (Groups)
- 🌐 Globe (Accounts)
- 🔄 Network (Proxies)
- 🏷 Ticket (Redeem Codes)
You can replace these with your preferred icon library (e.g., Heroicons, Font Awesome) if needed.
Mobile Responsiveness
All components are fully responsive:
- AppSidebar: Fixed positioning on desktop, hidden by default on mobile
- AppHeader: Shows mobile menu toggle on small screens, hides balance display
- AuthLayout: Adapts padding and card size for mobile devices
The sidebar uses Tailwind's responsive breakpoints (md:) to adjust behavior.