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;