diff --git a/next.config.ts b/next.config.ts index 38855f6..dbab7a1 100644 --- a/next.config.ts +++ b/next.config.ts @@ -14,4 +14,15 @@ export default createMDX({ mdxType: 'gfm', }, }, + images: { + remotePatterns: [ + { + protocol: 'https', + hostname: 'pay.rscygroup.com', + port: '', + pathname: '/api/scan/imgs/*', + search: '', + }, + ], + }, }) diff --git a/src/actions/announcement.ts b/src/actions/announcement.ts new file mode 100644 index 0000000..a8460b4 --- /dev/null +++ b/src/actions/announcement.ts @@ -0,0 +1,19 @@ +'use server' + +import {PageRecord} from '@/lib/api' +import {Announcement} from '@/lib/models' +import {callByUser} from './base' + +export async function listAnnouncements(props: { + page: number + size: number + title?: string + type?: number + status?: number + create_after?: Date + create_before?: Date + update_after?: Date + update_before?: Date +}) { + return await callByUser>('/api/announcement/list', props) +} diff --git a/src/actions/dashboard.ts b/src/actions/dashboard.ts index e3327a0..8b6f762 100644 --- a/src/actions/dashboard.ts +++ b/src/actions/dashboard.ts @@ -1,34 +1,11 @@ 'use server' +import {ApiResponse, ExtraResp} from '@/lib/api' import {callByUser} from './base' - -export async function listInitialization(props: { - page: number - size: number - title?: string - type?: number - status?: number - create_after?: Date - create_before?: Date - update_after?: Date - update_before?: Date - short_term_package?: number -}) { - return await callByUser<{ - short_term: string - short_term_monthly: string - long_term: string - long_term_monthly: string - list: { - id: number - title: string - created_at: Date - }[] - }>('/api/announcement/list', props) -} +import {listAnnouncements} from './announcement' type listAccountReq = { - resource_no: string + resource_no?: string create_after: Date create_before: Date } @@ -39,5 +16,68 @@ type listAccountResp = { }[] export async function listAccount(props: listAccountReq) { - return await callByUser('/api/account/list', props) + return await callByUser('/api/resource/statistics/usage', props) +} + +export async function statisticsResourceFree() { + return await callByUser<{ + long: { + ResourceCount: number + ResourceDailyFreeSum: number + ResourceQuotaSum: number + } + short: { + ResourceCount: number + ResourceDailyFreeSum: number + ResourceQuotaSum: number + } + }>('/api/resource/statistics/free') +} + +type listInitializationResp = { + anno: ExtraResp + free: ExtraResp + usage: ExtraResp +} +export async function listInitialization(): Promise> { + const free = await statisticsResourceFree() + if (!free.success) { + return { + success: false, + status: 500, + message: '套餐剩余数据获取失败', + } + } + const anno = await listAnnouncements({ + page: 1, + size: 5, + }) + if (!anno.success) { + return { + success: false, + status: 500, + message: '公告数据获取失败', + } + } + const usage = await listAccount({ + create_after: new Date(), + create_before: new Date(), + }) + if (!usage.success) { + return { + success: false, + status: 500, + message: '套餐用量数据获取失败', + } + } + const data = { + anno: anno.data, + free: free.data, + usage: usage.data, + } + + return { + success: true, + data: data, + } } diff --git a/src/app/admin/(dashboard)/page.tsx b/src/app/admin/(dashboard)/page.tsx index 006fe20..8daf534 100644 --- a/src/app/admin/(dashboard)/page.tsx +++ b/src/app/admin/(dashboard)/page.tsx @@ -13,11 +13,8 @@ import mask from './_assets/Mask group.webp' export type DashboardPageProps = {} export default async function DashboardPage(props: DashboardPageProps) { - const resp = await listInitialization({ - page: 1, - size: 5, - }) - + const resp = await listInitialization() + console.log(resp, 'respresprespresprespresp') if (!resp.success) { return (
@@ -47,10 +44,10 @@ export default async function DashboardPage(props: DashboardPageProps) { {/* 磁贴集 */} {initData && ( )} @@ -65,7 +62,7 @@ export default async function DashboardPage(props: DashboardPageProps) { {/* 通知 */}
{initData && ( - + )}
diff --git a/src/app/callback/sftpay/page.tsx b/src/app/callback/sftpay/page.tsx new file mode 100644 index 0000000..aabe009 --- /dev/null +++ b/src/app/callback/sftpay/page.tsx @@ -0,0 +1,11 @@ +import {ReactNode} from 'react' + +export type SftpayPageProps = { + +} + +export default async function SftpayPage(props: SftpayPageProps) { + return ( +
111
+ ) +} diff --git a/src/components/composites/payment/desktop-payment.tsx b/src/components/composites/payment/desktop-payment.tsx index b7d69a6..b7a36fd 100644 --- a/src/components/composites/payment/desktop-payment.tsx +++ b/src/components/composites/payment/desktop-payment.tsx @@ -3,45 +3,19 @@ import {DialogContent, DialogHeader, DialogTitle} from '@/components/ui/dialog' import {Button} from '@/components/ui/button' import {completeResource} from '@/actions/resource' import {toast} from 'sonner' -import {CheckCircle, Loader} from 'lucide-react' +import {Loader} from 'lucide-react' import {useState, useEffect, useRef} from 'react' -import * as qrcode from 'qrcode' import Image from 'next/image' -import {TradeMethod} from '@/lib/models/trade' import {PaymentModalProps} from './payment-modal' export function DesktopPayment(props: PaymentModalProps) { - console.log(props, 'props') - const [paymentVerified, setPaymentVerified] = useState(false) const [loading, setLoading] = useState(false) - const canvasRef = useRef(null) - useEffect(() => { - if (!canvasRef.current || props.method === TradeMethod.Alipay) return - qrcode.toCanvas(canvasRef.current, props.pay_url, {width: 200}) - .catch((err) => { - console.error('生成二维码失败:', err) - toast.error('生成支付二维码失败') - }) - }, [props.method, props.pay_url]) - - const handleComplete = async () => { + const onSubmit = async () => { setLoading(true) - try { - const resp = await completeResource({trade_no: props.inner_no}) - if (!resp.success) throw new Error(resp.message) - toast.success('支付成功') - setPaymentVerified(true) - setTimeout(() => props.onSuccess?.(), 2000) - } - catch (e) { - toast.error('支付验证失败', {description: (e as Error).message}) - } - finally { - setLoading(false) - } + await props.onConfirm?.() + setLoading(false) } - console.log(props.decoration.text, 'props.decoration.text') return ( @@ -62,52 +36,44 @@ export function DesktopPayment(props: PaymentModalProps) { - {paymentVerified ? ( -
- -

支付验证成功

-
- ) : ( -
-
- {props.method === TradeMethod.Alipay ? ( -