Build and Publish Server / build (push) Successful in 4m30s
- 新增商业化模块:Stripe/Binance Pay 支付、邮箱登录、订单管理 - 新增数据模型:ReportProduct, ReportEntitlement, ReportSnapshot, PaymentEvent, EmailLoginCode - 新增 API:/api/commerce/checkout, /api/commerce/webhooks/*, /api/commerce/orders/* - 新增管理后台:订单列表、统计图表、统一 AdminHeader 组件 - 新增中间件测试:RateLimit, Auth, CORS 共 7 个测试用例 - 新增 AGENTS.md 项目代理指令文件 - 新增 REMINDER.md 商业化功能开发规范 - 修复 JWT 解析:添加 WithValidMethods 限制 HS256 - 修复 GetPayStatus:增加用户权限校验 - 更新 .gitignore 和 README.md
70 lines
2.9 KiB
JavaScript
70 lines
2.9 KiB
JavaScript
// Login 管理员登录页
|
|
export default {
|
|
template: `
|
|
<div class="min-h-screen bg-gray-100 flex items-center justify-center px-4">
|
|
<div class="max-w-sm w-full bg-white rounded-lg shadow-md p-8">
|
|
<div class="text-center mb-6">
|
|
<h1 class="text-2xl font-bold text-red-600">知命 PC 商业版后台</h1>
|
|
<p class="text-gray-500 text-sm mt-1">管理后台登录</p>
|
|
<p class="text-gray-300 text-xs mt-2">v2026.08.12-login</p>
|
|
</div>
|
|
<form @submit.prevent="submit">
|
|
<div class="mb-4">
|
|
<label class="block text-sm font-medium text-gray-700 mb-1">管理密码</label>
|
|
<input
|
|
v-model="password"
|
|
type="password"
|
|
autocomplete="current-password"
|
|
placeholder="请输入 ADMIN_PASSWORD"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-red-500 focus:border-transparent"
|
|
:disabled="loading"
|
|
/>
|
|
</div>
|
|
<div v-if="error" class="mb-4 text-sm text-red-600">{{ error }}</div>
|
|
<button
|
|
type="submit"
|
|
:disabled="loading || !password"
|
|
class="w-full bg-red-600 text-white py-2 rounded-md hover:bg-red-700 disabled:opacity-50 disabled:cursor-not-allowed transition"
|
|
>
|
|
{{ loading ? '登录中...' : '登 录' }}
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
`,
|
|
data() {
|
|
return {
|
|
password: '',
|
|
loading: false,
|
|
error: ''
|
|
};
|
|
},
|
|
methods: {
|
|
async submit() {
|
|
if (!this.password || this.loading) return;
|
|
this.loading = true;
|
|
this.error = '';
|
|
try {
|
|
const res = await fetch('/admin/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ password: this.password })
|
|
});
|
|
const data = await res.json();
|
|
if (data.code === 0) {
|
|
// Cookie 已由服务端写入,跳回原本要访问的页面
|
|
window.location.href = window.location.pathname === '/admin/login'
|
|
? '/admin/'
|
|
: window.location.pathname;
|
|
} else {
|
|
this.error = data.msg || '登录失败';
|
|
}
|
|
} catch (e) {
|
|
this.error = '网络错误,请重试';
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
}
|
|
}
|
|
};
|