From 357894afc04fb781921fc9e9c0d53f98a6d7b60a Mon Sep 17 00:00:00 2001 From: mackt <1033530438@qq.com> Date: Sat, 20 Apr 2024 13:36:23 +0800 Subject: [PATCH] feat(feature): QRCode --- package.json | 2 + src/components/Footer/DownLoadItem.tsx | 16 --- src/components/Footer/FooterDownload.tsx | 9 +- src/components/Footer/QRCodeDialog.tsx | 19 ++- src/components/Icon/Comment.tsx | 6 +- src/components/common/QRCode.tsx | 24 ++++ src/components/index.ts | 1 + src/services/client/app.ts | 15 +++ src/services/index.ts | 4 +- src/services/server/app.ts | 22 ---- src/utils/request/client/index.ts | 2 +- src/utils/request/server/utils.ts | 10 ++ yarn.lock | 141 ++++++++++++++++++++++- 13 files changed, 210 insertions(+), 61 deletions(-) create mode 100644 src/components/common/QRCode.tsx create mode 100644 src/services/client/app.ts delete mode 100644 src/services/server/app.ts diff --git a/package.json b/package.json index 25f481b..1301f28 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@radix-ui/react-popover": "^1.0.7", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-toast": "^1.1.5", + "@types/qrcode": "^1.5.5", "class-variance-authority": "^0.7.0", "clsx": "^2.1.0", "immer": "^10.0.4", @@ -24,6 +25,7 @@ "lucide-react": "^0.367.0", "next": "14.1.3", "nookies": "^2.5.2", + "qrcode": "^1.5.3", "qs": "^6.12.0", "react": "^18", "react-dom": "^18", diff --git a/src/components/Footer/DownLoadItem.tsx b/src/components/Footer/DownLoadItem.tsx index b571844..05e54a9 100644 --- a/src/components/Footer/DownLoadItem.tsx +++ b/src/components/Footer/DownLoadItem.tsx @@ -1,19 +1,3 @@ -import QRCodeDialog from './QRCodeDialog'; - -import { apiAppVersionCheck } from '@/services'; - -const getData = async (platform: AppPlatform) => { - const res = await apiAppVersionCheck(platform); - if (res.code === 200) { - return res.data; - } else { - return { - version: '1.0.0', - url: '', - }; - } -}; - const IconIos = ({ className }: { className?: string }) => { return ( @@ -21,9 +20,9 @@ export default async function FooterPlatform({ className }: { className?: string - + {/* - + */} diff --git a/src/components/Footer/QRCodeDialog.tsx b/src/components/Footer/QRCodeDialog.tsx index d1f596f..c185c7b 100644 --- a/src/components/Footer/QRCodeDialog.tsx +++ b/src/components/Footer/QRCodeDialog.tsx @@ -2,10 +2,9 @@ import { useState, useEffect } from 'react'; -import Image from 'next/image'; - import { AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogTrigger } from '@/components/ui/alert-dialog'; +import { QRCode } from '@/components'; import { apiAppVersionCheck } from '@/services'; export default function QRCodeDialog({ @@ -25,8 +24,8 @@ export default function QRCodeDialog({ const getData = async () => { const res = await apiAppVersionCheck(platform); if (res.code === 200) { - setVersion(res.data.version); - setUrl(res.data.url); + setVersion(res.data?.version || '1.0.0'); + setUrl(res.data?.url || '1.0.0'); } }; @@ -42,13 +41,11 @@ export default function QRCodeDialog({

{headerText}

{`最新版V${version}`}

- qrcode + +
+ {!!url && } +
+