mirror of
https://github.com/ucmao/media-parser.git
synced 2026-11-20 08:04:56 +08:00
806 lines
51 KiB
HTML
806 lines
51 KiB
HTML
{% extends 'base_console.html' %}
|
|
{% block title %}系统设置 · 管理员后台{% endblock %}
|
|
{% block page_title %}系统设置{% endblock %}
|
|
{% block console_content %}
|
|
<main class="max-w-4xl mx-auto space-y-6">
|
|
<div id="settings" class="space-y-6">
|
|
<div>
|
|
<h1 class="text-xl font-bold text-slate-900 tracking-tight">系统设置</h1>
|
|
<p class="text-xs text-slate-500 mt-1">管理服务全局开放状态、访问体验、平台凭据与默认参数配置。(修改自动保存生效)</p>
|
|
</div>
|
|
|
|
<!-- 顶部 Tab 切换胶囊栏 -->
|
|
<div
|
|
class="flex items-center gap-1.5 p-1 bg-slate-200/60 rounded-xl max-w-fit border border-slate-200/80 select-none shadow-2xs">
|
|
<button type="button" onclick="switchSettingsTab('access')" id="tab-btn-access"
|
|
class="tab-nav-btn inline-flex items-center gap-2 px-3.5 py-2 text-xs font-semibold rounded-lg transition-all bg-white text-brand shadow-xs">
|
|
{{ icon('shield', 'w-3.5 h-3.5') }}
|
|
<span>服务与访问控制</span>
|
|
</button>
|
|
<button type="button" onclick="switchSettingsTab('cookies')" id="tab-btn-cookies"
|
|
class="tab-nav-btn inline-flex items-center gap-2 px-3.5 py-2 text-xs font-semibold rounded-lg transition-all text-slate-600 hover:text-slate-900">
|
|
{{ icon('key', 'w-3.5 h-3.5') }}
|
|
<span>平台凭据 (Cookie)</span>
|
|
</button>
|
|
<button type="button" onclick="switchSettingsTab('proxy')" id="tab-btn-proxy"
|
|
class="tab-nav-btn inline-flex items-center gap-2 px-3.5 py-2 text-xs font-semibold rounded-lg transition-all text-slate-600 hover:text-slate-900">
|
|
{{ icon('globe', 'w-3.5 h-3.5') }}
|
|
<span>网络与动态代理</span>
|
|
</button>
|
|
<button type="button" onclick="switchSettingsTab('branding')" id="tab-btn-branding"
|
|
class="tab-nav-btn inline-flex items-center gap-2 px-3.5 py-2 text-xs font-semibold rounded-lg transition-all text-slate-600 hover:text-slate-900">
|
|
{{ icon('tag', 'w-3.5 h-3.5') }}
|
|
<span>响应水印与版权</span>
|
|
</button>
|
|
</div>
|
|
|
|
<form method="post" action="{{ url_for('admin.update_settings') }}" id="admin-settings-form" class="space-y-6">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
|
|
<!-- Tab 1: 服务与访问控制 -->
|
|
<div id="tab-content-access" class="space-y-6 tab-panel">
|
|
<!-- 分组 1:服务与访问控制 -->
|
|
<section class="bg-white rounded-xl border border-slate-200/80 p-5 sm:p-6 shadow-xs space-y-5">
|
|
<div class="border-b border-slate-100 pb-3">
|
|
<h2 class="text-sm font-bold text-slate-900 flex items-center gap-2">
|
|
<span class="text-brand flex items-center justify-center">{{ icon('shield', 'w-4 h-4')
|
|
}}</span>
|
|
服务与访问控制
|
|
</h2>
|
|
</div>
|
|
<div class="divide-y divide-slate-100 text-sm">
|
|
<div class="py-3.5 first:pt-0 last:pb-0 flex items-center justify-between gap-4">
|
|
<div>
|
|
<div class="font-medium text-slate-900">API 服务总开关</div>
|
|
<div class="text-xs text-slate-500 mt-0.5">控制全局 API 解析接口是否开放并响应外部调用请求</div>
|
|
</div>
|
|
<div class="shrink-0">
|
|
<label class="switch-toggle" title="切换 API 开放状态">
|
|
<input type="checkbox" id="global-api-toggle" name="global_api_enabled"
|
|
data-initial="{{ '1' if settings.get('global_api_enabled')=='1' else '0' }}"
|
|
{{ 'checked' if settings.get('global_api_enabled')=='1' }}
|
|
onchange="triggerSettingsSubmit(this)">
|
|
<span class="switch-slider"></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="py-3.5 first:pt-0 last:pb-0 flex items-center justify-between gap-4">
|
|
<div>
|
|
<div class="font-medium text-slate-900">开放公开首页</div>
|
|
<div class="text-xs text-slate-500 mt-0.5">允许访客访问产品宣传主页;关闭后访问根路径直接跳转至登录页(私密模式)</div>
|
|
</div>
|
|
<div class="shrink-0">
|
|
<label class="switch-toggle" title="切换公开首页状态">
|
|
<input type="checkbox" id="homepage-toggle" name="homepage_enabled" {{ 'checked' if
|
|
settings.get('homepage_enabled', '1' )=='1' }}
|
|
onchange="triggerSettingsSubmit(this)">
|
|
<span class="switch-slider"></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="py-3.5 first:pt-0 last:pb-0 flex items-center justify-between gap-4">
|
|
<div>
|
|
<div class="font-medium text-slate-900">首页在线体验</div>
|
|
<div class="text-xs text-slate-500 mt-0.5">允许访客在首页未登录状态下直接体验视频解析功能</div>
|
|
</div>
|
|
<div class="shrink-0">
|
|
<label class="switch-toggle" title="切换首页在线体验状态">
|
|
<input type="checkbox" name="demo_enabled" {{ 'checked' if
|
|
settings.get('demo_enabled')=='1' }} onchange="triggerSettingsSubmit(this)">
|
|
<span class="switch-slider"></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- 分组 2:用户注册与新账号配置 -->
|
|
{% set registration_enabled = (settings.get('registration_enabled', '1') == '1') %}
|
|
<section class="bg-white rounded-xl border border-slate-200/80 p-5 sm:p-6 shadow-xs space-y-5">
|
|
<div class="border-b border-slate-100 pb-3">
|
|
<h2 class="text-sm font-bold text-slate-900 flex items-center gap-2">
|
|
<span class="text-brand flex items-center justify-center">{{ icon('user', 'w-4 h-4')
|
|
}}</span>
|
|
用户注册与新账号配置
|
|
</h2>
|
|
</div>
|
|
<div class="space-y-4">
|
|
<div class="flex items-center justify-between gap-4">
|
|
<div>
|
|
<div class="font-medium text-slate-900 text-sm">开放用户注册</div>
|
|
<div class="text-xs text-slate-500 mt-0.5">允许新用户在登录页面自主申请与注册客户账号</div>
|
|
</div>
|
|
<div class="shrink-0">
|
|
<label class="switch-toggle" title="切换用户注册开关">
|
|
<input type="checkbox" id="registration-toggle" name="registration_enabled"
|
|
{{ 'checked' if registration_enabled }}
|
|
onchange="toggleRegistrationDetails(this)">
|
|
<span class="switch-slider"></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 联动折叠卡片:新注册初始参数 -->
|
|
<div id="registration-collapse-panel" class="pt-4 border-t border-slate-100 space-y-3.5"
|
|
style="{{ 'display:none;' if not registration_enabled else '' }}">
|
|
<div class="text-xs font-semibold text-slate-700 mb-2 flex items-center gap-1.5">
|
|
<span class="w-1.5 h-1.5 rounded-full bg-brand"></span>
|
|
新注册账号默认初始参数
|
|
</div>
|
|
<div class="divide-y divide-slate-100 text-sm">
|
|
<div class="py-3 first:pt-0 last:pb-0 flex items-center justify-between gap-4">
|
|
<div>
|
|
<div class="font-medium text-slate-900">默认 QPS 限制</div>
|
|
<div class="text-xs text-slate-500 mt-0.5">新账号注册时默认分配的每秒并发请求数上限 (1 ~ 1000)</div>
|
|
</div>
|
|
<div class="relative w-28 shrink-0">
|
|
<input type="number" min="1" max="1000" data-default="2" name="default_user_qps"
|
|
value="{{ settings.get('default_user_qps','2') }}"
|
|
oninput="validateNumberClamp(this)" onblur="normalizeNumberOnBlur(this)"
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full pl-3 pr-10 py-1.5 text-xs text-right font-mono font-bold rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50">
|
|
<span
|
|
class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2.5 text-[11px] font-semibold text-slate-400">QPS</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="py-3 first:pt-0 last:pb-0 flex items-center justify-between gap-4">
|
|
<div>
|
|
<div class="font-medium text-slate-900">默认试用天数</div>
|
|
<div class="text-xs text-slate-500 mt-0.5">新注册客户默认试用时长 (1 ~ 9999 天,或勾选永久有效)
|
|
</div>
|
|
</div>
|
|
<div class="flex items-center gap-3 shrink-0">
|
|
<div class="relative w-28">
|
|
<input type="number" min="1" max="9999" data-default="365"
|
|
id="input_default_trial_days" name="default_trial_days"
|
|
value="{{ '365' if settings.get('default_trial_days') == '0' else settings.get('default_trial_days', '365') }}"
|
|
{{ 'disabled' if settings.get('default_trial_days')=='0' }}
|
|
oninput="validateNumberClamp(this)" onblur="normalizeNumberOnBlur(this)"
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full pl-3 pr-8 py-1.5 text-xs text-right font-mono font-bold rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition disabled:opacity-40 disabled:bg-slate-100 disabled:cursor-not-allowed bg-slate-50/50">
|
|
<span
|
|
class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2.5 text-[11px] font-semibold text-slate-400">天</span>
|
|
</div>
|
|
<label
|
|
class="inline-flex items-center gap-1.5 cursor-pointer select-none text-xs font-medium text-slate-600 hover:text-slate-900">
|
|
<input type="checkbox" id="chk_unlimited_trial" name="chk_unlimited_trial"
|
|
value="1" {{ 'checked' if settings.get('default_trial_days')=='0' }}
|
|
onchange="toggleUnlimitedDays(this)"
|
|
class="rounded border-slate-300 text-brand focus:ring-brand/20 h-4 w-4">
|
|
<span>永久有效</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="py-3 first:pt-0 last:pb-0 flex items-center justify-between gap-4">
|
|
<div>
|
|
<div class="font-medium text-slate-900">默认赠送积分</div>
|
|
<div class="text-xs text-slate-500 mt-0.5">新注册客户初始赠送的解析积分额度 (0 ~
|
|
99999999,或勾选不限制)
|
|
</div>
|
|
</div>
|
|
<div class="flex items-center gap-3 shrink-0">
|
|
<div class="relative w-32">
|
|
<input type="text" inputmode="numeric" min="0" max="99999999"
|
|
data-default="100" data-thousands="true"
|
|
id="input_default_initial_credits" name="default_initial_credits"
|
|
value="{{ '{:,}'.format(settings.get('default_initial_credits', '100')|int) if settings.get('default_initial_credits') != '-1' else '100' }}"
|
|
{{ 'disabled' if settings.get('default_initial_credits')=='-1' }}
|
|
onfocus="this.value = unformatThousands(this.value)"
|
|
oninput="validateNumberClamp(this)" onblur="normalizeNumberOnBlur(this)"
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full pl-3 pr-8 py-1.5 text-xs text-right font-mono font-bold rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition disabled:opacity-40 disabled:bg-slate-100 disabled:cursor-not-allowed bg-slate-50/50">
|
|
<span
|
|
class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2.5 text-[11px] font-semibold text-slate-400">点</span>
|
|
</div>
|
|
<label
|
|
class="inline-flex items-center gap-1.5 cursor-pointer select-none text-xs font-medium text-slate-600 hover:text-slate-900">
|
|
<input type="checkbox" id="chk_unlimited_credits"
|
|
name="chk_unlimited_credits" value="1" {{ 'checked' if
|
|
settings.get('default_initial_credits')=='-1' }}
|
|
onchange="toggleUnlimitedCredits(this)"
|
|
class="rounded border-slate-300 text-brand focus:ring-brand/20 h-4 w-4">
|
|
<span>不限积分</span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<!-- Tab 2: 平台凭据 (Cookie) -->
|
|
<div id="tab-content-cookies" class="space-y-6 tab-panel" style="display: none;">
|
|
<section class="bg-white rounded-xl border border-slate-200/80 p-5 sm:p-6 shadow-xs space-y-5">
|
|
<div class="border-b border-slate-100 pb-3 flex items-center justify-between">
|
|
<div>
|
|
<h2 class="text-sm font-bold text-slate-900 flex items-center gap-2">
|
|
<span class="text-brand flex items-center justify-center">{{ icon('key', 'w-4 h-4')
|
|
}}</span>
|
|
平台 Cookie 凭据覆盖配置
|
|
</h2>
|
|
<p class="text-xs text-slate-500 mt-1">此处配置具有最高优先级(覆盖 <code>.env</code>
|
|
环境变量)。保存后无需重启即可即时生效;清空输入框并保存即可自动恢复读取 <code>.env</code> 凭据。</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="space-y-5 text-xs">
|
|
<!-- 微信视频号 / 腾讯元宝 -->
|
|
<div class="space-y-1.5">
|
|
<div class="flex items-center justify-between">
|
|
<label for="cookie_wechat_channels"
|
|
class="font-semibold text-slate-900 flex items-center gap-2">
|
|
<span>微信视频号 / 腾讯元宝</span>
|
|
</label>
|
|
<span class="text-[11px] text-slate-400">后台键名: <code>cookie_wechat_channels</code> /
|
|
降级环境变量: <code>YUANBAO_COOKIE</code></span>
|
|
</div>
|
|
<textarea id="cookie_wechat_channels" name="cookie_wechat_channels" rows="2"
|
|
placeholder="格式例: hybrid_sess=...; pass_ticket=..."
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 font-mono text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50 custom-scroll">{{ settings.get('cookie_wechat_channels', '') }}</textarea>
|
|
<p class="text-[11px] text-slate-400">用于解析微信视频号无水印视频与图集内容。</p>
|
|
</div>
|
|
|
|
<!-- 小红书 -->
|
|
<div class="space-y-1.5">
|
|
<div class="flex items-center justify-between">
|
|
<label for="cookie_xiaohongshu"
|
|
class="font-semibold text-slate-900 flex items-center gap-2">
|
|
<span>小红书 (Xiaohongshu)</span>
|
|
</label>
|
|
<span class="text-[11px] text-slate-400">后台键名: <code>cookie_xiaohongshu</code> / 降级环境变量:
|
|
<code>XHS_COOKIE</code></span>
|
|
</div>
|
|
<textarea id="cookie_xiaohongshu" name="cookie_xiaohongshu" rows="2"
|
|
placeholder="格式例: a1=...; webId=...; web_session=..."
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 font-mono text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50 custom-scroll">{{ settings.get('cookie_xiaohongshu', '') }}</textarea>
|
|
<p class="text-[11px] text-slate-400">用于绕过小红书风控阻断与提取高清无水印图集/视频。</p>
|
|
</div>
|
|
|
|
<!-- 快手 -->
|
|
<div class="space-y-1.5">
|
|
<div class="flex items-center justify-between">
|
|
<label for="cookie_kuaishou"
|
|
class="font-semibold text-slate-900 flex items-center gap-2">
|
|
<span>快手 (Kuaishou)</span>
|
|
</label>
|
|
<span class="text-[11px] text-slate-400">后台键名: <code>cookie_kuaishou</code> / 降级环境变量:
|
|
<code>KUAISHOU_COOKIE</code></span>
|
|
</div>
|
|
<textarea id="cookie_kuaishou" name="cookie_kuaishou" rows="2"
|
|
placeholder="格式例: did=...; kuaishou.server.web_st=..."
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 font-mono text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50 custom-scroll">{{ settings.get('cookie_kuaishou', '') }}</textarea>
|
|
<p class="text-[11px] text-slate-400">用于解除快手风控阻断或滑块验证要求。</p>
|
|
</div>
|
|
|
|
<!-- 拼多多 -->
|
|
<div class="space-y-1.5">
|
|
<div class="flex items-center justify-between">
|
|
<label for="cookie_pinduoduo"
|
|
class="font-semibold text-slate-900 flex items-center gap-2">
|
|
<span>拼多多 (Pinduoduo)</span>
|
|
</label>
|
|
<span class="text-[11px] text-slate-400">后台键名: <code>cookie_pinduoduo</code> / 降级环境变量:
|
|
<code>PINDUODUO_COOKIE</code></span>
|
|
</div>
|
|
<textarea id="cookie_pinduoduo" name="cookie_pinduoduo" rows="2"
|
|
placeholder="格式例: PDDAccessToken=...; pdd_user_id=..."
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 font-mono text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50 custom-scroll">{{ settings.get('cookie_pinduoduo', '') }}</textarea>
|
|
<p class="text-[11px] text-slate-400">用于拼多多商品/视频页面详情提取。</p>
|
|
</div>
|
|
|
|
<!-- 抖音 -->
|
|
<div class="space-y-1.5">
|
|
<div class="flex items-center justify-between">
|
|
<label for="cookie_douyin" class="font-semibold text-slate-900 flex items-center gap-2">
|
|
<span>抖音 (Douyin)</span>
|
|
</label>
|
|
<span class="text-[11px] text-slate-400">后台键名: <code>cookie_douyin</code> / 降级环境变量:
|
|
<code>DOUYIN_COOKIE</code></span>
|
|
</div>
|
|
<textarea id="cookie_douyin" name="cookie_douyin" rows="2"
|
|
placeholder="格式例: passport_csrf_token=...; sessionid=..."
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 font-mono text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50 custom-scroll">{{ settings.get('cookie_douyin', '') }}</textarea>
|
|
<p class="text-[11px] text-slate-400">可选。常规抖音内容免 Cookie,针对受限作品做风控退避。</p>
|
|
</div>
|
|
|
|
<!-- 微博 -->
|
|
<div class="space-y-1.5">
|
|
<div class="flex items-center justify-between">
|
|
<label for="cookie_weibo" class="font-semibold text-slate-900 flex items-center gap-2">
|
|
<span>微博 (Weibo)</span>
|
|
</label>
|
|
<span class="text-[11px] text-slate-400">后台键名: <code>cookie_weibo</code> / 降级环境变量:
|
|
<code>WEIBO_COOKIE</code></span>
|
|
</div>
|
|
<textarea id="cookie_weibo" name="cookie_weibo" rows="2"
|
|
placeholder="格式例: SUB=...; SUBP=..." onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 font-mono text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50 custom-scroll">{{ settings.get('cookie_weibo', '') }}</textarea>
|
|
<p class="text-[11px] text-slate-400">可选。常规内容免 Cookie,遇到频繁抓包限制时提供。</p>
|
|
</div>
|
|
|
|
<!-- 豆包 AI -->
|
|
<div class="space-y-1.5">
|
|
<div class="flex items-center justify-between">
|
|
<label for="cookie_doubao" class="font-semibold text-slate-900 flex items-center gap-2">
|
|
<span>豆包 AI (Doubao)</span>
|
|
</label>
|
|
<span class="text-[11px] text-slate-400">后台键名: <code>cookie_doubao</code> / 降级环境变量:
|
|
<code>DOUBAO_COOKIE</code></span>
|
|
</div>
|
|
<textarea id="cookie_doubao" name="cookie_doubao" rows="2" placeholder="格式例: sessionid=..."
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 font-mono text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50 custom-scroll">{{ settings.get('cookie_doubao', '') }}</textarea>
|
|
<p class="text-[11px] text-slate-400">用于提取豆包 AI 对话中的视频/生成媒体。</p>
|
|
</div>
|
|
|
|
<!-- 即梦 AI -->
|
|
<div class="space-y-1.5">
|
|
<div class="flex items-center justify-between">
|
|
<label for="cookie_jimeng" class="font-semibold text-slate-900 flex items-center gap-2">
|
|
<span>即梦 AI (Jimeng)</span>
|
|
</label>
|
|
<span class="text-[11px] text-slate-400">后台键名: <code>cookie_jimeng</code> / 降级环境变量:
|
|
<code>JIMENG_COOKIE</code></span>
|
|
</div>
|
|
<textarea id="cookie_jimeng" name="cookie_jimeng" rows="2" placeholder="格式例: sessionid=..."
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 font-mono text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50 custom-scroll">{{ settings.get('cookie_jimeng', '') }}</textarea>
|
|
<p class="text-[11px] text-slate-400">用于即梦 AI 生成内容的接口凭据支持。</p>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<!-- Tab 3: API 响应水印与版权提示 -->
|
|
<div id="tab-content-branding" class="space-y-6 tab-panel" style="display: none;">
|
|
{% set tip_enabled = (settings.get('api_tip_enabled', '1') == '1') %}
|
|
<section class="bg-white rounded-xl border border-slate-200/80 p-5 sm:p-6 shadow-xs space-y-5">
|
|
<div class="border-b border-slate-100 pb-3">
|
|
<h2 class="text-sm font-bold text-slate-900 flex items-center gap-2">
|
|
<span class="text-brand flex items-center justify-center">{{ icon('tag', 'w-4 h-4')
|
|
}}</span>
|
|
API 响应水印与版权提示
|
|
</h2>
|
|
</div>
|
|
<div class="space-y-4">
|
|
<div class="flex items-center justify-between gap-4">
|
|
<div>
|
|
<div class="font-medium text-slate-900 text-sm">API 响应版权信息</div>
|
|
<div class="text-xs text-slate-500 mt-0.5">开启后将在所有 API 解析接口响应的 JSON 尾部包含 _tip 元数据字段
|
|
</div>
|
|
</div>
|
|
<div class="shrink-0">
|
|
<label class="switch-toggle" title="切换 API 响应版权信息">
|
|
<input type="checkbox" id="api-tip-toggle" name="api_tip_enabled" {{ 'checked' if
|
|
tip_enabled }} onchange="toggleApiTipDetails(this)">
|
|
<span class="switch-slider"></span>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 联动折叠卡片 -->
|
|
<div id="api-tip-collapse-panel" class="pt-4 border-t border-slate-100 space-y-4"
|
|
style="{{ 'display:none;' if not tip_enabled else '' }}">
|
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
|
<div class="space-y-1.5">
|
|
<label for="api_tip_author"
|
|
class="block text-xs font-semibold text-slate-700">作者</label>
|
|
<input type="text" id="api_tip_author" name="api_tip_author"
|
|
value="{{ settings.get('api_tip_author', 'ucmao') }}" placeholder="例如: ucmao"
|
|
oninput="updateApiTipPreview()" onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50">
|
|
</div>
|
|
<div class="space-y-1.5">
|
|
<label for="api_tip_website"
|
|
class="block text-xs font-semibold text-slate-700">官网地址</label>
|
|
<input type="url" id="api_tip_website" name="api_tip_website"
|
|
value="{{ settings.get('api_tip_website', 'https://github.com/ucmao/media-parser') }}"
|
|
placeholder="例如: https://github.com/ucmao/media-parser"
|
|
oninput="updateApiTipPreview()" onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="space-y-1.5">
|
|
<label for="api_tip_notice"
|
|
class="block text-xs font-semibold text-slate-700">提示文本</label>
|
|
<input type="text" id="api_tip_notice" name="api_tip_notice"
|
|
value="{{ settings.get('api_tip_notice', '本接口由开源项目 media-parser 提供服务') }}"
|
|
placeholder="例如: 本接口由开源项目 media-parser 提供服务" oninput="updateApiTipPreview()"
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2 text-xs rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50">
|
|
</div>
|
|
|
|
<details
|
|
class="rounded-xl overflow-hidden bg-slate-50/70 border border-slate-200 transition-all">
|
|
<summary
|
|
class="px-4 py-2.5 bg-slate-100/70 hover:bg-slate-100 border-b border-slate-200/80 cursor-pointer select-none font-sans font-semibold text-xs text-slate-700 flex items-center justify-between transition-colors">
|
|
<span class="flex items-center gap-2">
|
|
<svg width="14" height="14" viewBox="0 0 24 24" fill="none"
|
|
stroke="currentColor" stroke-width="2" stroke-linecap="round"
|
|
stroke-linejoin="round" class="text-slate-500">
|
|
<polyline points="16 18 22 12 16 6" />
|
|
<polyline points="8 6 2 12 8 18" />
|
|
</svg>
|
|
<span>响应 JSON 效果预览</span>
|
|
</span>
|
|
<span class="text-[11px] text-slate-400 font-normal">点击展开/收起 ▾</span>
|
|
</summary>
|
|
<pre
|
|
class="p-4 overflow-x-auto text-xs font-mono text-slate-800 bg-slate-50/40 leading-relaxed custom-scroll"><code id="api-tip-preview-code"></code></pre>
|
|
</details>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<!-- Tab 4: 网络与动态代理 -->
|
|
<div id="tab-content-proxy" class="space-y-6 tab-panel" style="display: none;">
|
|
<section class="bg-white rounded-xl border border-slate-200/80 p-5 sm:p-6 shadow-xs space-y-5">
|
|
<div class="border-b border-slate-100 pb-3 flex items-center justify-between">
|
|
<h2 class="text-sm font-bold text-slate-900 flex items-center gap-2">
|
|
<span class="text-brand flex items-center justify-center">{{ icon('globe', 'w-4 h-4')
|
|
}}</span>
|
|
动态代理配置 (Proxy API)
|
|
</h2>
|
|
{% if settings.get('dynamic_proxy_api_url') %}
|
|
<span
|
|
class="inline-flex items-center gap-1.5 px-2.5 py-1 text-[11px] font-semibold text-emerald-700 bg-emerald-50 rounded-full border border-emerald-200">
|
|
<span class="w-1.5 h-1.5 rounded-full bg-emerald-500 animate-pulse"></span>
|
|
后台在线配置已生效 (覆盖 .env)
|
|
</span>
|
|
{% elif config.get('DYNAMIC_PROXY_API_URL') %}
|
|
<span
|
|
class="inline-flex items-center gap-1.5 px-2.5 py-1 text-[11px] font-semibold text-blue-700 bg-blue-50 rounded-full border border-blue-200">
|
|
<span class="w-1.5 h-1.5 rounded-full bg-blue-500"></span>
|
|
已启用来自 .env 的环境变量
|
|
</span>
|
|
{% else %}
|
|
<span
|
|
class="inline-flex items-center gap-1.5 px-2.5 py-1 text-[11px] font-semibold text-slate-500 bg-slate-100 rounded-full border border-slate-200">
|
|
<span class="w-1.5 h-1.5 rounded-full bg-slate-400"></span>
|
|
未配置 (默认直接连网解析)
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="space-y-4">
|
|
<div class="text-xs text-slate-500 leading-relaxed">
|
|
当任意平台直连解析触发风控或需要 Cookie 校验失败时,系统将自动开启 15 分钟平台级代理窗口并提取代理重试。
|
|
系统已内置智能通用解码器,原生兼容 <strong>芝麻代理、巨量IP、青果网络、无忧代理、多米代理</strong> 等主流服务商。
|
|
</div>
|
|
|
|
<div class="space-y-1.5">
|
|
<label for="dynamic_proxy_api_url" class="block text-xs font-semibold text-slate-700">
|
|
动态代理 API 提取 URL
|
|
</label>
|
|
<input type="url" id="dynamic_proxy_api_url" name="dynamic_proxy_api_url"
|
|
value="{{ settings.get('dynamic_proxy_api_url', '') }}"
|
|
placeholder="例如: https://v2.api.juliangip.com/dynamic/getippro?trade_no=xxx&num=1&pt=1&result_type=json2&ip_remain=1"
|
|
onchange="triggerSettingsSubmit(this)"
|
|
class="w-full px-3.5 py-2.5 text-xs font-mono rounded-lg border border-slate-200 focus:outline-none focus:border-brand focus:ring-2 focus:ring-brand/20 transition bg-slate-50/50">
|
|
</div>
|
|
|
|
<div
|
|
class="p-3 bg-slate-50 rounded-lg border border-slate-100 text-[11px] text-slate-500 space-y-1.5">
|
|
<div class="font-semibold text-slate-700">📌 优先级与生效规则说明:</div>
|
|
<ul class="list-disc list-inside space-y-1 text-slate-600">
|
|
<li><strong>三级优先级</strong>:后台在线配置 > <code>.env</code> 环境变量
|
|
(<code>DYNAMIC_PROXY_API_URL</code>) > 留空不启用。</li>
|
|
<li>修改此处的提取 URL 保存后<strong>即时生效,无需重启应用或 Docker 容器</strong>。</li>
|
|
<li>若需取消后台覆盖恢复读取 <code>.env</code> 环境变量配置,只需清空上方输入框并保存即可。</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</main>
|
|
|
|
<script>
|
|
window.switchSettingsTab = function (tabKey) {
|
|
const tabs = ['access', 'cookies', 'proxy', 'branding'];
|
|
tabs.forEach(key => {
|
|
const btn = document.getElementById('tab-btn-' + key);
|
|
const panel = document.getElementById('tab-content-' + key);
|
|
if (key === tabKey) {
|
|
if (btn) {
|
|
btn.className = 'tab-nav-btn inline-flex items-center gap-2 px-3.5 py-2 text-xs font-semibold rounded-lg transition-all bg-white text-brand shadow-xs';
|
|
}
|
|
if (panel) {
|
|
panel.style.display = 'block';
|
|
}
|
|
} else {
|
|
if (btn) {
|
|
btn.className = 'tab-nav-btn inline-flex items-center gap-2 px-3.5 py-2 text-xs font-semibold rounded-lg transition-all text-slate-600 hover:text-slate-900';
|
|
}
|
|
if (panel) {
|
|
panel.style.display = 'none';
|
|
}
|
|
}
|
|
});
|
|
try {
|
|
history.replaceState(null, '', '#tab=' + tabKey);
|
|
} catch (e) { }
|
|
};
|
|
|
|
window.toggleRegistrationDetails = function (checkbox) {
|
|
const panel = document.getElementById('registration-collapse-panel');
|
|
if (panel) {
|
|
panel.style.display = checkbox.checked ? 'block' : 'none';
|
|
}
|
|
triggerSettingsSubmit(checkbox);
|
|
};
|
|
|
|
window.toggleApiTipDetails = function (checkbox) {
|
|
const panel = document.getElementById('api-tip-collapse-panel');
|
|
if (panel) {
|
|
panel.style.display = checkbox.checked ? 'block' : 'none';
|
|
}
|
|
triggerSettingsSubmit(checkbox);
|
|
};
|
|
|
|
function highlightJson(json) {
|
|
if (typeof json !== 'string') {
|
|
json = JSON.stringify(json, null, 2);
|
|
}
|
|
return json
|
|
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
|
|
let cls = 'hl-num';
|
|
if (/^"/.test(match)) {
|
|
if (/:$/.test(match)) {
|
|
cls = 'hl-type';
|
|
} else {
|
|
cls = 'hl-str';
|
|
}
|
|
} else if (/true|false/.test(match)) {
|
|
cls = 'hl-kw';
|
|
} else if (/null/.test(match)) {
|
|
cls = 'hl-cmt';
|
|
}
|
|
return '<span class="' + cls + '">' + match + '</span>';
|
|
});
|
|
}
|
|
|
|
window.updateApiTipPreview = function () {
|
|
const authorEl = document.getElementById('api_tip_author');
|
|
const websiteEl = document.getElementById('api_tip_website');
|
|
const noticeEl = document.getElementById('api_tip_notice');
|
|
const previewEl = document.getElementById('api-tip-preview-code');
|
|
if (!previewEl) return;
|
|
|
|
const author = (authorEl && authorEl.value.trim()) || 'ucmao';
|
|
const website = (websiteEl && websiteEl.value.trim()) || 'https://github.com/ucmao/media-parser';
|
|
const notice = (noticeEl && noticeEl.value.trim()) || '本接口由开源项目 media-parser 提供服务';
|
|
|
|
const samplePayload = {
|
|
succ: true,
|
|
data: {
|
|
title: "示例短视频标题...",
|
|
url: "https://example.com/video.mp4"
|
|
},
|
|
_tip: {
|
|
author: author,
|
|
website: website,
|
|
notice: notice
|
|
}
|
|
};
|
|
previewEl.innerHTML = highlightJson(samplePayload);
|
|
};
|
|
|
|
window.formatThousands = function (val) {
|
|
if (val === null || val === undefined || val === '') return '';
|
|
const raw = String(val).replace(/,/g, '').trim();
|
|
const num = parseInt(raw, 10);
|
|
return isNaN(num) ? raw : num.toLocaleString('en-US');
|
|
};
|
|
|
|
window.unformatThousands = function (val) {
|
|
if (val === null || val === undefined) return '';
|
|
return String(val).replace(/,/g, '').trim();
|
|
};
|
|
|
|
window.toggleUnlimitedDays = function (checkbox) {
|
|
const input = document.getElementById('input_default_trial_days');
|
|
if (!input) return;
|
|
if (checkbox.checked) {
|
|
input.dataset.prevValue = input.value && input.value !== '0' ? input.value : '365';
|
|
input.disabled = true;
|
|
} else {
|
|
input.disabled = false;
|
|
input.value = input.dataset.prevValue && input.dataset.prevValue !== '0' ? input.dataset.prevValue : '365';
|
|
input.focus();
|
|
}
|
|
triggerSettingsSubmit(checkbox);
|
|
};
|
|
|
|
window.toggleUnlimitedCredits = function (checkbox) {
|
|
const input = document.getElementById('input_default_initial_credits');
|
|
if (!input) return;
|
|
if (checkbox.checked) {
|
|
const raw = window.unformatThousands(input.value);
|
|
input.dataset.prevValue = raw && raw !== '-1' ? raw : '100';
|
|
input.disabled = true;
|
|
} else {
|
|
input.disabled = false;
|
|
const prev = input.dataset.prevValue && input.dataset.prevValue !== '-1' ? input.dataset.prevValue : '100';
|
|
input.value = window.formatThousands(prev);
|
|
input.focus();
|
|
}
|
|
triggerSettingsSubmit(checkbox);
|
|
};
|
|
|
|
window.validateNumberClamp = function (input) {
|
|
if (input.value === '' || input.value === '-') return;
|
|
const raw = window.unformatThousands(input.value);
|
|
const max = input.hasAttribute('max') ? parseInt(input.getAttribute('max'), 10) : null;
|
|
let num = parseInt(raw, 10);
|
|
if (!isNaN(num) && max !== null && num > max) {
|
|
input.value = input.dataset.thousands === 'true' ? window.formatThousands(max) : max;
|
|
}
|
|
};
|
|
|
|
window.normalizeNumberOnBlur = function (input) {
|
|
const min = input.hasAttribute('min') ? parseInt(input.getAttribute('min'), 10) : null;
|
|
const max = input.hasAttribute('max') ? parseInt(input.getAttribute('max'), 10) : null;
|
|
const def = input.dataset.default || (min !== null ? String(min) : '0');
|
|
const isThousands = input.dataset.thousands === 'true';
|
|
|
|
const raw = window.unformatThousands(input.value);
|
|
if (raw === '' || isNaN(parseInt(raw, 10))) {
|
|
input.value = isThousands ? window.formatThousands(def) : def;
|
|
triggerSettingsSubmit(input);
|
|
return;
|
|
}
|
|
|
|
let num = parseInt(raw, 10);
|
|
if (min !== null && num < min) num = min;
|
|
if (max !== null && num > max) num = max;
|
|
|
|
const formatted = isThousands ? window.formatThousands(num) : String(num);
|
|
if (input.value !== formatted) {
|
|
input.value = formatted;
|
|
triggerSettingsSubmit(input);
|
|
}
|
|
};
|
|
|
|
let lastTriggeredElement = null;
|
|
|
|
function getSpecificSuccessToast(el) {
|
|
if (!el) return '系统设置已保存';
|
|
const name = el.name || el.id;
|
|
if (name === 'global_api_enabled' || el.id === 'global-api-toggle') {
|
|
return el.checked ? '已开启全局 API 解析服务' : '已暂停全局 API 解析服务';
|
|
}
|
|
if (name === 'homepage_enabled' || el.id === 'homepage-toggle') {
|
|
return el.checked ? '已开放公开产品主页' : '已关闭公开首页(进入私密模式)';
|
|
}
|
|
if (name === 'demo_enabled') {
|
|
return el.checked ? '已开启首页在线解析体验' : '已关闭首页在线解析体验';
|
|
}
|
|
if (name === 'registration_enabled' || el.id === 'registration-toggle') {
|
|
return el.checked ? '已开放用户自主注册' : '已关闭用户自主注册';
|
|
}
|
|
if (name === 'default_user_qps' || name === 'default_trial_days' || name === 'chk_unlimited_trial' || name === 'default_initial_credits' || name === 'chk_unlimited_credits') {
|
|
return '新账号默认初始参数已更新';
|
|
}
|
|
if (name === 'api_tip_enabled' || el.id === 'api-tip-toggle') {
|
|
return el.checked ? '已开启 API 响应版权提示' : '已关闭 API 响应版权提示';
|
|
}
|
|
if (name === 'api_tip_author' || name === 'api_tip_website' || name === 'api_tip_notice') {
|
|
return 'API 版权提示内容已更新';
|
|
}
|
|
return '系统设置已保存';
|
|
}
|
|
|
|
window.triggerSettingsSubmit = function (el) {
|
|
lastTriggeredElement = el || null;
|
|
const form = (el && el.form) || document.getElementById('admin-settings-form');
|
|
if (form) {
|
|
if (typeof form.requestSubmit === 'function') {
|
|
form.requestSubmit();
|
|
} else {
|
|
form.dispatchEvent(new Event('submit', { cancelable: true }));
|
|
}
|
|
}
|
|
};
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
updateApiTipPreview();
|
|
|
|
// 检查 URL hash 自动定位 Tab
|
|
if (window.location.hash) {
|
|
const hash = window.location.hash;
|
|
if (hash.includes('tab=')) {
|
|
const tabKey = hash.split('tab=')[1].trim();
|
|
if (['access', 'cookies', 'proxy', 'branding'].includes(tabKey)) {
|
|
switchSettingsTab(tabKey);
|
|
}
|
|
}
|
|
}
|
|
|
|
const settingsForm = document.getElementById('admin-settings-form');
|
|
if (settingsForm) {
|
|
settingsForm.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const globalApiToggle = document.getElementById('global-api-toggle');
|
|
if (globalApiToggle) {
|
|
const initial = globalApiToggle.dataset.initial === '1';
|
|
const isNowChecked = globalApiToggle.checked;
|
|
|
|
if (initial !== isNowChecked) {
|
|
const title = isNowChecked ? '开启 API 服务总开关' : '暂停 API 服务总开关';
|
|
const message = isNowChecked
|
|
? '提示:保存后将重新开启全局 API 解析服务,恢复所有外部接口调用响应。确定保存系统配置吗?'
|
|
: '警告:保存后将暂停全局 API 解析服务,所有外部客户与系统发起的接口解析请求将立即被拦截拒绝!确定保存系统配置并暂停服务吗?';
|
|
const confirmText = isNowChecked ? '确认开启' : '确认暂停';
|
|
const type = isNowChecked ? 'primary' : 'danger';
|
|
|
|
const ok = await window.confirmModal({ title, message, confirmText, type });
|
|
if (!ok) {
|
|
globalApiToggle.checked = initial;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
try {
|
|
const formData = new FormData(settingsForm);
|
|
const chkTrial = document.getElementById('chk_unlimited_trial');
|
|
if (chkTrial && chkTrial.checked) {
|
|
formData.set('default_trial_days', '0');
|
|
formData.set('chk_unlimited_trial', '1');
|
|
}
|
|
const chkCredits = document.getElementById('chk_unlimited_credits');
|
|
if (chkCredits && chkCredits.checked) {
|
|
formData.set('default_initial_credits', '-1');
|
|
formData.set('chk_unlimited_credits', '1');
|
|
}
|
|
|
|
const res = await fetch(settingsForm.action || window.location.href, {
|
|
method: 'POST',
|
|
body: formData,
|
|
headers: {
|
|
'X-Requested-With': 'XMLHttpRequest',
|
|
'Accept': 'application/json'
|
|
}
|
|
});
|
|
|
|
if (res.ok) {
|
|
const data = await res.json();
|
|
const toastMsg = getSpecificSuccessToast(lastTriggeredElement);
|
|
if (window.showToast) {
|
|
window.showToast(toastMsg, 'success', 2200);
|
|
}
|
|
if (globalApiToggle) {
|
|
globalApiToggle.dataset.initial = globalApiToggle.checked ? '1' : '0';
|
|
}
|
|
} else {
|
|
if (window.showToast) {
|
|
window.showToast('保存失败,请刷新重试', 'error');
|
|
}
|
|
}
|
|
} catch (err) {
|
|
console.error('Settings save error:', err);
|
|
if (window.showToast) {
|
|
window.showToast('网络请求异常,保存失败', 'error');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %} |