Skip to content

Commit

Permalink
merge(#18): bietiaop/dev
Browse files Browse the repository at this point in the history
修复了HTTP Debug错误
HTTP Debug数据结构完善字段解释
添加页面Meta标题
  • Loading branch information
bietiaop authored Dec 20, 2024
2 parents 2750f53 + 3ed8c13 commit dea87ab
Show file tree
Hide file tree
Showing 27 changed files with 1,516 additions and 1,239 deletions.
4 changes: 3 additions & 1 deletion src/components/audio_player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ export default function AudioPlayer(props: AudioPlayerProps) {

const translateStyle = dragTranslate || collapsedTranslate

if (!src) return null

return (
<div
className={clsx(
Expand Down Expand Up @@ -277,7 +279,7 @@ export default function AudioPlayer(props: AudioPlayerProps) {
filler: 'rounded-full'
}}
color="foreground"
value={currentProgress}
value={currentProgress || 0}
defaultValue={0}
size="sm"
onChange={(value) => {
Expand Down
95 changes: 49 additions & 46 deletions src/components/log_com/history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,52 +81,55 @@ const HistoryLogs: React.FC<HistoryLogsProps> = (props) => {
}, [logContent, logLevel])

return (
<Card className="max-w-full h-full bg-opacity-50 backdrop-blur-sm">
<CardHeader className="flex-row justify-start gap-3">
<Select
label="选择日志"
size="sm"
isLoading={listLoading}
errorMessage={listError?.message}
classNames={{
trigger:
'hover:!bg-content3 bg-opacity-50 backdrop-blur-sm hover:!bg-opacity-60'
}}
placeholder="选择日志"
onChange={(e) => {
const value = e.target.value
if (!value) {
return
}
onSelect(value)
}}
selectedKeys={[selectedLog || '']}
items={list.map((name) => ({
value: name,
label: name
}))}
>
{(item) => (
<SelectItem key={item.value} value={item.value}>
{item.label}
</SelectItem>
)}
</Select>
<LogLevelSelect
selectedKeys={logLevel}
onSelectionChange={setLogLevel}
/>
<Button className="flex-shrink-0" onPress={onDownloadLog}>
下载日志
</Button>
<Button onPress={refreshList}>刷新列表</Button>
<Button onPress={refreshLog}>刷新日志</Button>
</CardHeader>
<CardBody className="relative">
<PageLoading loading={logLoading} />
<XTerm className="w-full h-full" ref={Xterm} />
</CardBody>
</Card>
<>
<title>历史日志 - NapCat WebUI</title>
<Card className="max-w-full h-full bg-opacity-50 backdrop-blur-sm">
<CardHeader className="flex-row justify-start gap-3">
<Select
label="选择日志"
size="sm"
isLoading={listLoading}
errorMessage={listError?.message}
classNames={{
trigger:
'hover:!bg-content3 bg-opacity-50 backdrop-blur-sm hover:!bg-opacity-60'
}}
placeholder="选择日志"
onChange={(e) => {
const value = e.target.value
if (!value) {
return
}
onSelect(value)
}}
selectedKeys={[selectedLog || '']}
items={list.map((name) => ({
value: name,
label: name
}))}
>
{(item) => (
<SelectItem key={item.value} value={item.value}>
{item.label}
</SelectItem>
)}
</Select>
<LogLevelSelect
selectedKeys={logLevel}
onSelectionChange={setLogLevel}
/>
<Button className="flex-shrink-0" onPress={onDownloadLog}>
下载日志
</Button>
<Button onPress={refreshList}>刷新列表</Button>
<Button onPress={refreshLog}>刷新日志</Button>
</CardHeader>
<CardBody className="relative">
<PageLoading loading={logLoading} />
<XTerm className="w-full h-full" ref={Xterm} />
</CardBody>
</Card>
</>
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/log_com/realtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const RealTimeLogs = () => {

return (
<>
<title>实时日志 - NapCat WebUI</title>
<div className="flex items-center gap-2">
<LogLevelSelect
selectedKeys={logLevel}
Expand All @@ -100,7 +101,6 @@ const RealTimeLogs = () => {
<div className="flex-1 h-full overflow-hidden">
<XTerm ref={Xterm} />
</div>
{/* */}
</>
)
}
Expand Down
44 changes: 25 additions & 19 deletions src/components/onebot/api/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,31 @@ const OneBotApiDebug: React.FC<OneBotApiDebugProps> = (props) => {
if (isFetching) return
setIsFetching(true)
const r = toast.loading('正在发送请求...')
request
.post(httpConfig.url + path, {
headers: {
Authorization: `Bearer ${httpConfig.token}`
},
responseType: 'text',
body: requestBody
})
.then((res) => {
setResponseContent(parseAxiosResponse(res))
})
.catch((err) => {
setResponseContent(parseAxiosResponse(err.response))
})
.finally(() => {
setIsFetching(false)
toast.dismiss(r)
toast.success('请求发送成功')
})
try {
const parsedRequestBody = JSON.parse(requestBody)
request
.post(httpConfig.url + path, parsedRequestBody, {
headers: {
Authorization: `Bearer ${httpConfig.token}`
},
responseType: 'text'
})
.then((res) => {
setResponseContent(parseAxiosResponse(res))
})
.catch((err) => {
setResponseContent(parseAxiosResponse(err.response))
})
.finally(() => {
setIsFetching(false)
toast.dismiss(r)
toast.success('请求发送成功')
})
} catch (error) {
toast.error('请求体 JSON 格式错误')
setIsFetching(false)
toast.dismiss(r)
}
}

useEffect(() => {
Expand Down
19 changes: 19 additions & 0 deletions src/components/onebot/api/display_struct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,25 @@ const RenderSchema: React.FC<{ schema: ParsedSchema }> = ({ schema }) => {
)
}

if (schema.type === 'enum' && Array.isArray(schema.enum)) {
return (
<SchemaContainer schema={schema}>
<div className="flex gap-1 items-center">
{schema.enum?.map((value, i) => (
<Chip
key={value?.toString() || i}
size="sm"
variant="flat"
color="success"
>
{value?.toString()}
</Chip>
))}
</div>
</SchemaContainer>
)
}

return (
<div className="mb-2 flex items-center gap-1 pl-5">
<Tooltip content="点击复制" placement="top" showArrow>
Expand Down
9 changes: 9 additions & 0 deletions src/components/qq_info_card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Avatar } from '@nextui-org/avatar'
import { Card, CardBody } from '@nextui-org/card'
import clsx from 'clsx'

import { SelfInfo } from '@/types/user'

Expand Down Expand Up @@ -48,6 +49,14 @@ const QQInfoCard: React.FC<QQInfoCardProps> = ({ data, error, loading }) => {
{data?.uin}
</div>
</div>
<div className="flex-shrink-0 flex items-center ml-2">
<div
className={clsx(
'w-2 h-2 rounded-full',
data?.online ? 'bg-green-500' : 'bg-gray-500'
)}
></div>
</div>
</div>
</CardBody>
)}
Expand Down
Loading

0 comments on commit dea87ab

Please sign in to comment.