Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70b2cacc20 | ||
|
|
7d698273d0 | ||
|
|
d508f84954 |
No files matched your search
+1
-1
@@ -51,7 +51,7 @@ ENV NODE_ENV=production
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
ENV PORT=3000
|
||||
ENV DOCKER_ENV=true
|
||||
ENV NEXT_PUBLIC_SITE_VERSION=fixed73
|
||||
ENV NEXT_PUBLIC_SITE_VERSION=fixed75
|
||||
|
||||
# 从构建器中复制 standalone 输出
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
||||
|
||||
+14
-3
@@ -29,17 +29,28 @@ const all=await liveEpgAll();
|
||||
const key=EPG_MAP[name]||(all[name]?name:null);
|
||||
if(!key)return{has:false,list:[]};
|
||||
return{has:true,epg_key:key,list:all[key]||[]}}
|
||||
async function liveText(u,ms){const c=new AbortController();const t=setTimeout(()=>c.abort(),ms||15000);
|
||||
try{const r=await fetch(u,{redirect:"follow",signal:c.signal,headers:{"User-Agent":LIVE_UA,"Referer":LIVE_UP+"/"}});return await r.text()}finally{clearTimeout(t)}}
|
||||
async function liveText(u,ms){const timeout=ms||25000;let lastErr=null;
|
||||
for(let attempt=1;attempt<=3;attempt++){
|
||||
const c=new AbortController();const t=setTimeout(()=>c.abort(),timeout);
|
||||
try{const r=await fetch(u,{redirect:"follow",signal:c.signal,headers:{"User-Agent":LIVE_UA,"Referer":LIVE_UP+"/"}});
|
||||
if(!r.ok)throw new Error("http "+r.status);
|
||||
const txt=await r.text();clearTimeout(t);return txt}
|
||||
catch(e){clearTimeout(t);lastErr=e;console.log("[LIVE-FETCH-RETRY]",attempt+"/3",(u||"").slice(0,60),e&&e.message);
|
||||
if(attempt<3)await new Promise(r=>setTimeout(r,800*attempt))}}
|
||||
throw lastErr||new Error("fetch failed")}
|
||||
function liveRegion(n){if(/澳门|澳門|澳[視视]|澳亚|莲花/.test(n))return"澳门";
|
||||
if(/凤凰|TVB|有线|有線|NOW|ViuTV|HOY|港台|香港|明珠|HKS/.test(n))return"香港";
|
||||
if(/中天|东森|東森|中视|中視|台视|台視|三立|非凡|民视|民視|华视|華視|镜电视|鏡電視|寰宇|TVBS|纬来|緯來|ELEVEN|DAZN|爱尔达|愛爾達/.test(n))return"台湾";return"其他"}
|
||||
async function liveChannels(){
|
||||
if(liveCh.list&&Date.now()-liveCh.ts<3600e3)return liveCh.list;
|
||||
try{
|
||||
const h=await liveText(LIVE_UP+"/?tid=gt");const seen=new Set(),list=[];
|
||||
for(const m of h.matchAll(/href="\?act=play&(?:amp;)?tid=gt&(?:amp;)?id=(\d+)"[^>]*>\s*([^<]+?)\s*</g)){
|
||||
if(!seen.has(m[1])){seen.add(m[1]);list.push({id:m[1],name:m[2]})}}
|
||||
if(list.length){list.forEach(function(c){c.region=liveRegion(c.name)});liveCh.list=list;liveCh.ts=Date.now()}return list||[]}
|
||||
if(list.length){list.forEach(function(c){c.region=liveRegion(c.name)});liveCh.list=list;liveCh.ts=Date.now();return list}
|
||||
throw new Error("channels empty")}catch(e){console.log("[LIVE-CH-ERR]",e&&e.message);
|
||||
if(liveCh.list&&liveCh.list.length){console.log("[LIVE-CH-STALE] use stale list n="+liveCh.list.length);return liveCh.list}
|
||||
return[]}}
|
||||
async function liveLines(id){
|
||||
const c=liveLn.get(id);if(c&&Date.now()-c.ts<1800e3)return c.lines;
|
||||
const h=await liveText(LIVE_UP+"/?act=play&tid=gt&id="+encodeURIComponent(id));
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
if(!self.define){let e,s={};const n=(n,a)=>(n=new URL(n+".js",a).href,s[n]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()}).then(()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(a,i)=>{const c=e||("document"in self?document.currentScript.src:"")||location.href;if(s[c])return;let t={};const o=e=>n(e,c),r={module:{uri:c},exports:t,require:o};s[c]=Promise.all(a.map(e=>r[e]||o(e))).then(e=>(i(...e),t))}}define(["./workbox-e9849328"],function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"be9d54592fea46176d680a09da2f8b03"},{url:"/_next/static/6pApvoOMGhTBhMnIA6395/_buildManifest.js",revision:"85aecd8a55db42fc901f52386fd2a680"},{url:"/_next/static/6pApvoOMGhTBhMnIA6395/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/_next/static/chunks/151-8711dd3ec7fbfa61.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/234-c7c5e76b3553af41.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/242-5a0502f47346ed4a.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/273-fffc7e5390a1c642.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/547-65bdb23e16942a03.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/609-46d66c37b95adf6a.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/78-b091442d784a205f.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/866-7f5b3d6941560701.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/_not-found/page-2f2263c5b98c190a.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/admin/page-759806afdd5b7523.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/config/page-e7450485f43e42b7.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/douban/page-72adc56cdd9fa67a.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/filter/page-4cebc2f48c3257a1.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/ipv6/page-4396f8cd57b55d3b.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/layout-abad67b72f2d607d.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/live/page-83b49175a0a9d775.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/login/page-b2957b92254ae889.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/page-984f6128015dda92.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/play/page-4b74435a3843991f.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/search/page-62b12f466a432302.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/settings/page-137dd16f391763b9.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/tvbox/page-125bca4b61639acb.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/app/warning/page-e6b20b93b37dc516.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/b145b63a-d75d6adf389a7589.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/c72274ce-909438a8a5dd87a5.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/da9543df-c2ce5269243dd748.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/framework-6e06c675866dc992.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/main-68795df77d27d928.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/main-app-734bbab0f54e7373.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/pages/_app-3fcac1a2c632f1ef.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/pages/_error-d3fe151bf402c134.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-f732225cafd52a05.js",revision:"6pApvoOMGhTBhMnIA6395"},{url:"/_next/static/css/083d238e0b356531.css",revision:"083d238e0b356531"},{url:"/_next/static/css/23100062f5d4aac0.css",revision:"23100062f5d4aac0"},{url:"/_next/static/css/da6e9b4a73108890.css",revision:"da6e9b4a73108890"},{url:"/_next/static/media/19cfc7226ec3afaa-s.woff2",revision:"9dda5cfc9a46f256d0e131bb535e46f8"},{url:"/_next/static/media/21350d82a1f187e9-s.woff2",revision:"4e2553027f1d60eff32898367dd4d541"},{url:"/_next/static/media/8e9860b6e62d6359-s.woff2",revision:"01ba6c2a184b8cba08b0d57167664d75"},{url:"/_next/static/media/ba9851c3c22cd980-s.woff2",revision:"9e494903d6b0ffec1a1e14d34427d44d"},{url:"/_next/static/media/c5fe6dc8356a8c31-s.woff2",revision:"027a89e9ab733a145db70f09b8a18b42"},{url:"/_next/static/media/df0a9ae256c0569c-s.woff2",revision:"d54db44de5ccb18886ece2fda72bdfe0"},{url:"/_next/static/media/e4af272ccee01ff0-s.p.woff2",revision:"65850a373e258f1c897a2b3d75eb74de"},{url:"/favicon.ico",revision:"c5deLine truncated
|
||||
if(!self.define){let e,s={};const n=(n,i)=>(n=new URL(n+".js",i).href,s[n]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=n,e.onload=s,document.head.appendChild(e)}else e=n,importScripts(n),s()}).then(()=>{let e=s[n];if(!e)throw new Error(`Module ${n} didn’t register its module`);return e}));self.define=(i,a)=>{const c=e||("document"in self?document.currentScript.src:"")||location.href;if(s[c])return;let t={};const r=e=>n(e,c),o={module:{uri:c},exports:t,require:r};s[c]=Promise.all(i.map(e=>o[e]||r(e))).then(e=>(a(...e),t))}}define(["./workbox-e9849328"],function(e){"use strict";importScripts(),self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"/_next/app-build-manifest.json",revision:"85a885cf9d52dfc1f9e7714b1099e163"},{url:"/_next/static/chunks/151-8711dd3ec7fbfa61.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/234-8975aa8e308e2c95.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/242-5a0502f47346ed4a.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/273-fffc7e5390a1c642.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/547-65bdb23e16942a03.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/609-46d66c37b95adf6a.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/78-b091442d784a205f.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/866-7f5b3d6941560701.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/_not-found/page-2f2263c5b98c190a.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/admin/page-759806afdd5b7523.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/config/page-e11c360d4b3b5cc5.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/douban/page-72adc56cdd9fa67a.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/filter/page-4cebc2f48c3257a1.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/ipv6/page-659cd71fb4b9a563.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/layout-abad67b72f2d607d.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/live/page-63f48c7b5b4e432c.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/login/page-b2957b92254ae889.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/page-e7df8976ebcc4d71.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/play/page-4b74435a3843991f.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/search/page-62b12f466a432302.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/settings/page-563818cdeb3743df.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/tvbox/page-8126310a5c549d37.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/app/warning/page-e6b20b93b37dc516.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/b145b63a-d75d6adf389a7589.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/c72274ce-909438a8a5dd87a5.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/da9543df-c2ce5269243dd748.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/framework-6e06c675866dc992.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/main-68795df77d27d928.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/main-app-734bbab0f54e7373.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/pages/_app-3fcac1a2c632f1ef.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/pages/_error-d3fe151bf402c134.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/chunks/polyfills-42372ed130431b0a.js",revision:"846118c33b2c0e922d7b3a7676f81f6f"},{url:"/_next/static/chunks/webpack-f732225cafd52a05.js",revision:"npJwqxq3GQJATZ3iINZqR"},{url:"/_next/static/css/23100062f5d4aac0.css",revision:"23100062f5d4aac0"},{url:"/_next/static/css/50ddca8f740c6eb6.css",revision:"50ddca8f740c6eb6"},{url:"/_next/static/css/da6e9b4a73108890.css",revision:"da6e9b4a73108890"},{url:"/_next/static/media/19cfc7226ec3afaa-s.woff2",revision:"9dda5cfc9a46f256d0e131bb535e46f8"},{url:"/_next/static/media/21350d82a1f187e9-s.woff2",revision:"4e2553027f1d60eff32898367dd4d541"},{url:"/_next/static/media/8e9860b6e62d6359-s.woff2",revision:"01ba6c2a184b8cba08b0d57167664d75"},{url:"/_next/static/media/ba9851c3c22cd980-s.woff2",revision:"9e494903d6b0ffec1a1e14d34427d44d"},{url:"/_next/static/media/c5fe6dc8356a8c31-s.woff2",revision:"027a89e9ab733a145db70f09b8a18b42"},{url:"/_next/static/media/df0a9ae256c0569c-s.woff2",revision:"d54db44de5ccb18886ece2fda72bdfe0"},{url:"/_next/static/media/e4af272ccee01ff0-s.p.woff2",revision:"65850a373e258f1c897a2b3d75eb74de"},{url:"/_next/static/npJwqxq3GQJATZ3iINZqR/_buildManifest.js",revision:"85aecd8a55db42fc901f52386fd2a680"},{url:"/_next/static/npJwqxq3GQJATZ3iINZqR/_ssgManifest.js",revision:"b6652df95db52feb4daf4eca35380933"},{url:"/favicon.ico",revision:"c5deLine truncated
|
||||
@@ -470,6 +470,18 @@ const UserConfig = ({ config, role, refreshConfig }: UserConfigProps) => {
|
||||
>
|
||||
状态
|
||||
</th>
|
||||
<th
|
||||
scope='col'
|
||||
className='px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider'
|
||||
>
|
||||
注册时间
|
||||
</th>
|
||||
<th
|
||||
scope='col'
|
||||
className='px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider'
|
||||
>
|
||||
最后登录
|
||||
</th>
|
||||
<th
|
||||
scope='col'
|
||||
className='px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider'
|
||||
@@ -548,6 +560,16 @@ const UserConfig = ({ config, role, refreshConfig }: UserConfigProps) => {
|
||||
{!user.banned ? '正常' : '已封禁'}
|
||||
</span>
|
||||
</td>
|
||||
<td className='px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400'>
|
||||
{user.created_at
|
||||
? `${new Date(user.created_at).toLocaleString('zh-CN', { hour12: false })}${user.created_at_estimated ? '*' : ''}`
|
||||
: '-'}
|
||||
</td>
|
||||
<td className='px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400'>
|
||||
{user.last_login_at
|
||||
? `${new Date(user.last_login_at).toLocaleString('zh-CN', { hour12: false })}${user.last_login_estimated ? '*' : ''}`
|
||||
: '-'}
|
||||
</td>
|
||||
<td className='px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2'>
|
||||
{/* 修改密码按钮 */}
|
||||
{canChangePassword && (
|
||||
|
||||
@@ -132,11 +132,13 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
await storage.registerUser(targetUsername!, targetPassword);
|
||||
// 更新配置
|
||||
// 更新配置(带注册时间,避免列表显示空白)
|
||||
adminConfig.UserConfig.Users.push({
|
||||
username: targetUsername!,
|
||||
role: 'user',
|
||||
});
|
||||
created_at: new Date().toISOString(),
|
||||
created_at_estimated: false,
|
||||
} as any);
|
||||
targetEntry =
|
||||
adminConfig.UserConfig.Users[
|
||||
adminConfig.UserConfig.Users.length - 1
|
||||
|
||||
@@ -97,11 +97,13 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
await db.registerUser(username, password);
|
||||
|
||||
// 添加到配置中并保存
|
||||
// 添加到配置中并保存(带注册时间,避免列表显示空白)
|
||||
config.UserConfig.Users.push({
|
||||
username,
|
||||
role: 'user',
|
||||
});
|
||||
created_at: new Date().toISOString(),
|
||||
created_at_estimated: false,
|
||||
} as any);
|
||||
await db.saveAdminConfig(config);
|
||||
|
||||
// 注册成功,设置认证cookie
|
||||
|
||||
@@ -8,6 +8,7 @@ export const dynamic = 'force-dynamic';
|
||||
|
||||
export default function ConfigPage() {
|
||||
const [copied, setCopied] = useState(false);
|
||||
const [copiedLive, setCopiedLive] = useState(false);
|
||||
const [format, setFormat] = useState<'json' | 'base64'>('json');
|
||||
|
||||
const getConfigUrl = useCallback(() => {
|
||||
@@ -16,6 +17,12 @@ export default function ConfigPage() {
|
||||
return `${baseUrl}/api/tvbox?format=${format}`;
|
||||
}, [format]);
|
||||
|
||||
const getLiveUrl = useCallback(() => {
|
||||
if (typeof window === 'undefined') return '';
|
||||
const baseUrl = window.location.origin;
|
||||
return `${baseUrl}/api/tvbox?live=txt`;
|
||||
}, []);
|
||||
|
||||
const handleCopy = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(getConfigUrl());
|
||||
@@ -26,6 +33,16 @@ export default function ConfigPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleCopyLive = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(getLiveUrl());
|
||||
setCopiedLive(true);
|
||||
setTimeout(() => setCopiedLive(false), 2000);
|
||||
} catch {
|
||||
// Copy failed silently
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<TopRightButtons variant='float' />
|
||||
@@ -72,6 +89,31 @@ export default function ConfigPage() {
|
||||
{copied ? '已复制' : '复制'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h2 className="text-xl font-semibold mt-6 mb-2 text-gray-900 dark:text-white">
|
||||
直播源地址
|
||||
</h2>
|
||||
<p className="text-sm text-gray-500 dark:text-gray-400 mb-4">
|
||||
仅含电视直播,可单独填入 TVBox 直播源(TXT 格式)。
|
||||
</p>
|
||||
<div className="flex items-center space-x-2">
|
||||
<input
|
||||
type="text"
|
||||
readOnly
|
||||
value={getLiveUrl()}
|
||||
className="flex-1 p-3 border border-gray-300 dark:border-gray-600 rounded-md bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white font-mono text-sm"
|
||||
/>
|
||||
<button
|
||||
onClick={handleCopyLive}
|
||||
className={`px-4 py-3 rounded-md font-medium transition-colors ${
|
||||
copiedLive
|
||||
? 'bg-green-500 text-white'
|
||||
: 'bg-blue-500 hover:bg-blue-600 text-white'
|
||||
}`}
|
||||
>
|
||||
{copiedLive ? '已复制' : '复制'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-lg p-6 mb-6">
|
||||
|
||||
@@ -27,7 +27,7 @@ const MobileHeader = ({ showBackButton = false }: MobileHeaderProps) => {
|
||||
className='shrink-0 select-none rounded-md px-1.5 py-0.5 text-[10px] font-bold tracking-wide text-purple-600 dark:text-purple-400 bg-purple-500/10 border border-purple-500/20'
|
||||
title='米视TV 当前版本'
|
||||
>
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed73'}
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed75'}
|
||||
</span>
|
||||
<ThemeToggle />
|
||||
<UserMenu />
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function TopRightButtons({ variant = 'bar' }: TopRightButtonsProp
|
||||
className='shrink-0 select-none rounded-md px-1.5 py-1 text-[10px] font-bold tracking-wide text-purple-300 bg-purple-500/20 border border-purple-400/30'
|
||||
title='米视TV 当前版本'
|
||||
>
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed73'}
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed75'}
|
||||
</span>
|
||||
<HubBell forceShow />
|
||||
<TvboxButton forceShow compact />
|
||||
@@ -43,7 +43,7 @@ export default function TopRightButtons({ variant = 'bar' }: TopRightButtonsProp
|
||||
className='hidden lg:inline-flex shrink-0 items-center select-none rounded-lg px-2 py-1.5 text-xs font-bold tracking-wide text-purple-600 dark:text-purple-400 bg-purple-500/10 border border-purple-500/20'
|
||||
title='米视TV 当前版本'
|
||||
>
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed73'}
|
||||
v{process.env.NEXT_PUBLIC_SITE_VERSION || 'fixed75'}
|
||||
</span>
|
||||
<HubBell />
|
||||
<TvboxButton />
|
||||
|
||||
@@ -5,7 +5,25 @@ import { useState } from 'react';
|
||||
export default function TvboxButton({ forceShow = false, compact = false }: { forceShow?: boolean; compact?: boolean }) {
|
||||
const [label, setLabel] = useState('📺 TVBOX接口');
|
||||
|
||||
const showModal = (title: string, body: string, link?: string) => {
|
||||
const copyText = (t: string, btn?: HTMLButtonElement) => {
|
||||
try {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(t).then(() => {
|
||||
if (btn) { btn.textContent = '✓ 已复制'; setTimeout(() => (btn.textContent = '复制'), 1600); }
|
||||
}).catch(() => {});
|
||||
return;
|
||||
}
|
||||
} catch {}
|
||||
const ta = document.createElement('textarea');
|
||||
ta.value = t;
|
||||
document.body.appendChild(ta);
|
||||
ta.select();
|
||||
try { document.execCommand('copy'); } catch {}
|
||||
document.body.removeChild(ta);
|
||||
if (btn) { btn.textContent = '✓ 已复制'; setTimeout(() => (btn.textContent = '复制'), 1600); }
|
||||
};
|
||||
|
||||
const showTvboxModal = (cfg: string, live: string) => {
|
||||
const ov = document.createElement('div');
|
||||
ov.className =
|
||||
'fixed inset-0 z-[9999] flex items-center justify-center bg-black/50 p-4';
|
||||
@@ -18,7 +36,7 @@ export default function TvboxButton({ forceShow = false, compact = false }: { fo
|
||||
const h3 = document.createElement('h3');
|
||||
h3.className =
|
||||
'text-base font-bold text-gray-900 dark:text-gray-100 truncate mr-2';
|
||||
h3.textContent = title;
|
||||
h3.textContent = '📺 TVBOX 接入';
|
||||
const xb = document.createElement('button');
|
||||
xb.className =
|
||||
'text-gray-400 hover:text-gray-600 dark:hover:text-gray-200 text-lg leading-none flex-shrink-0';
|
||||
@@ -27,8 +45,51 @@ export default function TvboxButton({ forceShow = false, compact = false }: { fo
|
||||
head.appendChild(xb);
|
||||
const bd = document.createElement('div');
|
||||
bd.className =
|
||||
'px-6 pb-4 overflow-y-auto text-sm text-gray-700 dark:text-gray-300 whitespace-pre-wrap';
|
||||
bd.textContent = body;
|
||||
'px-6 pb-4 overflow-y-auto text-sm text-gray-700 dark:text-gray-300';
|
||||
const mkRow = (label: string, url: string) => {
|
||||
const wrap = document.createElement('div');
|
||||
wrap.style.marginBottom = '14px';
|
||||
const lb = document.createElement('div');
|
||||
lb.style.fontWeight = '700';
|
||||
lb.style.marginBottom = '6px';
|
||||
lb.textContent = label;
|
||||
const urlDiv = document.createElement('div');
|
||||
urlDiv.style.wordBreak = 'break-all';
|
||||
urlDiv.style.background = 'rgba(127,127,127,.12)';
|
||||
urlDiv.style.borderRadius = '8px';
|
||||
urlDiv.style.padding = '8px 10px';
|
||||
urlDiv.style.fontSize = '12px';
|
||||
urlDiv.textContent = url;
|
||||
const row = document.createElement('div');
|
||||
row.style.display = 'flex';
|
||||
row.style.gap = '8px';
|
||||
row.style.marginTop = '8px';
|
||||
const cp = document.createElement('button');
|
||||
cp.textContent = '复制';
|
||||
cp.className =
|
||||
'px-3 py-1.5 rounded-lg text-xs font-medium text-white bg-purple-600 hover:bg-purple-700';
|
||||
cp.onclick = () => copyText(url, cp);
|
||||
const op = document.createElement('a');
|
||||
op.href = url;
|
||||
op.target = '_blank';
|
||||
op.rel = 'noopener';
|
||||
op.textContent = '打开 →';
|
||||
op.className =
|
||||
'px-3 py-1.5 rounded-lg text-xs font-medium text-purple-600 dark:text-purple-400 hover:bg-purple-500/10';
|
||||
row.appendChild(cp);
|
||||
row.appendChild(op);
|
||||
wrap.appendChild(lb);
|
||||
wrap.appendChild(urlDiv);
|
||||
wrap.appendChild(row);
|
||||
return wrap;
|
||||
};
|
||||
bd.appendChild(mkRow('配置地址(含直播,推荐)', cfg));
|
||||
bd.appendChild(mkRow('直播源地址(仅直播)', live));
|
||||
const tip = document.createElement('div');
|
||||
tip.style.fontSize = '12px';
|
||||
tip.style.opacity = '0.75';
|
||||
tip.textContent = '影视仓/TVBox「设置 → 配置地址」粘贴保存即可';
|
||||
bd.appendChild(tip);
|
||||
card.appendChild(head);
|
||||
card.appendChild(bd);
|
||||
const foot = document.createElement('div');
|
||||
@@ -39,16 +100,6 @@ export default function TvboxButton({ forceShow = false, compact = false }: { fo
|
||||
'px-3 py-1.5 rounded-lg text-xs font-medium text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-600';
|
||||
kb.textContent = '我知道了';
|
||||
foot.appendChild(kb);
|
||||
if (link) {
|
||||
const la = document.createElement('a');
|
||||
la.href = link;
|
||||
la.target = '_blank';
|
||||
la.rel = 'noopener';
|
||||
la.className =
|
||||
'px-3 py-1.5 rounded-lg text-xs font-medium text-purple-600 dark:text-purple-400 hover:bg-purple-500/10';
|
||||
la.textContent = '查看详情 →';
|
||||
foot.insertBefore(la, kb);
|
||||
}
|
||||
card.appendChild(foot);
|
||||
const close = () => {
|
||||
if (ov && ov.parentNode) ov.parentNode.removeChild(ov);
|
||||
@@ -63,25 +114,16 @@ export default function TvboxButton({ forceShow = false, compact = false }: { fo
|
||||
};
|
||||
|
||||
const onClick = (ev: React.MouseEvent<HTMLButtonElement>) => {
|
||||
const u = location.origin + '/api/tvbox';
|
||||
const cfg = location.origin + '/api/tvbox';
|
||||
const live = location.origin + '/api/tvbox?live=txt';
|
||||
const bt = ev.currentTarget;
|
||||
const ok = () => {
|
||||
setLabel('✓ 已复制');
|
||||
setTimeout(() => setLabel('📺 TVBOX接口'), 1600);
|
||||
};
|
||||
const tip = '影视仓/TVBox「设置 → 配置地址」粘贴保存即可';
|
||||
try {
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard
|
||||
.writeText(u)
|
||||
.then(ok)
|
||||
.catch(() =>
|
||||
showModal('📺 TVBOX 接入', '配置地址: ' + u + ' —— ' + tip, u)
|
||||
);
|
||||
return;
|
||||
}
|
||||
} catch {}
|
||||
showModal('📺 TVBOX 接入', '配置地址: ' + u + ' —— ' + tip, u);
|
||||
void bt;
|
||||
void ok;
|
||||
showTvboxModal(cfg, live);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -13,6 +13,10 @@ export interface AdminConfig {
|
||||
username: string;
|
||||
role: 'user' | 'admin' | 'owner';
|
||||
banned?: boolean;
|
||||
created_at?: string;
|
||||
created_at_estimated?: boolean;
|
||||
last_login_at?: string;
|
||||
last_login_estimated?: boolean;
|
||||
}[];
|
||||
};
|
||||
SourceConfig: {
|
||||
|
||||
+76
-8
@@ -73,16 +73,41 @@ async function initConfig() {
|
||||
adminConfig = await (storage as any).getAdminConfig();
|
||||
}
|
||||
|
||||
// 获取所有用户名,用于补全 Users
|
||||
// 获取所有用户(含注册/最后登录时间),用于补全 Users
|
||||
let userNames: string[] = [];
|
||||
const userTimeMap = new Map<
|
||||
string,
|
||||
{
|
||||
created_at?: string;
|
||||
created_at_estimated?: boolean;
|
||||
last_login_at?: string;
|
||||
last_login_estimated?: boolean;
|
||||
}
|
||||
>();
|
||||
if (storage && typeof (storage as any).getAllUsers === 'function') {
|
||||
try {
|
||||
const rawUsers = await (storage as any).getAllUsers();
|
||||
// getAllUsers 返回的是 User 对象数组,这里统一取用户名字符串,
|
||||
// 否则会把整个对象写入 Users[].username(导致管理页渲染对象报 React #31)
|
||||
userNames = (Array.isArray(rawUsers) ? rawUsers : [])
|
||||
.map((u: any) => (typeof u === 'string' ? u : u && typeof u.username === 'string' ? u.username : ''))
|
||||
.filter((n: string) => !!n);
|
||||
// 同时保留时间字段,供用户列表展示注册/最后登录时间
|
||||
(Array.isArray(rawUsers) ? rawUsers : []).forEach((u: any) => {
|
||||
const n =
|
||||
typeof u === 'string'
|
||||
? u
|
||||
: u && typeof u.username === 'string'
|
||||
? u.username
|
||||
: '';
|
||||
if (!n) return;
|
||||
userNames.push(n);
|
||||
if (typeof u === 'object' && u) {
|
||||
userTimeMap.set(n, {
|
||||
created_at: u.created_at || undefined,
|
||||
created_at_estimated: !!u.created_at_estimated,
|
||||
last_login_at: u.last_login_at || undefined,
|
||||
last_login_estimated: !!u.last_login_estimated,
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('获取用户列表失败:', e);
|
||||
}
|
||||
@@ -132,7 +157,24 @@ async function initConfig() {
|
||||
adminConfig!.UserConfig.Users.push({
|
||||
username: uname,
|
||||
role: 'user',
|
||||
...(userTimeMap.get(uname) || {}),
|
||||
});
|
||||
} else {
|
||||
// 已存在用户也回填时间字段(老配置升级时补上)
|
||||
const exist = adminConfig!.UserConfig.Users.find(
|
||||
(u) => u.username === uname
|
||||
);
|
||||
const t = userTimeMap.get(uname);
|
||||
if (exist && t) {
|
||||
if (!exist.created_at && t.created_at) {
|
||||
exist.created_at = t.created_at;
|
||||
exist.created_at_estimated = t.created_at_estimated;
|
||||
}
|
||||
if (!exist.last_login_at && t.last_login_at) {
|
||||
exist.last_login_at = t.last_login_at;
|
||||
exist.last_login_estimated = t.last_login_estimated;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
// 站长
|
||||
@@ -151,6 +193,7 @@ async function initConfig() {
|
||||
let allUsers = userNames.map((uname) => ({
|
||||
username: uname,
|
||||
role: 'user',
|
||||
...(userTimeMap.get(uname) || {}),
|
||||
}));
|
||||
const ownerUser = process.env.USERNAME;
|
||||
if (ownerUser) {
|
||||
@@ -325,14 +368,38 @@ export async function getConfig(): Promise<AdminConfig> {
|
||||
|
||||
export async function resetConfig() {
|
||||
const storage = getStorage();
|
||||
// 获取所有用户名,用于补全 Users
|
||||
// 获取所有用户(含注册/最后登录时间),用于补全 Users
|
||||
let userNames: string[] = [];
|
||||
const userTimeMap = new Map<
|
||||
string,
|
||||
{
|
||||
created_at?: string;
|
||||
created_at_estimated?: boolean;
|
||||
last_login_at?: string;
|
||||
last_login_estimated?: boolean;
|
||||
}
|
||||
>();
|
||||
if (storage && typeof (storage as any).getAllUsers === 'function') {
|
||||
try {
|
||||
const rawUsers = await (storage as any).getAllUsers();
|
||||
userNames = (Array.isArray(rawUsers) ? rawUsers : [])
|
||||
.map((u: any) => (typeof u === 'string' ? u : u && typeof u.username === 'string' ? u.username : ''))
|
||||
.filter((n: string) => !!n);
|
||||
(Array.isArray(rawUsers) ? rawUsers : []).forEach((u: any) => {
|
||||
const n =
|
||||
typeof u === 'string'
|
||||
? u
|
||||
: u && typeof u.username === 'string'
|
||||
? u.username
|
||||
: '';
|
||||
if (!n) return;
|
||||
userNames.push(n);
|
||||
if (typeof u === 'object' && u) {
|
||||
userTimeMap.set(n, {
|
||||
created_at: u.created_at || undefined,
|
||||
created_at_estimated: !!u.created_at_estimated,
|
||||
last_login_at: u.last_login_at || undefined,
|
||||
last_login_estimated: !!u.last_login_estimated,
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error('获取用户列表失败:', e);
|
||||
}
|
||||
@@ -358,6 +425,7 @@ export async function resetConfig() {
|
||||
let allUsers = userNames.map((uname) => ({
|
||||
username: uname,
|
||||
role: 'user',
|
||||
...(userTimeMap.get(uname) || {}),
|
||||
}));
|
||||
const ownerUser = process.env.USERNAME;
|
||||
if (ownerUser) {
|
||||
|
||||
Reference in new issue
Block a user