删除不再使用的文件,包括.gitignore、多个启动和配置指南文档,以及小程序相关的脚本和文档,简化项目结构以提高可维护性。
This commit is contained in:
@@ -39,6 +39,14 @@ export default function SettingsPage() {
|
||||
minWithdraw: 10, // 最低提现金额
|
||||
})
|
||||
|
||||
// 功能开关配置
|
||||
const [featureConfig, setFeatureConfig] = useState({
|
||||
matchEnabled: true, // 找伙伴功能开关(默认开启)
|
||||
referralEnabled: true, // 推广功能开关
|
||||
searchEnabled: true, // 搜索功能开关
|
||||
aboutEnabled: true // 关于页面开关
|
||||
})
|
||||
|
||||
// 加载配置
|
||||
useEffect(() => {
|
||||
const loadConfig = async () => {
|
||||
@@ -48,6 +56,7 @@ export default function SettingsPage() {
|
||||
const data = await res.json()
|
||||
if (data.freeChapters) setFreeChapters(data.freeChapters)
|
||||
if (data.mpConfig) setMpConfig(prev => ({ ...prev, ...data.mpConfig }))
|
||||
if (data.features) setFeatureConfig(prev => ({ ...prev, ...data.features }))
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Load config error:', e)
|
||||
@@ -82,16 +91,41 @@ export default function SettingsPage() {
|
||||
})
|
||||
|
||||
// 保存免费章节和小程序配置
|
||||
await fetch('/api/db/config', {
|
||||
const res1 = await fetch('/api/db/config', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ freeChapters, mpConfig })
|
||||
})
|
||||
const result1 = await res1.json()
|
||||
console.log('保存免费章节和小程序配置:', result1)
|
||||
|
||||
alert("设置已保存!")
|
||||
// 保存功能开关配置
|
||||
const res2 = await fetch('/api/db/config', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
key: 'feature_config',
|
||||
config: featureConfig,
|
||||
description: '功能开关配置'
|
||||
})
|
||||
})
|
||||
const result2 = await res2.json()
|
||||
console.log('保存功能开关配置:', result2)
|
||||
|
||||
// 验证保存结果
|
||||
const verifyRes = await fetch('/api/db/config')
|
||||
const verifyData = await verifyRes.json()
|
||||
console.log('验证保存结果:', verifyData.features)
|
||||
|
||||
// 立即更新本地状态
|
||||
if (verifyData.features) {
|
||||
setFeatureConfig(prev => ({ ...prev, ...verifyData.features }))
|
||||
}
|
||||
|
||||
alert("设置已保存!\n\n找伙伴功能:" + (verifyData.features?.matchEnabled ? "✅ 开启" : "❌ 关闭"))
|
||||
} catch (error) {
|
||||
console.error('Save settings error:', error)
|
||||
alert("保存失败")
|
||||
alert("保存失败: " + (error as Error).message)
|
||||
} finally {
|
||||
setIsSaving(false)
|
||||
}
|
||||
@@ -357,6 +391,114 @@ export default function SettingsPage() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* 功能开关设置 */}
|
||||
<Card className="bg-[#0f2137] border-gray-700/50 shadow-xl">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-white flex items-center gap-2">
|
||||
<Settings className="w-5 h-5 text-[#38bdac]" />
|
||||
功能开关
|
||||
</CardTitle>
|
||||
<CardDescription className="text-gray-400">控制各个功能模块的显示/隐藏</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-4">
|
||||
{/* 找伙伴功能开关 */}
|
||||
<div className="flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50">
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<Users className="w-4 h-4 text-[#38bdac]" />
|
||||
<Label htmlFor="match-enabled" className="text-white font-medium cursor-pointer">
|
||||
找伙伴功能
|
||||
</Label>
|
||||
</div>
|
||||
<p className="text-xs text-gray-400 ml-6">
|
||||
控制小程序和Web端的找伙伴功能显示
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="match-enabled"
|
||||
checked={featureConfig.matchEnabled}
|
||||
onCheckedChange={(checked) =>
|
||||
setFeatureConfig(prev => ({ ...prev, matchEnabled: checked }))
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 推广功能开关 */}
|
||||
<div className="flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50">
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<Gift className="w-4 h-4 text-[#38bdac]" />
|
||||
<Label htmlFor="referral-enabled" className="text-white font-medium cursor-pointer">
|
||||
推广功能
|
||||
</Label>
|
||||
</div>
|
||||
<p className="text-xs text-gray-400 ml-6">
|
||||
控制推广中心的显示(我的页面入口)
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="referral-enabled"
|
||||
checked={featureConfig.referralEnabled}
|
||||
onCheckedChange={(checked) =>
|
||||
setFeatureConfig(prev => ({ ...prev, referralEnabled: checked }))
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 搜索功能开关 */}
|
||||
<div className="flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50">
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<BookOpen className="w-4 h-4 text-[#38bdac]" />
|
||||
<Label htmlFor="search-enabled" className="text-white font-medium cursor-pointer">
|
||||
搜索功能
|
||||
</Label>
|
||||
</div>
|
||||
<p className="text-xs text-gray-400 ml-6">
|
||||
控制首页搜索栏的显示
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="search-enabled"
|
||||
checked={featureConfig.searchEnabled}
|
||||
onCheckedChange={(checked) =>
|
||||
setFeatureConfig(prev => ({ ...prev, searchEnabled: checked }))
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 关于页面开关 */}
|
||||
<div className="flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50">
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<Settings className="w-4 h-4 text-[#38bdac]" />
|
||||
<Label htmlFor="about-enabled" className="text-white font-medium cursor-pointer">
|
||||
关于页面
|
||||
</Label>
|
||||
</div>
|
||||
<p className="text-xs text-gray-400 ml-6">
|
||||
控制关于页面的访问
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
id="about-enabled"
|
||||
checked={featureConfig.aboutEnabled}
|
||||
onCheckedChange={(checked) =>
|
||||
setFeatureConfig(prev => ({ ...prev, aboutEnabled: checked }))
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="p-3 rounded-lg bg-blue-500/10 border border-blue-500/30">
|
||||
<p className="text-xs text-blue-300">
|
||||
💡 关闭功能后,相关入口会自动隐藏。建议在功能开发完成后再开启。
|
||||
</p>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* 小程序配置 */}
|
||||
<Card className="bg-[#0f2137] border-gray-700/50 shadow-xl">
|
||||
<CardHeader>
|
||||
@@ -478,14 +620,22 @@ export default function SettingsPage() {
|
||||
<span className="text-white">分销系统</span>
|
||||
<span className="font-normal text-xs text-gray-500">是否允许用户生成邀请链接</span>
|
||||
</Label>
|
||||
<Switch id="referral-enabled" defaultChecked />
|
||||
<Switch
|
||||
id="referral-enabled"
|
||||
checked={featureConfig.referralEnabled}
|
||||
onCheckedChange={(checked) => setFeatureConfig(prev => ({ ...prev, referralEnabled: checked }))}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<Label htmlFor="match-enabled" className="flex flex-col space-y-1">
|
||||
<span className="text-white">找伙伴功能</span>
|
||||
<span className="font-normal text-xs text-gray-500">是否启用找伙伴匹配功能</span>
|
||||
</Label>
|
||||
<Switch id="match-enabled" defaultChecked />
|
||||
<Switch
|
||||
id="match-enabled"
|
||||
checked={featureConfig.matchEnabled}
|
||||
onCheckedChange={(checked) => setFeatureConfig(prev => ({ ...prev, matchEnabled: checked }))}
|
||||
/>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user