mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-01 16:20:25 +00:00
refactor: 整体重构 (#1381)
* feat: pnpm new * Refactor build and release workflows, update dependencies Switch build scripts and workflows from npm to pnpm, update build and artifact paths, and simplify release workflow by removing version detection and changelog steps. Add new dependencies (silk-wasm, express, ws, node-pty-prebuilt-multiarch), update exports in package.json files, and add vite config for napcat-framework. Also, rename manifest.json for framework package and fix static asset copying in shell build config.
This commit is contained in:
129
packages/napcat-webui-frontend/src/components/quick_login.tsx
Normal file
129
packages/napcat-webui-frontend/src/components/quick_login.tsx
Normal file
@@ -0,0 +1,129 @@
|
||||
import { Avatar } from '@heroui/avatar';
|
||||
import { Button } from '@heroui/button';
|
||||
import { Image } from '@heroui/image';
|
||||
import { Select, SelectItem } from '@heroui/select';
|
||||
import { IoMdRefresh } from 'react-icons/io';
|
||||
|
||||
import { isQQQuickNewItem } from '@/utils/qq';
|
||||
|
||||
export interface QQItem {
|
||||
uin: string
|
||||
}
|
||||
|
||||
interface QuickLoginProps {
|
||||
qqList: (QQItem | LoginListItem)[]
|
||||
refresh: boolean
|
||||
isLoading: boolean
|
||||
selectedQQ: string
|
||||
onUpdateQQList: () => void
|
||||
handleSelectionChange: React.ChangeEventHandler<HTMLSelectElement>
|
||||
onSubmit: () => void
|
||||
}
|
||||
|
||||
const QuickLogin: React.FC<QuickLoginProps> = ({
|
||||
qqList,
|
||||
refresh,
|
||||
isLoading,
|
||||
selectedQQ,
|
||||
onUpdateQQList,
|
||||
handleSelectionChange,
|
||||
onSubmit,
|
||||
}) => {
|
||||
return (
|
||||
<div className='flex flex-col gap-8'>
|
||||
<div className='flex justify-center'>
|
||||
<Image
|
||||
className='shadow-lg'
|
||||
height={100}
|
||||
radius='full'
|
||||
src={`https://q1.qlogo.cn/g?b=qq&nk=${selectedQQ || '0'}&s=100`}
|
||||
width={100}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Select
|
||||
classNames={{
|
||||
popoverContent: 'bg-opacity-50 backdrop-blur',
|
||||
}}
|
||||
aria-label='QQ Login'
|
||||
isDisabled={refresh}
|
||||
items={qqList}
|
||||
placeholder='请选择QQ'
|
||||
renderValue={(items) => {
|
||||
return items.map((item) => (
|
||||
<div key={item.key} className='flex items-center gap-2'>
|
||||
<Avatar
|
||||
alt={item.key?.toString()}
|
||||
className='flex-shrink-0'
|
||||
size='sm'
|
||||
src={
|
||||
isQQQuickNewItem(item.data)
|
||||
? item.data?.faceUrl
|
||||
: `https://q1.qlogo.cn/g?b=qq&nk=${item.key}&s=1`
|
||||
}
|
||||
/>
|
||||
<div className='flex flex-col'>
|
||||
{isQQQuickNewItem(item.data)
|
||||
? `${item.data.nickName}(${item.key?.toString()})`
|
||||
: item.key?.toString()}
|
||||
</div>
|
||||
</div>
|
||||
));
|
||||
}}
|
||||
selectedKeys={[selectedQQ]}
|
||||
size='lg'
|
||||
onChange={handleSelectionChange}
|
||||
>
|
||||
{(item) => (
|
||||
<SelectItem key={item.uin} textValue={item.uin}>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Avatar
|
||||
alt={item.uin}
|
||||
className='flex-shrink-0'
|
||||
size='sm'
|
||||
src={
|
||||
isQQQuickNewItem(item)
|
||||
? item.faceUrl
|
||||
: `https://q1.qlogo.cn/g?b=qq&nk=${item.uin}&s=1`
|
||||
}
|
||||
/>
|
||||
<div className='flex flex-col'>
|
||||
{isQQQuickNewItem(item)
|
||||
? `${item.nickName}(${item.uin})`
|
||||
: item.uin}
|
||||
</div>
|
||||
</div>
|
||||
</SelectItem>
|
||||
)}
|
||||
</Select>
|
||||
<Button
|
||||
isIconOnly
|
||||
className='flex-grow-0 flex-shrink-0'
|
||||
color='secondary'
|
||||
isLoading={refresh}
|
||||
radius='full'
|
||||
size='lg'
|
||||
variant='light'
|
||||
onPress={onUpdateQQList}
|
||||
>
|
||||
<IoMdRefresh size={24} />
|
||||
</Button>
|
||||
</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={onSubmit}
|
||||
>
|
||||
登录
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default QuickLogin;
|
||||
Reference in New Issue
Block a user