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:
手瓜一十雪 committed 2026-03-05 18:45:50 +08:00
1 parent d2d0b258bc
commit 974528fe7e
186 files changed
+1367 -1233

No files matched your search

@@ -1,6 +1,6 @@
import { Input } from "@heroui/input";
import { Popover, PopoverContent, PopoverTrigger } from "@heroui/popover";
import React, { useCallback, useEffect, useRef, useState, memo } from "react";
import { Input } from '@heroui/input';
import { Popover, PopoverContent, PopoverTrigger } from '@heroui/popover';
import React, { useCallback, useEffect, useRef, useState, memo } from 'react';
interface ColorPickerProps {
color: string;
@@ -18,25 +18,25 @@ const parseHsl = (hslStr: string) => {
// 转换 HEX 到 HSL
const hexToHsl = (hex: string) => {
let r = 0, g = 0, b = 0;
let r = 0; let g = 0; let b = 0;
if (hex.length === 4) {
r = parseInt("0x" + hex[1] + hex[1]);
g = parseInt("0x" + hex[2] + hex[2]);
b = parseInt("0x" + hex[3] + hex[3]);
r = parseInt('0x' + hex[1] + hex[1]);
g = parseInt('0x' + hex[2] + hex[2]);
b = parseInt('0x' + hex[3] + hex[3]);
} else if (hex.length === 7) {
r = parseInt("0x" + hex[1] + hex[2]);
g = parseInt("0x" + hex[3] + hex[4]);
b = parseInt("0x" + hex[5] + hex[6]);
r = parseInt('0x' + hex[1] + hex[2]);
g = parseInt('0x' + hex[3] + hex[4]);
b = parseInt('0x' + hex[5] + hex[6]);
}
r /= 255;
g /= 255;
b /= 255;
const cmin = Math.min(r, g, b),
cmax = Math.max(r, g, b),
delta = cmax - cmin;
let h = 0,
s = 0,
l = 0;
const cmin = Math.min(r, g, b);
const cmax = Math.max(r, g, b);
const delta = cmax - cmin;
let h = 0;
let s = 0;
let l = 0;
if (delta === 0) h = 0;
else if (cmax === r) h = ((g - b) / delta) % 6;
@@ -61,19 +61,19 @@ const hslToHex = (h: number, s: number, l: number) => {
const c = (1 - Math.abs(2 * l - 1)) * s;
const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
const m = l - c / 2;
let r = 0, g = 0, b = 0;
let r = 0; let g = 0; let b = 0;
if (0 <= h && h < 60) {
if (h >= 0 && h < 60) {
r = c; g = x; b = 0;
} else if (60 <= h && h < 120) {
} else if (h >= 60 && h < 120) {
r = x; g = c; b = 0;
} else if (120 <= h && h < 180) {
} else if (h >= 120 && h < 180) {
r = 0; g = c; b = x;
} else if (180 <= h && h < 240) {
} else if (h >= 180 && h < 240) {
r = 0; g = x; b = c;
} else if (240 <= h && h < 300) {
} else if (h >= 240 && h < 300) {
r = x; g = 0; b = c;
} else if (300 <= h && h < 360) {
} else if (h >= 300 && h < 360) {
r = c; g = 0; b = x;
}
r = Math.round((r + m) * 255);
@@ -82,9 +82,9 @@ const hslToHex = (h: number, s: number, l: number) => {
const toHex = (n: number) => {
const hex = n.toString(16);
return hex.length === 1 ? "0" + hex : hex;
return hex.length === 1 ? '0' + hex : hex;
};
return "#" + toHex(r) + toHex(g) + toHex(b);
return '#' + toHex(r) + toHex(g) + toHex(b);
};
interface PanelProps {
@@ -109,7 +109,7 @@ const SatLightPanel = memo(({ hsl, onChange }: PanelProps) => {
const s_hsv = x;
const v_hsv = 1 - y;
let l_hsl = v_hsv * (1 - s_hsv / 2);
const l_hsl = v_hsv * (1 - s_hsv / 2);
let s_hsl = 0;
if (l_hsl === 0 || l_hsl === 1) {
s_hsl = 0;
@@ -157,16 +157,16 @@ const SatLightPanel = memo(({ hsl, onChange }: PanelProps) => {
};
if (isDragging) {
window.addEventListener("mousemove", handleMouseMove);
window.addEventListener("mouseup", handleEnd);
window.addEventListener("touchmove", handleTouchMove, { passive: false });
window.addEventListener("touchend", handleEnd);
window.addEventListener('mousemove', handleMouseMove);
window.addEventListener('mouseup', handleEnd);
window.addEventListener('touchmove', handleTouchMove, { passive: false });
window.addEventListener('touchend', handleEnd);
}
return () => {
window.removeEventListener("mousemove", handleMouseMove);
window.removeEventListener("mouseup", handleEnd);
window.removeEventListener("touchmove", handleTouchMove);
window.removeEventListener("touchend", handleEnd);
window.removeEventListener('mousemove', handleMouseMove);
window.removeEventListener('mouseup', handleEnd);
window.removeEventListener('touchmove', handleTouchMove);
window.removeEventListener('touchend', handleEnd);
};
}, [isDragging, updateColor]);
@@ -181,27 +181,27 @@ const SatLightPanel = memo(({ hsl, onChange }: PanelProps) => {
return (
<div
ref={panelRef}
className="w-full h-40 rounded-lg relative cursor-crosshair overflow-hidden shadow-inner touch-none"
className='w-full h-40 rounded-lg relative cursor-crosshair overflow-hidden shadow-inner touch-none'
style={{
backgroundColor: "hsl(" + hsl.h + ", 100%, 50%)",
backgroundImage: "linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)"
backgroundColor: 'hsl(' + hsl.h + ', 100%, 50%)',
backgroundImage: 'linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)',
}}
onMouseDown={handleMouseDown}
onTouchStart={handleTouchStart}
>
<div
className="w-4 h-4 rounded-full border-2 border-white shadow-md absolute transform -translate-x-1/2 -translate-y-1/2 pointer-events-none"
className='w-4 h-4 rounded-full border-2 border-white shadow-md absolute transform -translate-x-1/2 -translate-y-1/2 pointer-events-none'
style={{
left: markerX + "%",
top: markerY + "%",
backgroundColor: "hsl(" + hsl.h + ", " + hsl.s + "%, " + hsl.l + "%)"
left: markerX + '%',
top: markerY + '%',
backgroundColor: 'hsl(' + hsl.h + ', ' + hsl.s + '%, ' + hsl.l + '%)',
}}
/>
</div>
);
});
SatLightPanel.displayName = "SatLightPanel";
SatLightPanel.displayName = 'SatLightPanel';
const HueSlider = memo(({ hsl, onChange }: PanelProps) => {
const sliderRef = useRef<HTMLDivElement>(null);
@@ -255,38 +255,38 @@ const HueSlider = memo(({ hsl, onChange }: PanelProps) => {
};
if (isDragging) {
window.addEventListener("mousemove", handleMouseMove);
window.addEventListener("mouseup", handleEnd);
window.addEventListener("touchmove", handleTouchMove, { passive: false });
window.addEventListener("touchend", handleEnd);
window.addEventListener('mousemove', handleMouseMove);
window.addEventListener('mouseup', handleEnd);
window.addEventListener('touchmove', handleTouchMove, { passive: false });
window.addEventListener('touchend', handleEnd);
}
return () => {
window.removeEventListener("mousemove", handleMouseMove);
window.removeEventListener("mouseup", handleEnd);
window.removeEventListener("touchmove", handleTouchMove);
window.removeEventListener("touchend", handleEnd);
window.removeEventListener('mousemove', handleMouseMove);
window.removeEventListener('mouseup', handleEnd);
window.removeEventListener('touchmove', handleTouchMove);
window.removeEventListener('touchend', handleEnd);
};
}, [isDragging, updateHue]);
return (
<div
ref={sliderRef}
className="w-full h-4 rounded-full relative cursor-pointer mt-3 shadow-inner touch-none"
className='w-full h-4 rounded-full relative cursor-pointer mt-3 shadow-inner touch-none'
style={{
background: "linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)"
background: 'linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)',
}}
onMouseDown={handleMouseDown}
onTouchStart={handleTouchStart}
>
<div
className="w-4 h-4 rounded-full border-2 border-white shadow-md absolute top-0 transform -translate-x-1/2 pointer-events-none bg-white"
style={{ left: (hsl.h / 360) * 100 + "%" }}
className='w-4 h-4 rounded-full border-2 border-white shadow-md absolute top-0 transform -translate-x-1/2 pointer-events-none bg-white'
style={{ left: (hsl.h / 360) * 100 + '%' }}
/>
</div>
);
});
HueSlider.displayName = "HueSlider";
HueSlider.displayName = 'HueSlider';
const ColorPicker: React.FC<ColorPickerProps> = ({ color, onChange }) => {
const [hsl, setHsl] = useState(parseHsl(color));
@@ -305,7 +305,7 @@ const ColorPicker: React.FC<ColorPickerProps> = ({ color, onChange }) => {
const handleHslChange = useCallback((newHsl: { h: number, s: number, l: number; }) => {
setHsl(newHsl);
setHex(hslToHex(newHsl.h, newHsl.s, newHsl.l));
onChange("hsl(" + Math.round(newHsl.h) + ", " + Math.round(newHsl.s) + "%, " + Math.round(newHsl.l) + "%)");
onChange('hsl(' + Math.round(newHsl.h) + ', ' + Math.round(newHsl.s) + '%, ' + Math.round(newHsl.l) + '%)');
}, [onChange]);
const handleHexChange = (value: string) => {
@@ -317,30 +317,31 @@ const ColorPicker: React.FC<ColorPickerProps> = ({ color, onChange }) => {
};
return (
<Popover triggerScaleOnOpen={false} placement="bottom">
<Popover triggerScaleOnOpen={false} placement='bottom'>
<PopoverTrigger>
<div className="flex items-center gap-2 cursor-pointer group">
<div className='flex items-center gap-2 cursor-pointer group'>
<div
className="w-10 h-10 rounded-lg shadow-sm border-2 border-default-200 transition-transform group-hover:scale-105"
className='w-10 h-10 rounded-lg shadow-sm border-2 border-default-200 transition-transform group-hover:scale-105'
style={{ background: color }}
/>
<div className="flex flex-col">
<span className="text-xs font-mono text-default-500">{hex}</span>
<span className="text-xs font-mono text-default-400">HSL({Math.round(hsl.h)}, {Math.round(hsl.s)}%, {Math.round(hsl.l)}%)</span>
<div className='flex flex-col'>
<span className='text-xs font-mono text-default-500'>{hex}</span>
<span className='text-xs font-mono text-default-400'>HSL({Math.round(hsl.h)}, {Math.round(hsl.s)}%, {Math.round(hsl.l)}%)</span>
</div>
</div>
</PopoverTrigger>
<PopoverContent className="w-72 p-4 bg-background/80 backdrop-blur-xl border border-default-200 shadow-2xl rounded-2xl"
<PopoverContent
className='w-72 p-4 bg-background/80 backdrop-blur-xl border border-default-200 shadow-2xl rounded-2xl'
onMouseDownCapture={() => { isDraggingRef.current = true; }}
onMouseUpCapture={() => { isDraggingRef.current = false; }}
onTouchStartCapture={() => { isDraggingRef.current = true; }}
onTouchEndCapture={() => { isDraggingRef.current = false; }}
>
<div className="flex flex-col w-full gap-2">
<div className="flex justify-between items-center mb-2">
<span className="text-sm font-bold text-default-700">选择颜色</span>
<div className='flex flex-col w-full gap-2'>
<div className='flex justify-between items-center mb-2'>
<span className='text-sm font-bold text-default-700'>选择颜色</span>
<div
className="w-6 h-6 rounded-full border border-default-200 shadow-sm"
className='w-6 h-6 rounded-full border border-default-200 shadow-sm'
style={{ background: color }}
/>
</div>
@@ -348,53 +349,53 @@ const ColorPicker: React.FC<ColorPickerProps> = ({ color, onChange }) => {
<SatLightPanel hsl={hsl} onChange={handleHslChange} />
<HueSlider hsl={hsl} onChange={handleHslChange} />
<div className="grid grid-cols-4 gap-2 mt-2 items-center">
<span className="text-xs text-default-500 col-span-1">HEX</span>
<div className='grid grid-cols-4 gap-2 mt-2 items-center'>
<span className='text-xs text-default-500 col-span-1'>HEX</span>
<Input
size="sm"
variant="flat"
size='sm'
variant='flat'
value={hex}
onChange={(e) => handleHexChange(e.target.value)}
className="col-span-3 font-mono"
className='col-span-3 font-mono'
classNames={{
input: "text-xs uppercase",
inputWrapper: "h-8 min-h-8"
input: 'text-xs uppercase',
inputWrapper: 'h-8 min-h-8',
}}
/>
</div>
<div className="grid grid-cols-4 gap-2 items-center">
<span className="text-xs text-default-500 col-span-1">HSL</span>
<div className="col-span-3 flex gap-1">
<div className='grid grid-cols-4 gap-2 items-center'>
<span className='text-xs text-default-500 col-span-1'>HSL</span>
<div className='col-span-3 flex gap-1'>
<Input
size="sm" variant="flat" type="number"
size='sm' variant='flat' type='number'
value={Math.round(hsl.h).toString()}
onChange={(e) => handleHslChange({ ...hsl, h: Number(e.target.value) })}
endContent={<span className="text-xs text-default-400">H</span>}
classNames={{ input: "text-xs", inputWrapper: "h-8 min-h-8 px-1" }}
endContent={<span className='text-xs text-default-400'>H</span>}
classNames={{ input: 'text-xs', inputWrapper: 'h-8 min-h-8 px-1' }}
/>
<Input
size="sm" variant="flat" type="number"
size='sm' variant='flat' type='number'
value={Math.round(hsl.s).toString()}
onChange={(e) => handleHslChange({ ...hsl, s: Number(e.target.value) })}
endContent={<span className="text-xs text-default-400">S</span>}
classNames={{ input: "text-xs", inputWrapper: "h-8 min-h-8 px-1" }}
endContent={<span className='text-xs text-default-400'>S</span>}
classNames={{ input: 'text-xs', inputWrapper: 'h-8 min-h-8 px-1' }}
/>
<Input
size="sm" variant="flat" type="number"
size='sm' variant='flat' type='number'
value={Math.round(hsl.l).toString()}
onChange={(e) => handleHslChange({ ...hsl, l: Number(e.target.value) })}
endContent={<span className="text-xs text-default-400">L</span>}
classNames={{ input: "text-xs", inputWrapper: "h-8 min-h-8 px-1" }}
endContent={<span className='text-xs text-default-400'>L</span>}
classNames={{ input: 'text-xs', inputWrapper: 'h-8 min-h-8 px-1' }}
/>
</div>
</div>
<div className="flex gap-1 mt-2 flex-wrap justify-between">
{["#006FEE", "#17C964", "#F5A524", "#F31260", "#7828C8", "#000000", "#FFFFFF"].map((c) => (
<div className='flex gap-1 mt-2 flex-wrap justify-between'>
{['#006FEE', '#17C964', '#F5A524', '#F31260', '#7828C8', '#000000', '#FFFFFF'].map((c) => (
<button
key={c}
className="w-6 h-6 rounded-full border border-default-200 shadow-sm transition-transform hover:scale-110 active:scale-95"
className='w-6 h-6 rounded-full border border-default-200 shadow-sm transition-transform hover:scale-110 active:scale-95'
style={{ backgroundColor: c }}
onClick={() => handleHexChange(c)}
/>
@@ -406,4 +407,4 @@ const ColorPicker: React.FC<ColorPickerProps> = ({ color, onChange }) => {
);
};
export default ColorPicker;
export default ColorPicker;
@@ -33,7 +33,7 @@ const AddButton: React.FC<AddButtonProps> = (props) => {
>
<DropdownTrigger>
<Button
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'
startContent={<IoAddCircleOutline className='text-2xl' />}
>
新建
@@ -26,9 +26,9 @@ const SaveButtons: React.FC<SaveButtonsProps> = ({
>
<div className='flex items-center justify-center gap-2 mt-5'>
<Button
radius="full"
variant="flat"
className="font-medium bg-default-100 text-default-600 dark:bg-default-50/50"
radius='full'
variant='flat'
className='font-medium bg-default-100 text-default-600 dark:bg-default-50/50'
onPress={() => {
reset();
toast.success('重置成功');
@@ -38,8 +38,8 @@ const SaveButtons: React.FC<SaveButtonsProps> = ({
</Button>
<Button
color='primary'
radius="full"
className="font-medium shadow-md shadow-primary/20"
radius='full'
className='font-medium shadow-md shadow-primary/20'
isLoading={isSubmitting}
onPress={() => onSubmit()}
>
@@ -50,7 +50,7 @@ const SaveButtons: React.FC<SaveButtonsProps> = ({
isIconOnly
radius='full'
variant='flat'
className="text-default-500 bg-default-100 dark:bg-default-50/50"
className='text-default-500 bg-default-100 dark:bg-default-50/50'
onPress={() => refresh()}
>
<IoMdRefresh size={20} />
@@ -19,18 +19,20 @@ export default function ChatInputModal ({ children }: ChatInputModalProps) {
return (
<>
{children ? children(onOpen) : (
<Button
onPress={onOpen}
color='primary'
radius='full'
variant='flat'
size='sm'
className="bg-primary/10 text-primary"
>
构造消息
</Button>
)}
{children
? children(onOpen)
: (
<Button
onPress={onOpen}
color='primary'
radius='full'
variant='flat'
size='sm'
className='bg-primary/10 text-primary'
>
构造消息
</Button>
)}
<Modal
size='4xl'
scrollBehavior='inside'
@@ -31,7 +31,7 @@ export interface CodeEditorRef {
const CodeEditor = React.forwardRef<CodeEditorRef, CodeEditorProps>((props, ref) => {
const { isDark } = useTheme();
const chromeless = !!props.options?.chromeless;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [val, setVal] = useState(props.value || props.defaultValue || '');
const internalRef = React.useRef<ReactCodeMirrorRef>(null);
@@ -45,71 +45,71 @@ const CodeEditor = React.forwardRef<CodeEditorRef, CodeEditorProps>((props, ref)
getValue: () => {
// Prefer getting dynamic value from view, fallback to state
return internalRef.current?.view?.state.doc.toString() || val;
}
},
}));
const customTheme = EditorView.theme({
"&": {
fontSize: "14px",
height: "100% !important",
'&': {
fontSize: '14px',
height: '100% !important',
backgroundColor: 'transparent !important',
},
"&.cm-editor": {
'&.cm-editor': {
backgroundColor: 'transparent !important',
},
".cm-scroller": {
'.cm-scroller': {
fontFamily: "var(--font-family-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace)",
lineHeight: "1.6",
overflow: "auto !important",
height: "100% !important",
lineHeight: '1.6',
overflow: 'auto !important',
height: '100% !important',
backgroundColor: 'transparent !important',
},
".cm-gutters": {
backgroundColor: "transparent !important",
borderRight: "none",
'.cm-gutters': {
backgroundColor: 'transparent !important',
borderRight: 'none',
color: isDark
? 'hsl(var(--heroui-foreground-500) / 0.75)'
: 'hsl(var(--heroui-foreground-500) / 0.65)',
},
".cm-gutterElement": {
paddingLeft: "12px",
paddingRight: "12px",
'.cm-gutterElement': {
paddingLeft: '12px',
paddingRight: '12px',
},
".cm-activeLineGutter": {
'.cm-activeLineGutter': {
backgroundColor: 'transparent !important',
color: isDark
? 'hsl(var(--heroui-foreground) / 0.9) !important'
: 'hsl(var(--heroui-foreground) / 0.8) !important',
},
".cm-content": {
'.cm-content': {
color: 'hsl(var(--heroui-foreground) / 0.9)',
caretColor: 'hsl(var(--heroui-foreground) / 0.9)',
paddingTop: "12px",
paddingBottom: "12px",
paddingTop: '12px',
paddingBottom: '12px',
backgroundColor: 'transparent !important',
},
".cm-activeLine": {
'.cm-activeLine': {
backgroundColor: isDark
? 'hsl(var(--heroui-foreground) / 0.08)'
: 'hsl(var(--heroui-foreground) / 0.06)',
},
".cm-selectionMatch": {
'.cm-selectionMatch': {
backgroundColor: isDark
? 'hsl(var(--heroui-foreground) / 0.16)'
: 'hsl(var(--heroui-foreground) / 0.12)',
},
// Syntax highlighting overrides for better readability
".ͼo": {
'.ͼo': {
// JSON property names - use a softer primary color
color: isDark
? 'hsl(var(--heroui-primary) / 0.85)'
: 'hsl(var(--heroui-primary) / 0.75)',
},
".ͼd": {
'.ͼd': {
// Strings - softer green
color: isDark ? '#98c379cc' : '#50a14fcc',
},
".ͼc": {
'.ͼc': {
// Numbers - softer orange
color: isDark ? '#d19a66cc' : '#c18401cc',
},
@@ -137,8 +137,8 @@ const CodeEditor = React.forwardRef<CodeEditorRef, CodeEditorProps>((props, ref)
<CodeMirror
ref={internalRef}
value={props.value ?? props.defaultValue}
height="100%"
className="h-full w-full [&_.cm-editor]:!bg-transparent [&_.cm-scroller]:!bg-transparent"
height='100%'
className='h-full w-full [&_.cm-editor]:!bg-transparent [&_.cm-scroller]:!bg-transparent'
style={{ backgroundColor: 'transparent' }}
theme={isDark ? oneDark : 'light'}
extensions={extensions}
@@ -64,9 +64,9 @@ export default function CommandPalette (props: CommandPaletteProps) {
const list = !q
? commands
: commands.filter((c) => {
const hay = `${c.id} ${c.title} ${c.subtitle ?? ''} ${c.group ?? ''}`.toLowerCase();
return hay.includes(q);
});
const hay = `${c.id} ${c.title} ${c.subtitle ?? ''} ${c.group ?? ''}`.toLowerCase();
return hay.includes(q);
});
// 简单:优先 path 前缀命中
if (!q) return list;
@@ -125,7 +125,8 @@ export default function CommandPalette (props: CommandPaletteProps) {
<ModalHeader className={clsx(
'flex items-center gap-2',
mobile ? 'border-b border-default-200/50' : ''
)}>
)}
>
<span className='text-sm font-semibold'>命令面板</span>
<span className='text-xs text-default-400 font-normal hidden md:inline'>Ctrl/Cmd + K</span>
</ModalHeader>
@@ -149,11 +150,13 @@ export default function CommandPalette (props: CommandPaletteProps) {
<div className={clsx(
'rounded-xl border border-default-200/50 dark:border-default-100/20 overflow-hidden',
mobile ? 'flex-1 min-h-0' : 'max-h-[420px]'
)}>
)}
>
<div className={clsx(
'divide-y divide-default-200/50 dark:divide-default-100/20 overflow-y-auto no-scrollbar',
mobile ? 'h-full' : 'max-h-[420px]'
)}>
)}
>
{filtered.length === 0 && (
<div className='p-6 text-sm text-default-400'>没有匹配的接口</div>
)}
@@ -3,8 +3,6 @@ import { useLocalStorage } from '@uidotdev/usehooks';
import clsx from 'clsx';
import key from '@/const/key';
export interface NetworkItemDisplayProps {
count: number;
label: string;
@@ -63,22 +63,24 @@ export default function FileEditModal ({
};
return (
<Modal radius='sm' size='full' isOpen={isOpen} onClose={onClose} scrollBehavior="inside">
<ModalContent className="flex flex-col h-full max-h-[100dvh]">
<Modal radius='sm' size='full' isOpen={isOpen} onClose={onClose} scrollBehavior='inside'>
<ModalContent className='flex flex-col h-full max-h-[100dvh]'>
<ModalHeader className='flex items-center gap-2 border-b border-default-200/50 flex-shrink-0'>
<span>编辑文件</span>
<Code radius='sm' className='text-xs'>{file?.path}</Code>
<div className="ml-auto text-xs text-default-400 font-normal px-2">
按 <span className="px-1 py-0.5 rounded border border-default-300 bg-default-100">Ctrl/Cmd + S</span> 保存
<div className='ml-auto text-xs text-default-400 font-normal px-2'>
按 <span className='px-1 py-0.5 rounded border border-default-300 bg-default-100'>Ctrl/Cmd + S</span> 保存
</div>
</ModalHeader>
<ModalBody className='p-4 bg-content2/50 flex-1 min-h-0 overflow-hidden'>
<div className='h-full w-full overflow-auto' onKeyDown={(e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
e.preventDefault();
onSave();
}
}}>
<div
className='h-full w-full overflow-auto' onKeyDown={(e) => {
if ((e.ctrlKey || e.metaKey) && e.key === 's') {
e.preventDefault();
onSave();
}
}}
>
<CodeEditor
height='100%'
value={file?.content || ''}
@@ -88,7 +90,7 @@ export default function FileEditModal ({
/>
</div>
</ModalBody>
<ModalFooter className="border-t border-default-200/50 flex-shrink-0">
<ModalFooter className='border-t border-default-200/50 flex-shrink-0'>
<Button radius='sm' color='primary' variant='flat' onPress={onClose}>
取消
</Button>
@@ -363,15 +363,17 @@ const GUIDManager: React.FC<GUIDManagerProps> = ({ showRestart = true, compact =
<div className='flex flex-col gap-2'>
<div className='text-sm font-medium text-default-700'>当前设备 GUID</div>
<div className='flex items-center gap-2'>
{currentLinuxGUID ? (
<Chip variant='flat' color='primary' className='font-mono text-xs max-w-full'>
{currentLinuxGUID}
</Chip>
) : (
<Chip variant='flat' color='warning' className='text-xs'>
未设置 / 不存在
</Chip>
)}
{currentLinuxGUID
? (
<Chip variant='flat' color='primary' className='font-mono text-xs max-w-full'>
{currentLinuxGUID}
</Chip>
)
: (
<Chip variant='flat' color='warning' className='text-xs'>
未设置 / 不存在
</Chip>
)}
{currentLinuxGUID && (
<Button
isIconOnly
@@ -417,15 +419,17 @@ const GUIDManager: React.FC<GUIDManagerProps> = ({ showRestart = true, compact =
<div className='flex flex-col gap-2'>
<div className='text-sm font-medium text-default-700'>当前 MAC 地址</div>
<div className='flex items-center gap-2'>
{currentMAC ? (
<Chip variant='flat' color='secondary' className='font-mono text-xs max-w-full'>
{currentMAC}
</Chip>
) : (
<Chip variant='flat' color='warning' className='text-xs'>
未设置 / 不存在
</Chip>
)}
{currentMAC
? (
<Chip variant='flat' color='secondary' className='font-mono text-xs max-w-full'>
{currentMAC}
</Chip>
)
: (
<Chip variant='flat' color='warning' className='text-xs'>
未设置 / 不存在
</Chip>
)}
{currentMAC && (
<Button
isIconOnly
@@ -571,15 +575,17 @@ const GUIDManager: React.FC<GUIDManagerProps> = ({ showRestart = true, compact =
<div className='flex flex-col gap-2'>
<div className='text-sm font-medium text-default-700'>当前设备 GUID</div>
<div className='flex items-center gap-2'>
{currentGUID ? (
<Chip variant='flat' color='primary' className='font-mono text-xs max-w-full'>
{currentGUID}
</Chip>
) : (
<Chip variant='flat' color='warning' className='text-xs'>
未设置 / 不存在
</Chip>
)}
{currentGUID
? (
<Chip variant='flat' color='primary' className='font-mono text-xs max-w-full'>
{currentGUID}
</Chip>
)
: (
<Chip variant='flat' color='warning' className='text-xs'>
未设置 / 不存在
</Chip>
)}
{currentGUID && (
<Button
isIconOnly
@@ -91,7 +91,8 @@ const HistoryLogs: React.FC<HistoryLogsProps> = (props) => {
<Card className={clsx(
'max-w-full h-full backdrop-blur-sm border border-white/40 dark:border-white/10 shadow-sm',
hasBackground ? 'bg-white/20 dark:bg-black/10' : 'bg-white/60 dark:bg-black/40'
)}>
)}
>
<CardHeader className='flex-row justify-start gap-3'>
<Select
label='选择日志'
@@ -99,7 +99,8 @@ const RealTimeLogs = () => {
<div className={clsx(
'flex items-center gap-2 p-2 rounded-2xl border backdrop-blur-sm transition-all shadow-sm mb-4',
hasBackground ? 'bg-white/20 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'
)}>
)}
>
<LogLevelSelect
selectedKeys={logLevel}
onSelectionChange={setLogLevel}
@@ -96,24 +96,24 @@ export default function MirrorSelectorModal ({
};
return (
<Modal
isOpen={isOpen}
onClose={onClose}
size="2xl"
scrollBehavior="inside"
<Modal
isOpen={isOpen}
onClose={onClose}
size='2xl'
scrollBehavior='inside'
classNames={{
backdrop: 'z-[200]',
wrapper: 'z-[200]',
}}
>
<ModalContent>
<ModalHeader className="flex flex-col gap-1">
<div className="flex items-center justify-between pr-8">
<ModalHeader className='flex flex-col gap-1'>
<div className='flex items-center justify-between pr-8'>
<span>选择镜像源</span>
<Button
size="sm"
color="primary"
variant="flat"
size='sm'
color='primary'
variant='flat'
startContent={!isTesting && <IoMdFlash />}
onPress={startSpeedTest}
isLoading={isTesting}
@@ -122,34 +122,34 @@ export default function MirrorSelectorModal ({
</Button>
</div>
{isTesting && (
<div className="mt-2">
<div className="w-full bg-default-200 rounded-full h-2">
<div className='mt-2'>
<div className='w-full bg-default-200 rounded-full h-2'>
<div
className="bg-primary h-2 rounded-full transition-all duration-300"
className='bg-primary h-2 rounded-full transition-all duration-300'
style={{ width: `${testProgress}%` }}
/>
</div>
<p className="text-xs text-default-500 mt-1">{testMessage}</p>
<p className='text-xs text-default-500 mt-1'>{testMessage}</p>
</div>
)}
</ModalHeader>
<ModalBody>
<div className="flex flex-col gap-2">
<div className='flex flex-col gap-2'>
{/* 自动选择选项 */}
<MirrorOption
value="auto"
label="自动选择"
description="系统自动选择最快的镜像源"
value='auto'
label='自动选择'
description='系统自动选择最快的镜像源'
isSelected={selectedMirror === 'auto'}
onSelect={() => setSelectedMirror('auto')}
badge={<Chip size="sm" color="primary" variant="flat">推荐</Chip>}
badge={<Chip size='sm' color='primary' variant='flat'>推荐</Chip>}
/>
{/* 原始 GitHub */}
<MirrorOption
value="https://github.com"
label="GitHub 原始"
description="直连 GitHub(可能较慢)"
value='https://github.com'
label='GitHub 原始'
description='直连 GitHub(可能较慢)'
isSelected={selectedMirror === 'https://github.com'}
onSelect={() => setSelectedMirror('https://github.com')}
testResult={testResults.get('https://github.com (原始)')}
@@ -183,10 +183,10 @@ export default function MirrorSelectorModal ({
</div>
</ModalBody>
<ModalFooter>
<Button variant="light" onPress={onClose}>
<Button variant='light' onPress={onClose}>
取消
</Button>
<Button color="primary" onPress={handleConfirm}>
<Button color='primary' onPress={handleConfirm}>
确认选择
</Button>
</ModalFooter>
@@ -226,14 +226,14 @@ function MirrorOption ({
)}
onClick={onSelect}
>
<div className="flex-1 min-w-0">
<p className="font-medium">{label}</p>
<p className="text-xs text-default-500 truncate">{description}</p>
<div className='flex-1 min-w-0'>
<p className='font-medium'>{label}</p>
<p className='text-xs text-default-500 truncate'>{description}</p>
</div>
<div className="flex items-center gap-2 ml-2">
<div className='flex items-center gap-2 ml-2'>
{badge}
{isFastest && !badge && (
<Chip size="sm" color="success" variant="flat">最快</Chip>
<Chip size='sm' color='success' variant='flat'>最快</Chip>
)}
{testResult && <MirrorStatus result={testResult} />}
</div>
@@ -253,9 +253,9 @@ function MirrorStatus ({ result }: { result: MirrorTestResult; }) {
return (
<Tooltip content={result.error || '连接失败'}>
<Chip
size="sm"
color="danger"
variant="flat"
size='sm'
color='danger'
variant='flat'
startContent={<IoMdClose size={14} />}
>
失败
@@ -272,9 +272,9 @@ function MirrorStatus ({ result }: { result: MirrorTestResult; }) {
return (
<Chip
size="sm"
size='sm'
color={getColor()}
variant="flat"
variant='flat'
startContent={<IoMdCheckmark size={14} />}
>
{formatLatency(result.latency)}
@@ -114,22 +114,26 @@ const NewDeviceVerify: React.FC<NewDeviceVerifyProps> = ({
</p>
<div className='flex flex-col items-center gap-3' style={{ minHeight: 280 }}>
{status === 'loading' ? (
<div className='flex items-center justify-center' style={{ height: 240 }}>
<Spinner size='lg' />
</div>
) : status === 'error' ? (
<div className='flex flex-col items-center justify-center gap-3' style={{ height: 240 }}>
<p className='text-danger text-sm'>{errorMsg}</p>
<Button color='primary' variant='flat' onPress={fetchQRCode}>
重新获取
</Button>
</div>
) : (
<div className='p-3 bg-white rounded-lg'>
<QRCodeSVG value={qrUrl} size={220} />
</div>
)}
{status === 'loading'
? (
<div className='flex items-center justify-center' style={{ height: 240 }}>
<Spinner size='lg' />
</div>
)
: status === 'error'
? (
<div className='flex flex-col items-center justify-center gap-3' style={{ height: 240 }}>
<p className='text-danger text-sm'>{errorMsg}</p>
<Button color='primary' variant='flat' onPress={fetchQRCode}>
重新获取
</Button>
</div>
)
: (
<div className='p-3 bg-white rounded-lg'>
<QRCodeSVG value={qrUrl} size={220} />
</div>
)}
<p className={`text-sm ${statusColor[status]}`}>
{statusText[status]}
@@ -75,7 +75,7 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
try {
const wrappedResponseSchema = Type.Object({
...BaseResponseSchema.properties,
data: data?.response || Type.Any({ description: '数据' })
data: data?.response || Type.Any({ description: '数据' }),
});
return parseTypeBox(wrappedResponseSchema);
} catch (e) {
@@ -99,11 +99,11 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
if (adapterName) {
request.post(`/api/Debug/call/${adapterName}`, {
action: path,
params: parsedRequestBody
params: parsedRequestBody,
}, {
headers: {
Authorization: `Bearer ${localStorage.getItem('token')}`
}
Authorization: `Bearer ${localStorage.getItem('token')}`,
},
}).then((res) => {
if (res.data.code === 0) {
setResponseContent(JSON.stringify(res.data.data, null, 2));
@@ -173,7 +173,7 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
},
focusRequestEditor: () => {
setActiveTab('request');
}
},
}));
useEffect(() => {
@@ -251,7 +251,6 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
document.addEventListener('touchend', handleTouchEnd);
}, [responseHeight, setStoredHeight]);
return (
<div className='flex flex-col h-full w-full relative overflow-hidden'>
@@ -259,15 +258,17 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
<div className={clsx(
'flex items-center gap-4 px-4 py-2 border-b flex-shrink-0 z-10',
hasBackground ? 'border-white/10 bg-white/5' : 'border-black/5 dark:border-white/10 bg-white/40 dark:bg-black/20'
)}>
)}
>
{/* Method & Path */}
{/* Method & Path */}
{/* Method & Path */}
<div className="flex items-center gap-3 flex-1 min-w-0 pl-1">
<div className='flex items-center gap-3 flex-1 min-w-0 pl-1'>
<div className={clsx(
'text-sm font-mono truncate select-all px-2 py-1 rounded-md transition-colors',
hasBackground ? 'text-white/90 bg-black/10' : 'text-foreground dark:text-white/90 bg-default-100/50'
)}>
)}
>
{path}
</div>
</div>
@@ -277,14 +278,14 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
<Popover placement='bottom-end' backdrop='transparent'>
<PopoverTrigger>
<Button size='sm' variant='light' radius='sm' isIconOnly className='opacity-60 hover:opacity-100'>
<IoSettingsSharp className="text-lg" />
<IoSettingsSharp className='text-lg' />
</Button>
</PopoverTrigger>
<PopoverContent className='w-[260px] p-3 rounded-md border border-white/10 shadow-2xl bg-white/80 dark:bg-black/80 backdrop-blur-xl'>
<div className='flex flex-col gap-2'>
<p className='text-[10px] font-bold opacity-30 uppercase tracking-widest'>Debug Setup</p>
<Input label='Base URL' labelPlacement="outside" placeholder="http://..." value={httpConfig.url} onChange={(e) => setHttpConfig({ ...httpConfig, url: e.target.value })} size='sm' variant='bordered' />
<Input label='Token' labelPlacement="outside" placeholder="access_token" value={httpConfig.token} onChange={(e) => setHttpConfig({ ...httpConfig, token: e.target.value })} size='sm' variant='bordered' />
<Input label='Base URL' labelPlacement='outside' placeholder='http://...' value={httpConfig.url} onChange={(e) => setHttpConfig({ ...httpConfig, url: e.target.value })} size='sm' variant='bordered' />
<Input label='Token' labelPlacement='outside' placeholder='access_token' value={httpConfig.token} onChange={(e) => setHttpConfig({ ...httpConfig, token: e.target.value })} size='sm' variant='bordered' />
</div>
</PopoverContent>
</Popover>
@@ -296,7 +297,7 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
size='sm'
className='font-bold shadow-sm px-4'
isLoading={isFetching}
startContent={!isFetching && <IoSend className="text-xs" />}
startContent={!isFetching && <IoSend className='text-xs' />}
>
发送
</Button>
@@ -310,43 +311,46 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
<div className={clsx(
'px-4 flex items-center justify-between h-10 flex-shrink-0 border-b',
hasBackground ? 'border-white/10' : 'border-default-100 dark:border-white/10'
)}>
)}
>
<Tabs
aria-label="Request Options"
size="sm"
variant="underlined"
aria-label='Request Options'
size='sm'
variant='underlined'
selectedKey={activeTab}
onSelectionChange={setActiveTab}
classNames={{
tabList: 'p-0 gap-6 bg-transparent',
cursor: 'w-full bg-foreground dark:bg-white h-[2px]',
tab: 'px-0 h-full',
tabContent: 'text-xs font-medium text-default-500 dark:text-white/50 group-data-[selected=true]:text-foreground dark:group-data-[selected=true]:text-white'
tabContent: 'text-xs font-medium text-default-500 dark:text-white/50 group-data-[selected=true]:text-foreground dark:group-data-[selected=true]:text-white',
}}
>
<Tab key="request" title="请求体" />
<Tab key="docs" title="接口文档" />
<Tab key='request' title='请求体' />
<Tab key='docs' title='接口文档' />
</Tabs>
<div className='flex items-center gap-1 opacity-70'>
<ChatInputModal>
{(onOpen) => (
<Tooltip content="构造 CQ 码" closeDelay={0}>
<Tooltip content='构造 CQ 码' closeDelay={0}>
<Button isIconOnly size='sm' variant='light' radius='sm' className='w-8 h-8' onPress={onOpen}>
<TbMessageCode size={16} />
</Button>
</Tooltip>
)}
</ChatInputModal>
<Tooltip content="生成示例" closeDelay={0}>
<Button isIconOnly size='sm' variant='light' radius='sm' className='w-8 h-8' onPress={() => {
try {
setRequestBody(JSON.stringify(generateDefaultFromTypeBox(data?.payload), null, 2));
} catch (e) {
console.error('Error generating default:', e);
toast.error('生成示例失败');
}
}}>
<Tooltip content='生成示例' closeDelay={0}>
<Button
isIconOnly size='sm' variant='light' radius='sm' className='w-8 h-8' onPress={() => {
try {
setRequestBody(JSON.stringify(generateDefaultFromTypeBox(data?.payload), null, 2));
} catch (e) {
console.error('Error generating default:', e);
toast.error('生成示例失败');
}
}}
>
<TbCode size={16} />
</Button>
</Tooltip>
@@ -355,38 +359,40 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
{/* Content Area */}
<div className='flex-1 relative overflow-hidden'>
{activeTab === 'request' ? (
<div className="absolute inset-0">
<CodeEditor
value={requestBody}
onChange={(value) => setRequestBody(value ?? '')}
language='json'
options={{
minimap: { enabled: false },
fontSize: 13,
fontFamily: 'JetBrains Mono, monospace',
scrollBeyondLastLine: false,
wordWrap: 'on',
padding: { top: 16, bottom: 16 },
lineNumbersMinChars: 3,
chromeless: true,
backgroundColor: 'transparent'
}}
/>
</div>
) : (
<div className='p-6 space-y-8 overflow-y-auto h-full scrollbar-hide'>
<section>
<h3 className='text-[10px] font-bold text-default-700 dark:text-default-50 uppercase tracking-widest mb-4'>Request Params</h3>
<DisplayStruct schema={parsedRequest} />
</section>
<div className='h-px bg-white/10 w-full' />
<section>
<h3 className='text-[10px] font-bold text-default-700 dark:text-default-50 uppercase tracking-widest mb-4'>Response Data</h3>
<DisplayStruct schema={parsedResponse} />
</section>
</div>
)}
{activeTab === 'request'
? (
<div className='absolute inset-0'>
<CodeEditor
value={requestBody}
onChange={(value) => setRequestBody(value ?? '')}
language='json'
options={{
minimap: { enabled: false },
fontSize: 13,
fontFamily: 'JetBrains Mono, monospace',
scrollBeyondLastLine: false,
wordWrap: 'on',
padding: { top: 16, bottom: 16 },
lineNumbersMinChars: 3,
chromeless: true,
backgroundColor: 'transparent',
}}
/>
</div>
)
: (
<div className='p-6 space-y-8 overflow-y-auto h-full scrollbar-hide'>
<section>
<h3 className='text-[10px] font-bold text-default-700 dark:text-default-50 uppercase tracking-widest mb-4'>Request Params</h3>
<DisplayStruct schema={parsedRequest} />
</section>
<div className='h-px bg-white/10 w-full' />
<section>
<h3 className='text-[10px] font-bold text-default-700 dark:text-default-50 uppercase tracking-widest mb-4'>Response Data</h3>
<DisplayStruct schema={parsedResponse} />
</section>
</div>
)}
</div>
</div>
</div>
@@ -407,7 +413,7 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
{/* Invisible Draggable Area */}
{responseExpanded && (
<div
className="absolute -top-1.5 left-0 w-full h-4 cursor-ns-resize z-20"
className='absolute -top-1.5 left-0 w-full h-4 cursor-ns-resize z-20'
onMouseDown={(e) => { e.stopPropagation(); handleMouseDown(e); }}
onTouchStart={(e) => { e.stopPropagation(); handleTouchStart(e); }}
onClick={(e) => e.stopPropagation()}
@@ -416,14 +422,16 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
<div className='flex items-center gap-2'>
<div className={clsx('transition-transform duration-200', !responseExpanded && '-rotate-90')}>
<IoChevronDown size={14} className="opacity-50" />
<IoChevronDown size={14} className='opacity-50' />
</div>
<span className={clsx(
'text-[10px] font-bold tracking-widest uppercase',
hasBackground ? 'text-white' : 'text-foreground dark:text-white'
)}>Response</span>
)}
>Response
</span>
{responseStatus && (
<Chip size="sm" variant="dot" color={responseStatus.code >= 200 && responseStatus.code < 300 ? 'success' : 'danger'} className="h-5 text-[10px] font-mono border-none bg-transparent pl-0">
<Chip size='sm' variant='dot' color={responseStatus.code >= 200 && responseStatus.code < 300 ? 'success' : 'danger'} className='h-5 text-[10px] font-mono border-none bg-transparent pl-0'>
{responseStatus.code} {responseStatus.text}
</Chip>
)}
@@ -436,9 +444,9 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
{/* Response Editor */}
{responseExpanded && (
<div style={{ height: responseHeight }} className="relative bg-transparent">
<div style={{ height: responseHeight }} className='relative bg-transparent'>
<PageLoading loading={isFetching} />
<div className="absolute inset-0">
<div className='absolute inset-0'>
<CodeEditor
value={responseContent || '// Waiting for response...'}
language='json'
@@ -454,7 +462,7 @@ const OneBotApiDebug = forwardRef<OneBotApiDebugRef, OneBotApiDebugProps>((props
padding: { top: 12, bottom: 12 },
renderLineHighlight: 'none',
chromeless: true,
backgroundColor: 'transparent'
backgroundColor: 'transparent',
}}
/>
</div>
@@ -43,7 +43,7 @@ const OneBotSendModal: React.FC<OneBotSendModalProps> = (props) => {
return (
<>
<Button onPress={onOpen} color='primary' radius='full' variant='flat' size='sm' className="font-medium">
<Button onPress={onOpen} color='primary' radius='full' variant='flat' size='sm' className='font-medium'>
构造请求
</Button>
<Modal
@@ -1,4 +1,3 @@
const PageBackground = () => {
return (
<div className='fixed inset-0 w-full h-full -z-10 overflow-hidden bg-gradient-to-br from-indigo-50 via-white to-pink-50 dark:from-gray-900 dark:via-gray-800 dark:to-gray-900'>
@@ -54,80 +54,86 @@ const PasswordLogin: React.FC<PasswordLoginProps> = ({ onSubmit, onCaptchaSubmit
return (
<div className='flex flex-col gap-8'>
{captchaState?.needCaptcha && captchaState.proofWaterUrl ? (
<div className='flex flex-col gap-4 items-center'>
{captchaVerifying ? (
<>
<p className='text-primary text-sm'>验证码已提交,正在等待服务器验证结果...</p>
<div className='flex items-center justify-center py-8 gap-3'>
<Spinner size='lg' />
</div>
</>
) : (
<>
<p className='text-warning text-sm'>登录需要安全验证,请完成验证码</p>
<TencentCaptchaModal
proofWaterUrl={captchaState.proofWaterUrl}
onSuccess={(data) => {
onCaptchaSubmit?.(captchaState.uin, captchaState.password, data);
}}
onCancel={onCaptchaCancel}
/>
</>
)}
<Button
variant='light'
color='danger'
size='sm'
onPress={onCaptchaCancel}
>
取消验证
</Button>
</div>
) : newDeviceState?.needNewDevice && newDeviceState.jumpUrl ? (
<NewDeviceVerify
jumpUrl={newDeviceState.jumpUrl}
uin={newDeviceState.uin}
onVerified={(token) => onNewDeviceVerified?.(token)}
onCancel={onNewDeviceCancel}
/>
) : (
<>
<div className='flex justify-center'>
<Image
className='shadow-lg'
height={100}
radius='full'
src={`https://q1.qlogo.cn/g?b=qq&nk=${uin || '0'}&s=100`}
width={100}
alt="QQ Avatar"
/>
{captchaState?.needCaptcha && captchaState.proofWaterUrl
? (
<div className='flex flex-col gap-4 items-center'>
{captchaVerifying
? (
<>
<p className='text-primary text-sm'>验证码已提交,正在等待服务器验证结果...</p>
<div className='flex items-center justify-center py-8 gap-3'>
<Spinner size='lg' />
</div>
</>
)
: (
<>
<p className='text-warning text-sm'>登录需要安全验证,请完成验证码</p>
<TencentCaptchaModal
proofWaterUrl={captchaState.proofWaterUrl}
onSuccess={(data) => {
onCaptchaSubmit?.(captchaState.uin, captchaState.password, data);
}}
onCancel={onCaptchaCancel}
/>
</>
)}
<Button
variant='light'
color='danger'
size='sm'
onPress={onCaptchaCancel}
>
取消验证
</Button>
</div>
<div className='flex flex-col gap-4'>
<Input
type="text"
label="QQ账号"
placeholder="请输入QQ号"
value={uin}
onValueChange={setUin}
variant="bordered"
size='lg'
autoComplete="off"
endContent={
<Dropdown>
<DropdownTrigger>
<Button isIconOnly variant="light" size="sm" radius="full">
<IoChevronDown size={16} />
</Button>
</DropdownTrigger>
<DropdownMenu
aria-label="QQ Login History"
items={qqList}
onAction={(key) => setUin(key.toString())}
>
{(item) => (
<DropdownItem key={item.uin} textValue={item.uin}>
<div className='flex items-center gap-2'>
)
: newDeviceState?.needNewDevice && newDeviceState.jumpUrl
? (
<NewDeviceVerify
jumpUrl={newDeviceState.jumpUrl}
uin={newDeviceState.uin}
onVerified={(token) => onNewDeviceVerified?.(token)}
onCancel={onNewDeviceCancel}
/>
)
: (
<>
<div className='flex justify-center'>
<Image
className='shadow-lg'
height={100}
radius='full'
src={`https://q1.qlogo.cn/g?b=qq&nk=${uin || '0'}&s=100`}
width={100}
alt='QQ Avatar'
/>
</div>
<div className='flex flex-col gap-4'>
<Input
type='text'
label='QQ账号'
placeholder='请输入QQ号'
value={uin}
onValueChange={setUin}
variant='bordered'
size='lg'
autoComplete='off'
endContent={
<Dropdown>
<DropdownTrigger>
<Button isIconOnly variant='light' size='sm' radius='full'>
<IoChevronDown size={16} />
</Button>
</DropdownTrigger>
<DropdownMenu
aria-label='QQ Login History'
items={qqList}
onAction={(key) => setUin(key.toString())}
>
{(item) => (
<DropdownItem key={item.uin} textValue={item.uin}>
<div className='flex items-center gap-2'>
<Avatar
alt={item.uin}
className='flex-shrink-0'
@@ -144,38 +150,38 @@ const PasswordLogin: React.FC<PasswordLoginProps> = ({ onSubmit, onCaptchaSubmit
: item.uin}
</div>
</div>
</DropdownItem>
)}
</DropdownMenu>
</Dropdown>
</DropdownItem>
)}
</DropdownMenu>
</Dropdown>
}
/>
<Input
type="password"
label="密码"
placeholder="请输入密码"
value={password}
onValueChange={setPassword}
variant="bordered"
size='lg'
autoComplete="new-password"
/>
</div>
<div className='flex justify-center mt-5'>
<Button
className='w-64 max-w-full'
color='primary'
isLoading={isLoading}
radius='full'
size='lg'
variant='shadow'
onPress={handleSubmit}
>
登录
</Button>
</div>
</>
)}
/>
<Input
type='password'
label='密码'
placeholder='请输入密码'
value={password}
onValueChange={setPassword}
variant='bordered'
size='lg'
autoComplete='new-password'
/>
</div>
<div className='flex justify-center mt-5'>
<Button
className='w-64 max-w-full'
color='primary'
isLoading={isLoading}
radius='full'
size='lg'
variant='shadow'
onPress={handleSubmit}
>
登录
</Button>
</div>
</>
)}
</div>
);
};
@@ -69,11 +69,12 @@ const SideBar: React.FC<SideBarProps> = (props) => {
>
<motion.div className='w-64 flex flex-col items-stretch h-full transition-transform duration-300 ease-in-out z-30 relative float-right p-4'>
<div className='flex items-center justify-start gap-3 px-2 my-8 ml-2'>
<div className="h-5 w-1 bg-primary rounded-full shadow-sm" />
<div className='h-5 w-1 bg-primary rounded-full shadow-sm' />
<div className={clsx(
"text-xl font-bold tracking-wide select-none",
'text-xl font-bold tracking-wide select-none',
hasBackground ? 'text-white' : 'text-default-900 dark:text-white'
)}>
)}
>
NapCat
</div>
</div>
@@ -102,7 +102,7 @@ const renderItems = (items: MenuItem[], children = false) => {
? 'bg-primary-500 animate-nav-spin'
: 'bg-primary-200 dark:bg-white shadow-lg'
)}
aria-hidden="true"
aria-hidden='true'
/>
)
}
@@ -26,7 +26,6 @@ import Modal from '@/components/modal';
import MirrorSelectorModal from '@/components/mirror_selector_modal';
import { hasNewVersion, compareVersion } from '@/utils/version';
export interface SystemInfoItemProps {
title: string;
icon?: React.ReactNode;
@@ -57,13 +56,15 @@ const SystemInfoItem: React.FC<SystemInfoItemProps> = ({
)}
onClick={onClick}
>
<div className="text-lg opacity-70 self-center">{icon}</div>
<div className='text-lg opacity-70 self-center'>{icon}</div>
<div className='w-24 font-medium'>{title}</div>
<div className={clsx(
'text-xs font-mono flex-1',
hasBackground ? 'text-white/80' : 'text-default-500'
)}>{value}</div>
<div className="self-center">{endContent}</div>
)}
>{value}
</div>
<div className='self-center'>{endContent}</div>
</div>
);
};
@@ -85,28 +86,28 @@ const UpdateDialogContent: React.FC<{
return (
<div className='space-y-6'>
{/* 版本对比 */}
<div className="flex flex-col sm:flex-row items-center justify-between gap-4 px-6 py-8 bg-default-50 dark:bg-default-100/5 rounded-xl border border-default-100 dark:border-default-100/10">
<div className="flex flex-col items-center gap-2 min-w-0 w-full sm:w-auto">
<span className="text-xs text-default-500 font-medium uppercase tracking-wider">当前版本</span>
<div className='flex flex-col sm:flex-row items-center justify-between gap-4 px-6 py-8 bg-default-50 dark:bg-default-100/5 rounded-xl border border-default-100 dark:border-default-100/10'>
<div className='flex flex-col items-center gap-2 min-w-0 w-full sm:w-auto'>
<span className='text-xs text-default-500 font-medium uppercase tracking-wider'>当前版本</span>
<Tooltip content={`v${currentVersion}`}>
<Chip size="md" variant="flat" color="default" classNames={{ content: "font-mono font-bold text-sm truncate max-w-[120px] sm:max-w-[160px]" }}>
<Chip size='md' variant='flat' color='default' classNames={{ content: 'font-mono font-bold text-sm truncate max-w-[120px] sm:max-w-[160px]' }}>
v{currentVersion}
</Chip>
</Tooltip>
</div>
<div className="flex flex-col items-center text-primary-500 px-4 shrink-0">
<div className="p-2 rounded-full bg-primary-50 dark:bg-primary-900/20">
<svg className="w-6 h-6 animate-pulse rotate-90 sm:rotate-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 8l4 4m0 0l-4 4m4-4H3" />
<div className='flex flex-col items-center text-primary-500 px-4 shrink-0'>
<div className='p-2 rounded-full bg-primary-50 dark:bg-primary-900/20'>
<svg className='w-6 h-6 animate-pulse rotate-90 sm:rotate-0' fill='none' viewBox='0 0 24 24' stroke='currentColor'>
<path strokeLinecap='round' strokeLinejoin='round' strokeWidth={2} d='M17 8l4 4m0 0l-4 4m4-4H3' />
</svg>
</div>
</div>
<div className="flex flex-col items-center gap-2 min-w-0 w-full sm:w-auto">
<span className="text-xs text-primary-500 font-medium uppercase tracking-wider">最新版本</span>
<div className='flex flex-col items-center gap-2 min-w-0 w-full sm:w-auto'>
<span className='text-xs text-primary-500 font-medium uppercase tracking-wider'>最新版本</span>
<Tooltip content={`v${latestVersion}`}>
<Chip size="md" color="primary" variant="shadow" classNames={{ content: "font-mono font-bold text-sm truncate max-w-[120px] sm:max-w-[160px]" }}>
<Chip size='md' color='primary' variant='shadow' classNames={{ content: 'font-mono font-bold text-sm truncate max-w-[120px] sm:max-w-[160px]' }}>
v{latestVersion}
</Chip>
</Tooltip>
@@ -257,17 +258,17 @@ const NewVersionTip = (props: NewVersionTipProps) => {
return (
<Tooltip content='有新版本可用'>
<div className="cursor-pointer flex items-center justify-center" onClick={updateStatus === 'updating' ? undefined : showUpdateDialog}>
<div className='cursor-pointer flex items-center justify-center' onClick={updateStatus === 'updating' ? undefined : showUpdateDialog}>
<Chip
size="sm"
color="primary"
variant="flat"
size='sm'
color='primary'
variant='flat'
classNames={{
content: "font-bold text-[10px] px-1 flex items-center justify-center",
base: "h-5 min-h-5 min-w-[42px]"
content: 'font-bold text-[10px] px-1 flex items-center justify-center',
base: 'h-5 min-h-5 min-w-[42px]',
}}
>
{updateStatus === 'updating' ? <Spinner size="sm" color="primary" classNames={{ wrapper: "w-3 h-3" }} /> : 'New'}
{updateStatus === 'updating' ? <Spinner size='sm' color='primary' classNames={{ wrapper: 'w-3 h-3' }} /> : 'New'}
</Chip>
</div>
</Tooltip>
@@ -362,7 +363,7 @@ const VersionSelectDialogContent: React.FC<VersionSelectDialogProps> = ({
pageSize,
type: activeTab,
search: debouncedSearch,
mirror: selectedMirror
mirror: selectedMirror,
}),
{
refreshDeps: [currentPage, activeTab, debouncedSearch, selectedMirror],
@@ -517,7 +518,7 @@ const VersionSelectDialogContent: React.FC<VersionSelectDialogProps> = ({
</div>
{releasesData?.mirror && (
<div className='text-xs text-default-400 flex items-center gap-1'>
<span className='w-2 h-2 rounded-full bg-success-500'></span>
<span className='w-2 h-2 rounded-full bg-success-500' />
镜像: {releasesData.mirror}
</div>
)}
@@ -544,50 +545,50 @@ const VersionSelectDialogContent: React.FC<VersionSelectDialogProps> = ({
</Tabs>
{/* 下载镜像状态卡片 */}
<Card className="bg-default-100/50 shadow-sm">
<CardBody className="py-2 px-3">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<span className="text-xs text-default-500">镜像源:</span>
<span className="text-sm font-medium">{getMirrorDisplayName()}</span>
<Card className='bg-default-100/50 shadow-sm'>
<CardBody className='py-2 px-3'>
<div className='flex items-center justify-between'>
<div className='flex items-center gap-2'>
<span className='text-xs text-default-500'>镜像源:</span>
<span className='text-sm font-medium'>{getMirrorDisplayName()}</span>
{mirrorLatency !== null && (
<Chip
size="sm"
size='sm'
color={getLatencyColor(mirrorLatency)}
variant="flat"
variant='flat'
startContent={<IoMdCheckmark size={12} />}
>
{formatLatency(mirrorLatency)}
</Chip>
)}
{mirrorLatency === null && !mirrorTesting && (
<Chip size="sm" color="default" variant="flat">
<Chip size='sm' color='default' variant='flat'>
未测试
</Chip>
)}
{mirrorTesting && (
<Chip size="sm" color="primary" variant="flat">
<Chip size='sm' color='primary' variant='flat'>
测速中...
</Chip>
)}
</div>
<div className="flex items-center gap-1">
<Tooltip content="测速">
<div className='flex items-center gap-1'>
<Tooltip content='测速'>
<Button
isIconOnly
size="sm"
variant="light"
size='sm'
variant='light'
onPress={testCurrentMirror}
isLoading={mirrorTesting}
>
<IoMdFlash size={16} />
</Button>
</Tooltip>
<Tooltip content="切换镜像">
<Tooltip content='切换镜像'>
<Button
isIconOnly
size="sm"
variant="light"
size='sm'
variant='light'
onPress={() => setMirrorModalOpen(true)}
>
<IoMdSettings size={16} />
@@ -626,76 +627,81 @@ const VersionSelectDialogContent: React.FC<VersionSelectDialogProps> = ({
</span>
)}
</div>
{releasesLoading ? (
<div className='flex items-center gap-2 py-2'>
<Spinner size='sm' />
<span className='text-sm text-default-500'>加载版本列表...</span>
</div>
) : releasesError ? (
<div className='text-sm text-danger-500'>
加载版本列表失败: {releasesError.message}
</div>
) : filteredVersions.length === 0 ? (
<div className='text-sm text-default-500 py-4 text-center'>
{searchQuery ? `未找到匹配 "${searchQuery}" 的版本` : '暂无可用版本'}
</div>
) : (
<Select
label='选择版本'
placeholder='请选择要更新的版本'
selectedKeys={selectedVersion ? [selectedVersionTag] : []}
onSelectionChange={(keys) => {
const selectedTag = Array.from(keys)[0] as string;
const version = filteredVersions.find(v => v.tag === selectedTag);
setSelectedVersion(version || null);
}}
classNames={{
trigger: 'h-auto min-h-10',
}}
>
{filteredVersions.map((version) => {
const isCurrent = version.tag.replace(/^v/, '') === currentVersion;
const downgrade = isDowngrade(version.tag);
return (
<SelectItem
key={version.tag}
textValue={version.tag}
{releasesLoading
? (
<div className='flex items-center gap-2 py-2'>
<Spinner size='sm' />
<span className='text-sm text-default-500'>加载版本列表...</span>
</div>
)
: releasesError
? (
<div className='text-sm text-danger-500'>
加载版本列表失败: {releasesError.message}
</div>
)
: filteredVersions.length === 0
? (
<div className='text-sm text-default-500 py-4 text-center'>
{searchQuery ? `未找到匹配 "${searchQuery}" 的版本` : '暂无可用版本'}
</div>
)
: (
<Select
label='选择版本'
placeholder='请选择要更新的版本'
selectedKeys={selectedVersion ? [selectedVersionTag] : []}
onSelectionChange={(keys) => {
const selectedTag = Array.from(keys)[0] as string;
const version = filteredVersions.find(v => v.tag === selectedTag);
setSelectedVersion(version || null);
}}
classNames={{
trigger: 'h-auto min-h-10',
}}
>
<div className='flex flex-col gap-0.5'>
<div className='flex items-center gap-2'>
<span className="truncate max-w-[300px]">
{version.type === 'action'
? (version.workflowTitle || version.artifactName || version.tag)
: version.tag
}
</span>
{version.type === 'prerelease' && (
<Chip size='sm' color='secondary' variant='flat'>预发布</Chip>
)}
{version.type === 'action' && (
<Chip size='sm' color='default' variant='flat'>临时</Chip>
)}
{isCurrent && (
<Chip size='sm' color='success' variant='flat'>当前</Chip>
)}
{downgrade && !isCurrent && version.type !== 'action' && (
<Chip size='sm' color='warning' variant='flat'>降级</Chip>
)}
</div>
{version.type === 'action' && (
<div className='text-xs text-default-400 flex items-center gap-2'>
<span className='font-mono bg-default-100 dark:bg-default-100/10 px-1 rounded'>{version.tag}</span>
{version.headSha && <span className='font-mono' title={version.headSha}>{version.headSha.slice(0, 7)}</span>}
{version.createdAt && <span>{new Date(version.createdAt).toLocaleString()}</span>}
{version.size && <span>{(version.size / 1024 / 1024).toFixed(1)} MB</span>}
</div>
)}
</div>
</SelectItem>
);
})}
</Select>
)}
{filteredVersions.map((version) => {
const isCurrent = version.tag.replace(/^v/, '') === currentVersion;
const downgrade = isDowngrade(version.tag);
return (
<SelectItem
key={version.tag}
textValue={version.tag}
>
<div className='flex flex-col gap-0.5'>
<div className='flex items-center gap-2'>
<span className='truncate max-w-[300px]'>
{version.type === 'action'
? (version.workflowTitle || version.artifactName || version.tag)
: version.tag}
</span>
{version.type === 'prerelease' && (
<Chip size='sm' color='secondary' variant='flat'>预发布</Chip>
)}
{version.type === 'action' && (
<Chip size='sm' color='default' variant='flat'>临时</Chip>
)}
{isCurrent && (
<Chip size='sm' color='success' variant='flat'>当前</Chip>
)}
{downgrade && !isCurrent && version.type !== 'action' && (
<Chip size='sm' color='warning' variant='flat'>降级</Chip>
)}
</div>
{version.type === 'action' && (
<div className='text-xs text-default-400 flex items-center gap-2'>
<span className='font-mono bg-default-100 dark:bg-default-100/10 px-1 rounded'>{version.tag}</span>
{version.headSha && <span className='font-mono' title={version.headSha}>{version.headSha.slice(0, 7)}</span>}
{version.createdAt && <span>{new Date(version.createdAt).toLocaleString()}</span>}
{version.size && <span>{(version.size / 1024 / 1024).toFixed(1)} MB</span>}
</div>
)}
</div>
</SelectItem>
);
})}
</Select>
)}
</div>
{/* Action 版本提示 */}
@@ -786,7 +792,7 @@ const VersionSelectDialogContent: React.FC<VersionSelectDialogProps> = ({
setSelectedMirror(mirror || undefined);
setMirrorLatency(null);
}}
type="file"
type='file'
/>
</div>
);
@@ -848,7 +854,7 @@ const NapCatVersion: React.FC<NapCatVersionProps> = ({ hasBackground = false })
<Modal
title='版本管理'
size='lg'
hideFooter={true}
hideFooter
onClose={() => setIsVersionModalOpen(false)}
content={
<VersionSelectDialogContent
@@ -883,11 +889,13 @@ const SystemInfo: React.FC<SystemInfoProps> = (props) => {
<Card className={clsx(
'backdrop-blur-sm border border-white/40 dark:border-white/10 shadow-sm overflow-visible flex-1',
hasBackground ? 'bg-white/10 dark:bg-black/10' : 'bg-white/60 dark:bg-black/40'
)}>
)}
>
<CardHeader className={clsx(
'pb-0 items-center gap-2 font-bold px-4 pt-4',
hasBackground ? 'text-white drop-shadow-sm' : 'text-default-700 dark:text-white'
)}>
)}
>
<FaCircleInfo className='text-lg opacity-80' />
<span>系统信息</span>
</CardHeader>
@@ -29,19 +29,22 @@ const SystemStatusItem: React.FC<SystemStatusItemProps> = ({
<div
className={clsx(
'py-1.5 text-sm transition-colors',
size === 'lg' ? 'col-span-2' : 'col-span-1 flex justify-between items-center',
size === 'lg' ? 'col-span-2' : 'col-span-1 flex justify-between items-center'
)}
>
<div className={clsx(
'w-24 font-medium',
hasBackground ? 'text-white/90' : 'text-default-600 dark:text-gray-300'
)}>{title}</div>
)}
>{title}
</div>
<div className={clsx(
'font-mono text-xs',
hasBackground ? 'text-white/80' : 'text-default-500'
)}>
)}
>
{value}
{unit && <span className="ml-0.5 opacity-70">{unit}</span>}
{unit && <span className='ml-0.5 opacity-70'>{unit}</span>}
</div>
</div>
);
@@ -70,7 +73,8 @@ const SystemStatusDisplay: React.FC<SystemStatusDisplayProps> = ({ data }) => {
<Card className={clsx(
'backdrop-blur-sm border border-white/40 dark:border-white/10 shadow-sm col-span-1 lg:col-span-2 relative overflow-hidden',
hasBackground ? 'bg-white/10 dark:bg-black/10' : 'bg-white/60 dark:bg-black/40'
)}>
)}
>
<div className='absolute h-full right-0 top-0'>
<Image
src={bkg}
@@ -87,7 +91,8 @@ const SystemStatusDisplay: React.FC<SystemStatusDisplayProps> = ({ data }) => {
<h2 className={clsx(
'text-lg font-semibold flex items-center gap-2 mb-2',
hasBackground ? 'text-white drop-shadow-sm' : 'text-default-700 dark:text-gray-200'
)}>
)}
>
<GiCpu className='text-xl opacity-80' />
<span>CPU</span>
</h2>
@@ -111,7 +116,8 @@ const SystemStatusDisplay: React.FC<SystemStatusDisplayProps> = ({ data }) => {
<h2 className={clsx(
'text-lg font-semibold flex items-center gap-2 mb-2 mt-4',
hasBackground ? 'text-white drop-shadow-sm' : 'text-default-700 dark:text-gray-200'
)}>
)}
>
<BiSolidMemoryCard className='text-xl opacity-80' />
<span>内存</span>
</h2>
@@ -156,9 +156,9 @@ const TencentCaptchaModal: React.FC<TencentCaptchaProps> = ({
}, [proofWaterUrl, handleResult]);
return (
<div className="flex items-center justify-center py-8 gap-3">
<Spinner size="lg" />
<span className="text-default-500">正在加载验证码...</span>
<div className='flex items-center justify-center py-8 gap-3'>
<Spinner size='lg' />
<span className='text-default-500'>正在加载验证码...</span>
</div>
);
};
@@ -55,7 +55,7 @@ const XTerm = forwardRef<XTermRef, XTermProps>((props, ref) => {
'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "JetBrains Mono", monospace',
cursorInactiveStyle: 'outline',
drawBoldTextInBrightColors: false,
fontSize: fontSize,
fontSize,
lineHeight: 1.2,
});
terminalRef.current = terminal;
@@ -16,8 +16,8 @@ export async function fetchOneBotHttpApi (): Promise<OneBotHttpApi> {
try {
const response = await fetch('/api/Debug/schemas', {
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
}
Authorization: `Bearer ${localStorage.getItem('token')}`,
},
});
const data = await response.json();
if (data.code === 0) {
@@ -37,4 +37,3 @@ export function getOneBotHttpApi () {
export type OneBotHttpApiPath = string;
export default oneBotHttpApi;
@@ -184,7 +184,7 @@ export default class PluginManager {
*/
public static async getPluginConfig (id: string): Promise<PluginConfigResponse> {
const { data } = await serverRequest.get<ServerResponse<PluginConfigResponse>>('/Plugin/Config', {
params: { id }
params: { id },
});
return data.data;
}
@@ -218,7 +218,7 @@ export default class PluginManager {
sessionId,
key,
value,
currentConfig
currentConfig,
});
}
@@ -296,4 +296,3 @@ export default class QQManager {
);
}
}
@@ -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">跳转 &rarr;</span>
<span className='text-tiny text-default-400'>跳转 &rarr;</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
@@ -86,7 +86,7 @@ export function parseTypeBox (
type: 'object',
optional: false,
description: `... 还有 ${allOptions.length - MAX_UNION_OPTIONS} 个类型`,
isTruncated: true
isTruncated: true,
});
}
return { name, type: 'union', children, optional, description };