mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-08 13:46:08 +00:00
9b91f0f42e
Fold the standalone 3x-ui-docs project (Next.js 16 + Fumadocs, deployed to docs.sanaei.dev) into docs/ so the panel and its documentation share a single source of truth, the way sing-box keeps its docs in-tree. The old repo becomes redundant and can be retired. - Import the full site under docs/ (app, components, content, lib, public, scripts, config). The self-contained pnpm project sits alongside the existing engineering notes with no filename collisions. - Re-point "Edit on GitHub" links from MHSanaei/3x-ui-docs to this repo's docs/content/docs path (docs/lib/shared.ts, docs/app/.../page.tsx). - Add docs-ci.yml and docs-deploy.yml under .github/workflows/, scoped to docs/** and run with working-directory: docs, since GitHub only runs workflows from the repo-root .github/. deploy-static.yml's GitHub Pages publish (CNAME docs.sanaei.dev) carries over unchanged. Follow-up (outside this commit): attach the docs.sanaei.dev custom domain to this repository's Pages (or set the Vercel project's root directory to docs), confirm the site is live from the monorepo, then delete MHSanaei/3x-ui-docs.
115 lines
3.3 KiB
TypeScript
115 lines
3.3 KiB
TypeScript
'use client';
|
|
|
|
import type { ReactNode } from 'react';
|
|
import { useState } from 'react';
|
|
import {
|
|
validateBotToken,
|
|
parseAdminIds,
|
|
validateRunTime,
|
|
telegramApiBase,
|
|
buildBotConfigSummary,
|
|
} from '@/lib/xray/telegram';
|
|
import { ToolFrame } from './tool-frame';
|
|
import { TextField } from './shared/fields';
|
|
import { OutputBlock } from './shared/output-block';
|
|
|
|
function Status({ ok, children }: { ok: boolean; children: ReactNode }) {
|
|
return (
|
|
<p
|
|
className={`text-xs ${ok ? 'text-emerald-600 dark:text-emerald-400' : 'text-red-600 dark:text-red-400'}`}
|
|
>
|
|
{children}
|
|
</p>
|
|
);
|
|
}
|
|
|
|
export function TelegramSetupHelper() {
|
|
const [token, setToken] = useState('');
|
|
const [adminIds, setAdminIds] = useState('');
|
|
const [runTime, setRunTime] = useState('@daily');
|
|
|
|
const tokenV = validateBotToken(token);
|
|
const idsV = parseAdminIds(adminIds);
|
|
const cronV = validateRunTime(runTime);
|
|
const summary = buildBotConfigSummary({ token, adminIds, runTime });
|
|
|
|
const settingsText = [
|
|
`tgBotEnable = true`,
|
|
`tgBotToken = ${summary.tgBotToken || '<token>'}`,
|
|
`tgBotChatId = ${summary.tgBotChatId || '<admin ids>'}`,
|
|
`tgRunTime = ${summary.tgRunTime || '@daily'}`,
|
|
].join('\n');
|
|
|
|
function reset() {
|
|
setToken('');
|
|
setAdminIds('');
|
|
setRunTime('@daily');
|
|
}
|
|
|
|
return (
|
|
<ToolFrame
|
|
title="Telegram bot setup helper"
|
|
description="Validate your bot token, admin IDs, and report schedule, then copy the panel settings."
|
|
onReset={reset}
|
|
>
|
|
<div className="grid grid-cols-1 gap-4">
|
|
<div>
|
|
<TextField
|
|
label="Bot token (from @BotFather)"
|
|
value={token}
|
|
onChange={setToken}
|
|
placeholder="123456789:AA..."
|
|
/>
|
|
{token ? (
|
|
tokenV.valid ? (
|
|
<Status ok>Valid — bot id {tokenV.botId}</Status>
|
|
) : (
|
|
<Status ok={false}>{tokenV.error}</Status>
|
|
)
|
|
) : null}
|
|
</div>
|
|
<div>
|
|
<TextField
|
|
label="Admin chat IDs (comma-separated)"
|
|
value={adminIds}
|
|
onChange={setAdminIds}
|
|
placeholder="111111111, 222222222"
|
|
/>
|
|
{adminIds ? (
|
|
idsV.invalid.length > 0 ? (
|
|
<Status ok={false}>Not numeric: {idsV.invalid.join(', ')}</Status>
|
|
) : (
|
|
<Status ok>
|
|
{idsV.ids.length} admin id{idsV.ids.length === 1 ? '' : 's'}
|
|
</Status>
|
|
)
|
|
) : null}
|
|
</div>
|
|
<div>
|
|
<TextField
|
|
label="Report schedule (tgRunTime)"
|
|
value={runTime}
|
|
onChange={setRunTime}
|
|
placeholder="@daily, @every 8h, or a cron expression"
|
|
/>
|
|
{runTime ? (
|
|
cronV.valid ? (
|
|
<Status ok>Valid ({cronV.kind})</Status>
|
|
) : (
|
|
<Status ok={false}>{cronV.error}</Status>
|
|
)
|
|
) : null}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="mt-4 grid grid-cols-1 gap-4">
|
|
<OutputBlock label="Panel settings" value={settingsText} />
|
|
<OutputBlock
|
|
label="Bot API base (keep secret)"
|
|
value={tokenV.valid ? telegramApiBase(token) : 'https://api.telegram.org/bot<token>'}
|
|
/>
|
|
</div>
|
|
</ToolFrame>
|
|
);
|
|
}
|