Apply formatting and minor style fixes across repo
Normalize code style across multiple packages: whitespace cleanup, consistent commas and trailing commas in arrays/enums/objects, fix table markdown lines in CI comment template, ensure newline at EOF, normalize header/object property quoting and spacing, remove stray blank lines and minor non-functional comment tweaks. These are formatting-only changes and small type/annotation spacing adjustments; no functional behavior changes intended.
This commit is contained in:
1 parent
d2d0b258bc
commit
974528fe7e
186 files changed
+1367
-1233
No files matched your search
@@ -16,7 +16,7 @@ import {
|
||||
BsGlobe,
|
||||
BsPlugin,
|
||||
BsTelegram,
|
||||
BsTencentQq
|
||||
BsTencentQq,
|
||||
} from 'react-icons/bs';
|
||||
import { IoDocument, IoRocketSharp } from 'react-icons/io5';
|
||||
|
||||
@@ -31,16 +31,20 @@ function VersionInfo () {
|
||||
|
||||
return (
|
||||
<div className='flex items-center gap-2'>
|
||||
{error ? (
|
||||
<Chip color="danger" variant="flat" size="sm">{error.message}</Chip>
|
||||
) : loading ? (
|
||||
<Spinner size='sm' color="default" />
|
||||
) : (
|
||||
<div className="flex items-center gap-2">
|
||||
<Chip size="sm" color="default" variant="flat" className="text-default-500">WebUI v0.0.6</Chip>
|
||||
<Chip size="sm" color="primary" variant="flat">Core {data?.version}</Chip>
|
||||
</div>
|
||||
)}
|
||||
{error
|
||||
? (
|
||||
<Chip color='danger' variant='flat' size='sm'>{error.message}</Chip>
|
||||
)
|
||||
: loading
|
||||
? (
|
||||
<Spinner size='sm' color='default' />
|
||||
)
|
||||
: (
|
||||
<div className='flex items-center gap-2'>
|
||||
<Chip size='sm' color='default' variant='flat' className='text-default-500'>WebUI v0.0.6</Chip>
|
||||
<Chip size='sm' color='primary' variant='flat'>Core {data?.version}</Chip>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -75,7 +79,7 @@ function NapCatFileHash () {
|
||||
if (!isLoginAccountInList) {
|
||||
accounts.push({
|
||||
uin: String(loginData.uin),
|
||||
label: loginData.nick ? `${loginData.nick}(${loginData.uin})` : String(loginData.uin)
|
||||
label: loginData.nick ? `${loginData.nick}(${loginData.uin})` : String(loginData.uin),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -101,53 +105,59 @@ function NapCatFileHash () {
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-2 text-sm font-medium text-default-700">
|
||||
<div className='space-y-2'>
|
||||
<div className='flex items-center gap-2 text-sm font-medium text-default-700'>
|
||||
<span>入群密码</span>
|
||||
{loading && <Spinner size="sm" color="default" />}
|
||||
{loading && <Spinner size='sm' color='default' />}
|
||||
</div>
|
||||
{error ? (
|
||||
<Chip color="warning" variant="flat" size="sm">无法计算:{(error as Error).message}</Chip>
|
||||
) : loading ? null : accounts.length > 0 ? (
|
||||
<div className="space-y-3">
|
||||
{accounts.length > 1 && (
|
||||
<Select
|
||||
label="选择账号"
|
||||
size="sm"
|
||||
selectedKeys={selectedUin ? [selectedUin] : []}
|
||||
onChange={(e) => setSelectedUin(e.target.value)}
|
||||
className="max-w-full"
|
||||
>
|
||||
{accounts.map((acc) => (
|
||||
<SelectItem key={acc.uin} textValue={acc.label}>
|
||||
{acc.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
{error
|
||||
? (
|
||||
<Chip color='warning' variant='flat' size='sm'>无法计算:{(error as Error).message}</Chip>
|
||||
)
|
||||
: loading
|
||||
? null
|
||||
: accounts.length > 0
|
||||
? (
|
||||
<div className='space-y-3'>
|
||||
{accounts.length > 1 && (
|
||||
<Select
|
||||
label='选择账号'
|
||||
size='sm'
|
||||
selectedKeys={selectedUin ? [selectedUin] : []}
|
||||
onChange={(e) => setSelectedUin(e.target.value)}
|
||||
className='max-w-full'
|
||||
>
|
||||
{accounts.map((acc) => (
|
||||
<SelectItem key={acc.uin} textValue={acc.label}>
|
||||
{acc.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
|
||||
{password && (
|
||||
<div className="space-y-1">
|
||||
{accounts.length === 1 && <p className="text-xs text-default-500">{currentAccount.label}</p>}
|
||||
<Tooltip content={`使用 ${currentAccount.label} 申请入群,以此值作为入群密码`} placement="top">
|
||||
<Snippet
|
||||
size="sm"
|
||||
variant="flat"
|
||||
symbol=""
|
||||
codeString={password}
|
||||
className="w-full"
|
||||
classNames={{
|
||||
pre: 'text-xs break-all whitespace-pre-wrap font-mono',
|
||||
}}
|
||||
>
|
||||
{password}
|
||||
</Snippet>
|
||||
</Tooltip>
|
||||
</div>
|
||||
)}
|
||||
<p className="text-xs text-warning-500">入群密钥绑定QQ,使用对应QQ申请入群即可。</p>
|
||||
</div>
|
||||
) : null}
|
||||
{password && (
|
||||
<div className='space-y-1'>
|
||||
{accounts.length === 1 && <p className='text-xs text-default-500'>{currentAccount.label}</p>}
|
||||
<Tooltip content={`使用 ${currentAccount.label} 申请入群,以此值作为入群密码`} placement='top'>
|
||||
<Snippet
|
||||
size='sm'
|
||||
variant='flat'
|
||||
symbol=''
|
||||
codeString={password}
|
||||
className='w-full'
|
||||
classNames={{
|
||||
pre: 'text-xs break-all whitespace-pre-wrap font-mono',
|
||||
}}
|
||||
>
|
||||
{password}
|
||||
</Snippet>
|
||||
</Tooltip>
|
||||
</div>
|
||||
)}
|
||||
<p className='text-xs text-warning-500'>入群密钥绑定QQ,使用对应QQ申请入群即可。</p>
|
||||
</div>
|
||||
)
|
||||
: null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -158,26 +168,26 @@ export default function AboutPage () {
|
||||
icon: <IoRocketSharp size={20} />,
|
||||
title: '高性能架构',
|
||||
desc: 'Node.js + Native 混合架构,资源占用低,响应速度快。',
|
||||
className: 'bg-primary-50 text-primary'
|
||||
className: 'bg-primary-50 text-primary',
|
||||
},
|
||||
{
|
||||
icon: <BsGlobe size={20} />,
|
||||
title: '全平台支持',
|
||||
desc: '适配 Windows、Linux 及 Docker 环境。',
|
||||
className: 'bg-success-50 text-success'
|
||||
className: 'bg-success-50 text-success',
|
||||
},
|
||||
{
|
||||
icon: <BsCodeSlash size={20} />,
|
||||
title: 'OneBot 11',
|
||||
desc: '深度集成标准协议,兼容现有生态。',
|
||||
className: 'bg-warning-50 text-warning'
|
||||
className: 'bg-warning-50 text-warning',
|
||||
},
|
||||
{
|
||||
icon: <BsPlugin size={20} />,
|
||||
title: '极易扩展',
|
||||
desc: '提供丰富的 API 接口与 WebHook 支持。',
|
||||
className: 'bg-secondary-50 text-secondary'
|
||||
}
|
||||
className: 'bg-secondary-50 text-secondary',
|
||||
},
|
||||
];
|
||||
|
||||
const links = [
|
||||
@@ -190,37 +200,37 @@ export default function AboutPage () {
|
||||
{ icon: <IoDocument />, name: '文档', href: 'https://napcat.napneko.icu/' },
|
||||
];
|
||||
|
||||
const cardStyle = "bg-default/40 backdrop-blur-lg border-none shadow-none";
|
||||
const cardStyle = 'bg-default/40 backdrop-blur-lg border-none shadow-none';
|
||||
|
||||
return (
|
||||
<div className='flex flex-col h-full w-full gap-6 p-2 md:p-6'>
|
||||
<title>关于 - NapCat WebUI</title>
|
||||
|
||||
{/* 头部标题区 */}
|
||||
<div className="flex flex-col gap-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3 text-default-900">
|
||||
<Image src={logo} alt="NapCat Logo" width={32} height={32} />
|
||||
<div className='flex flex-col gap-2'>
|
||||
<h1 className='text-2xl font-bold flex items-center gap-3 text-default-900'>
|
||||
<Image src={logo} alt='NapCat Logo' width={32} height={32} />
|
||||
关于 NapCat
|
||||
</h1>
|
||||
<div className="flex items-center gap-4 text-small text-default-500">
|
||||
<div className='flex items-center gap-4 text-small text-default-500'>
|
||||
<p>现代化、轻量级的 QQ 机器人框架</p>
|
||||
<Divider orientation="vertical" className="h-4" />
|
||||
<Divider orientation='vertical' className='h-4' />
|
||||
<VersionInfo />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider className="opacity-50" />
|
||||
<Divider className='opacity-50' />
|
||||
|
||||
{/* 主内容区:双栏布局 */}
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6 flex-grow">
|
||||
<div className='grid grid-cols-1 lg:grid-cols-3 gap-6 flex-grow'>
|
||||
|
||||
{/* 左侧:介绍与特性 */}
|
||||
<div className="lg:col-span-2 space-y-6">
|
||||
<Card shadow="sm" className={cardStyle}>
|
||||
<CardHeader className="pb-0 pt-4 px-4 flex-col items-start">
|
||||
<h2 className="text-lg font-bold">项目简介</h2>
|
||||
<div className='lg:col-span-2 space-y-6'>
|
||||
<Card shadow='sm' className={cardStyle}>
|
||||
<CardHeader className='pb-0 pt-4 px-4 flex-col items-start'>
|
||||
<h2 className='text-lg font-bold'>项目简介</h2>
|
||||
</CardHeader>
|
||||
<CardBody className="py-4 text-default-600 leading-relaxed space-y-2">
|
||||
<CardBody className='py-4 text-default-600 leading-relaxed space-y-2'>
|
||||
<p>
|
||||
NapCat (瞌睡猫) 是一个致力于打破 QQ 机器人开发壁垒的开源项目。我们利用 NTQQ 的底层能力,
|
||||
构建了一个无需 GUI 即可在服务器端稳定运行的 Headless 框架。
|
||||
@@ -232,16 +242,16 @@ export default function AboutPage () {
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className='grid grid-cols-1 md:grid-cols-2 gap-4'>
|
||||
{features.map((item, index) => (
|
||||
<Card key={index} shadow="sm" className={cardStyle}>
|
||||
<CardBody className="flex flex-row items-start gap-4 p-4">
|
||||
<Card key={index} shadow='sm' className={cardStyle}>
|
||||
<CardBody className='flex flex-row items-start gap-4 p-4'>
|
||||
<div className={`p-3 rounded-lg ${item.className}`}>
|
||||
{item.icon}
|
||||
</div>
|
||||
<div>
|
||||
<h3 className="font-semibold text-default-900">{item.title}</h3>
|
||||
<p className="text-small text-default-500 mt-1">{item.desc}</p>
|
||||
<h3 className='font-semibold text-default-900'>{item.title}</h3>
|
||||
<p className='text-small text-default-500 mt-1'>{item.desc}</p>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
@@ -250,42 +260,42 @@ export default function AboutPage () {
|
||||
</div>
|
||||
|
||||
{/* 右侧:信息与链接 */}
|
||||
<div className="space-y-6">
|
||||
<Card shadow="sm" className={cardStyle}>
|
||||
<CardHeader className="pb-0 pt-4 px-4">
|
||||
<h2 className="text-lg font-bold">相关资源</h2>
|
||||
<div className='space-y-6'>
|
||||
<Card shadow='sm' className={cardStyle}>
|
||||
<CardHeader className='pb-0 pt-4 px-4'>
|
||||
<h2 className='text-lg font-bold'>相关资源</h2>
|
||||
</CardHeader>
|
||||
<CardBody className="py-4 space-y-4">
|
||||
<CardBody className='py-4 space-y-4'>
|
||||
<NapCatFileHash />
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className='flex flex-col gap-2'>
|
||||
{links.map((link, idx) => (
|
||||
<Link
|
||||
key={idx}
|
||||
isExternal
|
||||
href={link.href}
|
||||
className="flex items-center justify-between p-3 rounded-xl hover:bg-default-100/50 transition-colors text-default-600"
|
||||
className='flex items-center justify-between p-3 rounded-xl hover:bg-default-100/50 transition-colors text-default-600'
|
||||
>
|
||||
<span className="flex items-center gap-3">
|
||||
<span className='flex items-center gap-3'>
|
||||
{link.icon}
|
||||
{link.name}
|
||||
</span>
|
||||
<span className="text-tiny text-default-400">跳转 →</span>
|
||||
<span className='text-tiny text-default-400'>跳转 →</span>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</CardBody>
|
||||
</Card>
|
||||
|
||||
<Card shadow="sm" className={cardStyle}>
|
||||
<CardHeader className="pb-0 pt-4 px-4">
|
||||
<h2 className="text-lg font-bold flex items-center gap-2">
|
||||
<Card shadow='sm' className={cardStyle}>
|
||||
<CardHeader className='pb-0 pt-4 px-4'>
|
||||
<h2 className='text-lg font-bold flex items-center gap-2'>
|
||||
<BsCpu /> 技术栈
|
||||
</h2>
|
||||
</CardHeader>
|
||||
<CardBody className="py-4">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<CardBody className='py-4'>
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
{['TypeScript', 'React', 'Vite', 'Node.js', 'Electron', 'HeroUI'].map((tech) => (
|
||||
<Chip key={tech} size="sm" variant="flat" className="bg-default-100/50 text-default-600">
|
||||
<Chip key={tech} size='sm' variant='flat' className='bg-default-100/50 text-default-600'>
|
||||
{tech}
|
||||
</Chip>
|
||||
))}
|
||||
@@ -296,12 +306,12 @@ export default function AboutPage () {
|
||||
</div>
|
||||
|
||||
{/* 底部版权 - 移出 grid 布局 */}
|
||||
<div className="w-full text-center text-tiny text-default-400 py-4 mt-auto flex flex-col items-center gap-1">
|
||||
<p className="flex items-center justify-center gap-1">
|
||||
Made with <span className="text-danger">❤️</span> by NapCat Team
|
||||
<div className='w-full text-center text-tiny text-default-400 py-4 mt-auto flex flex-col items-center gap-1'>
|
||||
<p className='flex items-center justify-center gap-1'>
|
||||
Made with <span className='text-danger'>❤️</span> by NapCat Team
|
||||
</p>
|
||||
<p>MIT License © {new Date().getFullYear()}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,6 @@ const handleImportConfig = async (event: React.ChangeEvent<HTMLInputElement>) =>
|
||||
} else {
|
||||
toast.error(`配置导入失败: ${result.data?.message || '未知错误'}`);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
const msg = (error as Error).message;
|
||||
toast.error(`导入配置失败: ${msg}`);
|
||||
@@ -88,26 +87,26 @@ const BackupConfigCard: React.FC = () => {
|
||||
<div className='flex flex-wrap gap-3'>
|
||||
<Button
|
||||
isIconOnly
|
||||
className="bg-primary hover:bg-primary/90 text-white"
|
||||
className='bg-primary hover:bg-primary/90 text-white'
|
||||
radius='full'
|
||||
onPress={handleExportConfig}
|
||||
title="导出配置"
|
||||
title='导出配置'
|
||||
>
|
||||
<LuDownload size={20} />
|
||||
</Button>
|
||||
<label className="cursor-pointer">
|
||||
<label className='cursor-pointer'>
|
||||
<input
|
||||
type="file"
|
||||
accept=".zip"
|
||||
type='file'
|
||||
accept='.zip'
|
||||
onChange={handleImportConfig}
|
||||
className="hidden"
|
||||
className='hidden'
|
||||
/>
|
||||
<Button
|
||||
isIconOnly
|
||||
className="bg-primary hover:bg-primary/90 text-white"
|
||||
className='bg-primary hover:bg-primary/90 text-white'
|
||||
radius='full'
|
||||
as="span"
|
||||
title="导入配置"
|
||||
as='span'
|
||||
title='导入配置'
|
||||
>
|
||||
<LuUpload size={20} />
|
||||
</Button>
|
||||
@@ -126,4 +125,4 @@ const BackupConfigCard: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default BackupConfigCard;
|
||||
export default BackupConfigCard;
|
||||
@@ -18,7 +18,6 @@ interface BypassFormData {
|
||||
o3HookMode: boolean;
|
||||
}
|
||||
|
||||
|
||||
const BypassConfigCard = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const {
|
||||
|
||||
@@ -38,7 +38,8 @@ const ConfigPageItem: React.FC<ConfigPageProps> = ({
|
||||
'max-w-3xl': size === 'md',
|
||||
'max-w-6xl': size === 'lg',
|
||||
}
|
||||
)}>
|
||||
)}
|
||||
>
|
||||
<CardBody className='py-6 px-4 md:py-8 md:px-12'>
|
||||
<div className='w-full flex flex-col gap-5'>
|
||||
{children}
|
||||
|
||||
@@ -273,7 +273,7 @@ const ServerConfigCard = () => {
|
||||
<textarea
|
||||
value={ipListText}
|
||||
onChange={(e) => setIpListText(e.target.value)}
|
||||
placeholder={`每行一个IP地址或规则\n支持格式:\nIPv4:\n- 精确IP: 192.168.1.100\n- 通配符: 192.168.1.*\n- CIDR: 192.168.1.0/24\nIPv6:\n- 精确IP: 2001:db8::1\n- CIDR: 2001:db8::/32`}
|
||||
placeholder={'每行一个IP地址或规则\n支持格式:\nIPv4:\n- 精确IP: 192.168.1.100\n- 通配符: 192.168.1.*\n- CIDR: 192.168.1.0/24\nIPv6:\n- 精确IP: 2001:db8::1\n- CIDR: 2001:db8::/32'}
|
||||
disabled={!!configError}
|
||||
rows={10}
|
||||
className='w-full px-3 py-2 bg-default-100/50 dark:bg-white/5 backdrop-blur-md border border-transparent hover:bg-default-200/50 dark:hover:bg-white/10 transition-all shadow-sm hover:border-default-300 rounded-lg text-default-700 dark:text-default-300 placeholder:text-default-400 font-mono text-sm resize-y focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed'
|
||||
|
||||
@@ -348,7 +348,7 @@ const ThemeConfigCard = () => {
|
||||
>
|
||||
保存应用
|
||||
</Button>
|
||||
<div className='w-px h-6 bg-divider mx-1 hidden sm:block'></div>
|
||||
<div className='w-px h-6 bg-divider mx-1 hidden sm:block' />
|
||||
<Button
|
||||
size='sm'
|
||||
isIconOnly
|
||||
@@ -364,22 +364,22 @@ const ThemeConfigCard = () => {
|
||||
|
||||
<div className='px-4 pt-0 pb-4 w-full h-full'>
|
||||
<Tabs
|
||||
aria-label="Theme Config Options"
|
||||
color="primary"
|
||||
variant="underlined"
|
||||
aria-label='Theme Config Options'
|
||||
color='primary'
|
||||
variant='underlined'
|
||||
disableAnimation
|
||||
classNames={{
|
||||
tabList: "gap-8 w-full relative rounded-none p-0 border-b border-divider overflow-x-auto no-scrollbar",
|
||||
cursor: "w-full bg-primary h-[3px] -bottom-[1.5px]",
|
||||
tab: "max-w-fit px-0 h-12 hover:opacity-100 opacity-70 data-[selected=true]:opacity-100",
|
||||
tabContent: "font-semibold py-2",
|
||||
panel: "py-4"
|
||||
tabList: 'gap-8 w-full relative rounded-none p-0 border-b border-divider overflow-x-auto no-scrollbar',
|
||||
cursor: 'w-full bg-primary h-[3px] -bottom-[1.5px]',
|
||||
tab: 'max-w-fit px-0 h-12 hover:opacity-100 opacity-70 data-[selected=true]:opacity-100',
|
||||
tabContent: 'font-semibold py-2',
|
||||
panel: 'py-4',
|
||||
}}
|
||||
>
|
||||
<Tab
|
||||
key="font"
|
||||
key='font'
|
||||
title={
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className='flex items-center space-x-2'>
|
||||
<FaFont />
|
||||
<span>字体设置</span>
|
||||
</div>
|
||||
@@ -463,9 +463,9 @@ const ThemeConfigCard = () => {
|
||||
</Tab>
|
||||
|
||||
<Tab
|
||||
key="theme"
|
||||
key='theme'
|
||||
title={
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className='flex items-center space-x-2'>
|
||||
<IoIosColorPalette size={18} />
|
||||
<span>选择主题</span>
|
||||
</div>
|
||||
@@ -486,9 +486,9 @@ const ThemeConfigCard = () => {
|
||||
</Tab>
|
||||
|
||||
<Tab
|
||||
key="custom-color"
|
||||
key='custom-color'
|
||||
title={
|
||||
<div className="flex items-center space-x-2">
|
||||
<div className='flex items-center space-x-2'>
|
||||
<FaPaintbrush />
|
||||
<span>自定义配色</span>
|
||||
</div>
|
||||
@@ -499,7 +499,7 @@ const ThemeConfigCard = () => {
|
||||
<Card key={mode} className={clsx('border shadow-sm', mode === 'dark' ? 'bg-[#18181b] border-zinc-800' : 'bg-white border-zinc-200')}>
|
||||
<CardHeader className='pb-0 pt-4 px-4 flex-col items-start'>
|
||||
<div className='flex items-center gap-2 mb-1'>
|
||||
{mode === 'dark' ? <MdDarkMode className="text-zinc-400" size={20} /> : <MdLightMode className="text-orange-400" size={20} />}
|
||||
{mode === 'dark' ? <MdDarkMode className='text-zinc-400' size={20} /> : <MdLightMode className='text-orange-400' size={20} />}
|
||||
<h4 className={clsx('font-bold text-large', mode === 'dark' ? 'text-white' : 'text-black')}>
|
||||
{mode === 'dark' ? '深色模式' : '浅色模式'}
|
||||
</h4>
|
||||
|
||||
@@ -153,7 +153,7 @@ const WebUIConfigCard = () => {
|
||||
challenge: base64UrlToUint8Array(registrationOptions.challenge) as BufferSource,
|
||||
rp: {
|
||||
name: registrationOptions.rp.name,
|
||||
id: registrationOptions.rp.id
|
||||
id: registrationOptions.rp.id,
|
||||
},
|
||||
user: {
|
||||
id: base64UrlToUint8Array(registrationOptions.user.id) as BufferSource,
|
||||
|
||||
@@ -53,14 +53,14 @@ export default function HttpDebug () {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${localStorage.getItem('token')}`
|
||||
}
|
||||
Authorization: `Bearer ${localStorage.getItem('token')}`,
|
||||
},
|
||||
}).then(res => res.json()).then(data => {
|
||||
if (data.code === 0) {
|
||||
currentAdapterName = data.data.adapterName;
|
||||
setAdapterName(currentAdapterName);
|
||||
}
|
||||
})
|
||||
}),
|
||||
]);
|
||||
setOneBotHttpApi(apiData);
|
||||
} catch (error) {
|
||||
@@ -75,7 +75,6 @@ export default function HttpDebug () {
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
const handleSelectApi = (api: OneBotHttpApiPath) => {
|
||||
if (!openApis.includes(api)) {
|
||||
setOpenApis([...openApis, api]);
|
||||
@@ -161,16 +160,18 @@ export default function HttpDebug () {
|
||||
// ? 'bg-white/5 dark:bg-black/5 backdrop-blur-sm border-white/10'
|
||||
// : 'bg-white/40 dark:bg-black/20 backdrop-blur-md shadow-sm border-white/40 dark:border-white/10'
|
||||
'bg-transparent'
|
||||
)}>
|
||||
)}
|
||||
>
|
||||
<div className='flex-1 flex flex-col overflow-hidden relative'>
|
||||
<div className={clsx(
|
||||
'flex items-center w-full flex-shrink-0 pr-2 md:pl-4 py-1 relative z-20 rounded-md',
|
||||
hasBackground
|
||||
? 'bg-white/5'
|
||||
: 'bg-white/30 dark:bg-white/5'
|
||||
)}>
|
||||
)}
|
||||
>
|
||||
{/* Tab List */}
|
||||
<div className="flex-1 overflow-x-auto no-scrollbar flex items-center">
|
||||
<div className='flex-1 overflow-x-auto no-scrollbar flex items-center'>
|
||||
{openApis.map((api) => {
|
||||
const isActive = api === activeApi;
|
||||
const item = oneBotHttpApi[api];
|
||||
@@ -193,7 +194,9 @@ export default function HttpDebug () {
|
||||
isActive
|
||||
? 'bg-success/20 text-success'
|
||||
: 'opacity-60 bg-default-200/50 dark:bg-white/10'
|
||||
)}>POST</span>
|
||||
)}
|
||||
>POST
|
||||
</span>
|
||||
<span className='text-xs truncate flex-1'>{item?.description || api}</span>
|
||||
<div
|
||||
className={clsx(
|
||||
@@ -206,7 +209,6 @@ export default function HttpDebug () {
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
})}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -51,12 +51,12 @@ export default function WSDebug () {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${localStorage.getItem('token')}`
|
||||
}
|
||||
Authorization: `Bearer ${localStorage.getItem('token')}`,
|
||||
},
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.code === 0) {
|
||||
//const adapterName = data.data.adapterName;
|
||||
// const adapterName = data.data.adapterName;
|
||||
const token = data.data.token;
|
||||
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||
|
||||
@@ -66,7 +66,7 @@ export default function WSDebug () {
|
||||
|
||||
setSocketConfig({
|
||||
url: wsUrl,
|
||||
token: token
|
||||
token,
|
||||
});
|
||||
setInputUrl(wsUrl);
|
||||
setInputToken(token);
|
||||
@@ -120,7 +120,8 @@ export default function WSDebug () {
|
||||
hasBackground
|
||||
? 'bg-white/10 dark:bg-black/10 border-white/40 dark:border-white/10'
|
||||
: 'bg-white/60 dark:bg-black/40 border-white/40 dark:border-white/10'
|
||||
)}>
|
||||
)}
|
||||
>
|
||||
<CardBody className='gap-3 p-3 md:p-4'>
|
||||
{/* Connection Config */}
|
||||
<div className='grid gap-3 items-end md:grid-cols-[1fr_1fr_auto]'>
|
||||
@@ -162,17 +163,17 @@ export default function WSDebug () {
|
||||
input: hasBackground ? 'text-white placeholder:text-white/50' : '',
|
||||
}}
|
||||
/>
|
||||
<div className="flex gap-2">
|
||||
<div className='flex gap-2'>
|
||||
<Button
|
||||
isIconOnly
|
||||
size="md"
|
||||
radius="full"
|
||||
color="warning"
|
||||
variant="flat"
|
||||
size='md'
|
||||
radius='full'
|
||||
color='warning'
|
||||
variant='flat'
|
||||
onPress={handleResetConfig}
|
||||
title="重置配置"
|
||||
title='重置配置'
|
||||
>
|
||||
<IoRefresh className="text-xl" />
|
||||
<IoRefresh className='text-xl' />
|
||||
</Button>
|
||||
<Button
|
||||
onPress={shouldConnect ? handleDisconnect : handleConnect}
|
||||
@@ -193,9 +194,10 @@ export default function WSDebug () {
|
||||
hasBackground
|
||||
? 'bg-white/10 border-white/20'
|
||||
: 'bg-white/50 dark:bg-white/5 border-white/20'
|
||||
)}>
|
||||
)}
|
||||
>
|
||||
<div className='flex items-center gap-3 w-full md:w-auto'>
|
||||
<div className="flex-shrink-0">
|
||||
<div className='flex-shrink-0'>
|
||||
<WSStatus state={readyState} />
|
||||
</div>
|
||||
<div className='flex-1 md:w-56 overflow-hidden'>
|
||||
@@ -225,7 +227,8 @@ export default function WSDebug () {
|
||||
hasBackground
|
||||
? 'bg-white/10 dark:bg-black/10 border-white/40 dark:border-white/10'
|
||||
: 'bg-white/60 dark:bg-black/40 border-white/40 dark:border-white/10'
|
||||
)}>
|
||||
)}
|
||||
>
|
||||
<OneBotMessageList messages={filteredMessages} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -375,7 +375,7 @@ export default function NetworkPage () {
|
||||
<AddButton onOpen={handleClickCreate} />
|
||||
<Button
|
||||
isIconOnly
|
||||
className="bg-default-100/50 hover:bg-default-200/50 text-default-700 backdrop-blur-md"
|
||||
className='bg-default-100/50 hover:bg-default-200/50 text-default-700 backdrop-blur-md'
|
||||
radius='full'
|
||||
onPress={refresh}
|
||||
>
|
||||
|
||||
@@ -44,8 +44,6 @@ export default function PluginPage () {
|
||||
loadPlugins();
|
||||
}, []);
|
||||
|
||||
|
||||
|
||||
const handleToggle = async (plugin: PluginItem) => {
|
||||
const isEnable = plugin.status !== 'active';
|
||||
const actionText = isEnable ? '启用' : '禁用';
|
||||
@@ -65,18 +63,18 @@ export default function PluginPage () {
|
||||
dialog.confirm({
|
||||
title: '卸载插件',
|
||||
content: (
|
||||
<div className="flex flex-col gap-2">
|
||||
<p className="text-base text-default-800">确定要卸载插件「<span className="font-semibold text-danger">{plugin.name}</span>」吗? 此操作不可恢复。</p>
|
||||
<div className="mt-2 bg-default-100 dark:bg-default-50/10 p-3 rounded-lg flex flex-col gap-1">
|
||||
<label className="flex items-center gap-2 cursor-pointer w-fit">
|
||||
<div className='flex flex-col gap-2'>
|
||||
<p className='text-base text-default-800'>确定要卸载插件「<span className='font-semibold text-danger'>{plugin.name}</span>」吗? 此操作不可恢复。</p>
|
||||
<div className='mt-2 bg-default-100 dark:bg-default-50/10 p-3 rounded-lg flex flex-col gap-1'>
|
||||
<label className='flex items-center gap-2 cursor-pointer w-fit'>
|
||||
<input
|
||||
type="checkbox"
|
||||
type='checkbox'
|
||||
onChange={(e) => { cleanData = e.target.checked; }}
|
||||
className="w-4 h-4 cursor-pointer accent-danger"
|
||||
className='w-4 h-4 cursor-pointer accent-danger'
|
||||
/>
|
||||
<span className="text-small font-medium text-default-700">同时删除其配置文件</span>
|
||||
<span className='text-small font-medium text-default-700'>同时删除其配置文件</span>
|
||||
</label>
|
||||
<p className="text-xs text-default-500 pl-6 break-all w-full">配置目录: config/plugins/{plugin.id}</p>
|
||||
<p className='text-xs text-default-500 pl-6 break-all w-full'>配置目录: config/plugins/{plugin.id}</p>
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
@@ -96,7 +94,7 @@ export default function PluginPage () {
|
||||
},
|
||||
onCancel: () => {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -173,10 +171,10 @@ export default function PluginPage () {
|
||||
/>
|
||||
|
||||
<div className='flex mb-6 items-center gap-4'>
|
||||
<h1 className="text-2xl font-bold">插件管理</h1>
|
||||
<h1 className='text-2xl font-bold'>插件管理</h1>
|
||||
<Button
|
||||
isIconOnly
|
||||
className="bg-default-100/50 hover:bg-default-200/50 text-default-700 backdrop-blur-md"
|
||||
className='bg-default-100/50 hover:bg-default-200/50 text-default-700 backdrop-blur-md'
|
||||
radius='full'
|
||||
onPress={loadPlugins}
|
||||
>
|
||||
@@ -201,40 +199,44 @@ export default function PluginPage () {
|
||||
*/}
|
||||
</div>
|
||||
|
||||
{pluginManagerNotFound ? (
|
||||
<div className="flex flex-col items-center justify-center min-h-[400px] text-center">
|
||||
<div className="text-6xl mb-4">📦</div>
|
||||
<h2 className="text-xl font-semibold text-default-700 dark:text-white/90 mb-2">
|
||||
无插件加载
|
||||
</h2>
|
||||
<p className="text-default-500 dark:text-white/60 max-w-md">
|
||||
插件管理器未加载,请检查 plugins 目录是否存在
|
||||
</p>
|
||||
</div>
|
||||
) : plugins.length === 0 ? (
|
||||
<div className="text-default-400">暂时没有安装插件</div>
|
||||
) : (
|
||||
<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 justify-start items-stretch gap-x-2 gap-y-4'>
|
||||
{plugins.map(plugin => (
|
||||
<PluginDisplayCard
|
||||
key={plugin.id}
|
||||
data={plugin}
|
||||
onToggleStatus={() => handleToggle(plugin)}
|
||||
onUninstall={() => handleUninstall(plugin)}
|
||||
onConfig={() => {
|
||||
if (plugin.status !== 'active') {
|
||||
toast.error('未启用插件,无法配置插件');
|
||||
} else if (plugin.hasConfig) {
|
||||
handleConfig(plugin);
|
||||
} else {
|
||||
toast.error('此插件没有配置哦');
|
||||
}
|
||||
}}
|
||||
hasConfig={true}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{pluginManagerNotFound
|
||||
? (
|
||||
<div className='flex flex-col items-center justify-center min-h-[400px] text-center'>
|
||||
<div className='text-6xl mb-4'>📦</div>
|
||||
<h2 className='text-xl font-semibold text-default-700 dark:text-white/90 mb-2'>
|
||||
无插件加载
|
||||
</h2>
|
||||
<p className='text-default-500 dark:text-white/60 max-w-md'>
|
||||
插件管理器未加载,请检查 plugins 目录是否存在
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
: plugins.length === 0
|
||||
? (
|
||||
<div className='text-default-400'>暂时没有安装插件</div>
|
||||
)
|
||||
: (
|
||||
<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 justify-start items-stretch gap-x-2 gap-y-4'>
|
||||
{plugins.map(plugin => (
|
||||
<PluginDisplayCard
|
||||
key={plugin.id}
|
||||
data={plugin}
|
||||
onToggleStatus={() => handleToggle(plugin)}
|
||||
onUninstall={() => handleUninstall(plugin)}
|
||||
onConfig={() => {
|
||||
if (plugin.status !== 'active') {
|
||||
toast.error('未启用插件,无法配置插件');
|
||||
} else if (plugin.hasConfig) {
|
||||
handleConfig(plugin);
|
||||
} else {
|
||||
toast.error('此插件没有配置哦');
|
||||
}
|
||||
}}
|
||||
hasConfig
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -241,28 +241,28 @@ export default function PluginConfigModal ({ isOpen, onOpenChange, pluginId }: P
|
||||
value={value || ''}
|
||||
onValueChange={(val) => updateConfig(item.key, val)}
|
||||
description={item.description}
|
||||
className="mb-4"
|
||||
className='mb-4'
|
||||
/>
|
||||
);
|
||||
case 'number':
|
||||
return (
|
||||
<Input
|
||||
key={item.key}
|
||||
type="number"
|
||||
type='number'
|
||||
label={item.label}
|
||||
placeholder={item.placeholder || item.description}
|
||||
value={String(value ?? 0)}
|
||||
onValueChange={(val) => updateConfig(item.key, Number(val))}
|
||||
description={item.description}
|
||||
className="mb-4"
|
||||
className='mb-4'
|
||||
/>
|
||||
);
|
||||
case 'boolean':
|
||||
return (
|
||||
<div key={item.key} className="flex justify-between items-center mb-4 p-2 bg-default-100 rounded-lg">
|
||||
<div className="flex flex-col">
|
||||
<span className="text-small">{item.label}</span>
|
||||
{item.description && <span className="text-tiny text-default-500">{item.description}</span>}
|
||||
<div key={item.key} className='flex justify-between items-center mb-4 p-2 bg-default-100 rounded-lg'>
|
||||
<div className='flex flex-col'>
|
||||
<span className='text-small'>{item.label}</span>
|
||||
{item.description && <span className='text-tiny text-default-500'>{item.description}</span>}
|
||||
</div>
|
||||
<Switch
|
||||
isSelected={!!value}
|
||||
@@ -285,7 +285,7 @@ export default function PluginConfigModal ({ isOpen, onOpenChange, pluginId }: P
|
||||
updateConfig(item.key, opt ? opt.value : val);
|
||||
}}
|
||||
description={item.description}
|
||||
className="mb-4"
|
||||
className='mb-4'
|
||||
>
|
||||
{options.map((opt) => (
|
||||
<SelectItem key={String(opt.value)} textValue={opt.label}>
|
||||
@@ -303,7 +303,7 @@ export default function PluginConfigModal ({ isOpen, onOpenChange, pluginId }: P
|
||||
key={item.key}
|
||||
label={item.label}
|
||||
placeholder={item.placeholder || 'Select options'}
|
||||
selectionMode="multiple"
|
||||
selectionMode='multiple'
|
||||
selectedKeys={new Set(selectedKeys)}
|
||||
onSelectionChange={(keys) => {
|
||||
const selected = Array.from(keys).map(k => {
|
||||
@@ -313,7 +313,7 @@ export default function PluginConfigModal ({ isOpen, onOpenChange, pluginId }: P
|
||||
updateConfig(item.key, selected);
|
||||
}}
|
||||
description={item.description}
|
||||
className="mb-4"
|
||||
className='mb-4'
|
||||
>
|
||||
{options.map((opt) => (
|
||||
<SelectItem key={String(opt.value)} textValue={opt.label}>
|
||||
@@ -325,18 +325,18 @@ export default function PluginConfigModal ({ isOpen, onOpenChange, pluginId }: P
|
||||
}
|
||||
case 'html':
|
||||
return (
|
||||
<div key={item.key} className="mb-4">
|
||||
{item.label && <h4 className="text-small font-bold mb-1">{item.label}</h4>}
|
||||
<div dangerouslySetInnerHTML={{ __html: item.default || '' }} className="prose dark:prose-invert max-w-none" />
|
||||
{item.description && <p className="text-tiny text-default-500 mt-1">{item.description}</p>}
|
||||
<div key={item.key} className='mb-4'>
|
||||
{item.label && <h4 className='text-small font-bold mb-1'>{item.label}</h4>}
|
||||
<div dangerouslySetInnerHTML={{ __html: item.default || '' }} className='prose dark:prose-invert max-w-none' />
|
||||
{item.description && <p className='text-tiny text-default-500 mt-1'>{item.description}</p>}
|
||||
</div>
|
||||
);
|
||||
case 'text':
|
||||
return (
|
||||
<div key={item.key} className="mb-4">
|
||||
{item.label && <h4 className="text-small font-bold mb-1">{item.label}</h4>}
|
||||
<div className="whitespace-pre-wrap text-default-700">{item.default || ''}</div>
|
||||
{item.description && <p className="text-tiny text-default-500 mt-1">{item.description}</p>}
|
||||
<div key={item.key} className='mb-4'>
|
||||
{item.label && <h4 className='text-small font-bold mb-1'>{item.label}</h4>}
|
||||
<div className='whitespace-pre-wrap text-default-700'>{item.default || ''}</div>
|
||||
{item.description && <p className='text-tiny text-default-500 mt-1'>{item.description}</p>}
|
||||
</div>
|
||||
);
|
||||
default:
|
||||
@@ -345,12 +345,12 @@ export default function PluginConfigModal ({ isOpen, onOpenChange, pluginId }: P
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal isOpen={isOpen} onOpenChange={onOpenChange} size="2xl" scrollBehavior="inside">
|
||||
<Modal isOpen={isOpen} onOpenChange={onOpenChange} size='2xl' scrollBehavior='inside'>
|
||||
<ModalContent>
|
||||
{(onClose) => (
|
||||
<>
|
||||
<ModalHeader className="flex flex-col gap-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<ModalHeader className='flex flex-col gap-1'>
|
||||
<div className='flex items-center gap-2'>
|
||||
插件配置: {pluginId}
|
||||
{supportReactive && (
|
||||
<span className={`text-tiny px-2 py-0.5 rounded ${connected ? 'bg-success-100 text-success-600' : 'bg-warning-100 text-warning-600'}`}>
|
||||
@@ -360,23 +360,27 @@ export default function PluginConfigModal ({ isOpen, onOpenChange, pluginId }: P
|
||||
</div>
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
{loading ? (
|
||||
<div className="flex justify-center p-8">Loading configuration...</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
{schema.length === 0 ? (
|
||||
<div className="text-center text-default-500">No configuration schema available.</div>
|
||||
) : (
|
||||
schema.filter(item => !item.hidden).map(renderField)
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{loading
|
||||
? (
|
||||
<div className='flex justify-center p-8'>Loading configuration...</div>
|
||||
)
|
||||
: (
|
||||
<div className='flex flex-col gap-2'>
|
||||
{schema.length === 0
|
||||
? (
|
||||
<div className='text-center text-default-500'>No configuration schema available.</div>
|
||||
)
|
||||
: (
|
||||
schema.filter(item => !item.hidden).map(renderField)
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="danger" variant="light" onPress={onClose}>
|
||||
<Button color='danger' variant='light' onPress={onClose}>
|
||||
关闭
|
||||
</Button>
|
||||
<Button color="primary" onPress={handleSave} isLoading={saving}>
|
||||
<Button color='primary' onPress={handleSave} isLoading={saving}>
|
||||
保存
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
@@ -386,4 +390,3 @@ export default function PluginConfigModal ({ isOpen, onOpenChange, pluginId }: P
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,8 @@ export default function TerminalPage () {
|
||||
<TabList className={clsx(
|
||||
'flex-1 !overflow-x-auto w-full hide-scrollbar backdrop-blur-sm p-1 rounded-lg border border-white/20',
|
||||
hasBackground ? 'bg-white/20 dark:bg-black/10' : 'bg-white/40 dark:bg-black/20'
|
||||
)}>
|
||||
)}
|
||||
>
|
||||
<SortableContext
|
||||
items={tabs}
|
||||
strategy={horizontalListSortingStrategy}
|
||||
|
||||
@@ -321,7 +321,7 @@ export default function QQLoginPage () {
|
||||
</div>
|
||||
</div>
|
||||
<div className='absolute right-4 top-4 flex items-center gap-2'>
|
||||
<Button isIconOnly variant="light" aria-label="Settings" onPress={() => setShowGUIDManager(true)}>
|
||||
<Button isIconOnly variant='light' aria-label='Settings' onPress={() => setShowGUIDManager(true)}>
|
||||
<MdSettings size={22} />
|
||||
</Button>
|
||||
<ThemeSwitch />
|
||||
|
||||
@@ -155,7 +155,7 @@ export default function WebLoginPage () {
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 20, scale: 0.95 }}
|
||||
animate={{ opacity: 1, y: 0, scale: 1 }}
|
||||
transition={{ duration: 0.5, type: "spring", stiffness: 120, damping: 20 }}
|
||||
transition={{ duration: 0.5, type: 'spring', stiffness: 120, damping: 20 }}
|
||||
className='w-[608px] max-w-full py-8 px-2 md:px-8 overflow-hidden'
|
||||
>
|
||||
<HoverEffectCard
|
||||
|
||||
Reference in new issue
Block a user