Skip to content

Commit

Permalink
feat: 移除 lodah-es 包,解决打包不兼容报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwumm committed Jan 8, 2025
1 parent 87d9a9b commit c105a58
Show file tree
Hide file tree
Showing 30 changed files with 642 additions and 612 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ yarn-error.log*

# typescript
*.tsbuildinfo

.vercel
6 changes: 6 additions & 0 deletions next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ const nextConfig: NextConfig = {
sassOptions: {
silenceDeprecations: ['legacy-js-api'], // 去掉控制台警告
},
typescript: {
ignoreBuildErrors: true,
},
eslint: {
ignoreDuringBuilds: true,
},
};

export default withNextIntl(nextConfig);
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"homepage": "https://github.com/baiwumm/next-admin",
"scripts": {
"dev": "next dev",
"prebuild": "prisma generate",
"build": "next build",
"start": "next start",
"lint": "next lint",
Expand All @@ -21,7 +22,7 @@
"dependencies": {
"@auth/prisma-adapter": "^2.7.4",
"@hookform/resolvers": "^3.9.1",
"@nextui-org/react": "^2.6.8",
"@nextui-org/react": "^2.6.11",
"@prisma/client": "^6.1.0",
"@radix-ui/react-collapsible": "^1.1.1",
"@radix-ui/react-dialog": "^1.1.4",
Expand All @@ -35,7 +36,6 @@
"crypto": "^1.0.1",
"dayjs": "^1.11.13",
"framer-motion": "^11.13.1",
"lodash-es": "^4.17.21",
"next": "15.1.3",
"next-auth": "5.0.0-beta.25",
"next-intl": "^3.26.3",
Expand Down
950 changes: 472 additions & 478 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions src/app/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-12-04 09:59:04
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2025-01-02 09:44:00
* @LastEditTime: 2025-01-08 14:39:23
* @Description: 关于
*/
import { Alert, Card, CardBody, CardHeader, Chip, Divider } from '@nextui-org/react';
import { keys, map } from 'lodash-es';
import { useTranslations } from 'next-intl';

import pkg from '../../../package.json';
Expand All @@ -24,7 +23,7 @@ export default function About() {
<Divider />
<CardBody>
<div className="grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{map(keys(pkg.dependencies), (key: DepKey) => (
{Object.keys(pkg.dependencies).map((key) => (
<Alert
key={key}
hideIcon
Expand All @@ -33,7 +32,7 @@ export default function About() {
<div className="flex items-center justify-between">
<span className="text-xs font-bold">{key}</span>
<Chip size="sm" color="primary">
{pkg.dependencies[key]}
{pkg.dependencies[key as DepKey]}
</Chip>
</div>
}
Expand All @@ -49,7 +48,7 @@ export default function About() {
<Divider />
<CardBody>
<div className="grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
{map(keys(pkg.devDependencies), (key: devKey) => (
{Object.keys(pkg.devDependencies).map((key) => (
<Alert
key={key}
hideIcon
Expand All @@ -58,7 +57,7 @@ export default function About() {
<div className="flex items-center justify-between">
<span className="text-xs font-bold">{key}</span>
<Chip size="sm" color="primary">
{pkg.devDependencies[key]}
{pkg.devDependencies[key as devKey]}
</Chip>
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/auth/juejin/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @LastEditTime: 2024-12-18 16:57:48
* @Description: 获取掘金列表
*/
import { get } from 'lodash-es';
import { get } from '@/lib/radash';
import { type NextRequest, NextResponse } from 'next/server';

import { RESPONSE_MSG } from '@/enums';
Expand Down
10 changes: 4 additions & 6 deletions src/app/api/user-manage/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-12-23 17:34:18
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2025-01-07 15:14:54
* @LastEditTime: 2025-01-08 15:55:26
* @Description: 用户管理模块
*/
import { Prisma } from '@prisma/client';
import bcryptjs from 'bcryptjs';
import { toNumber } from 'lodash-es';
import { type NextRequest, NextResponse } from 'next/server';

import { RESPONSE_MSG } from '@/enums';
Expand All @@ -27,8 +25,8 @@ export async function GET(request: NextRequest) {
const name = searchParams.get('name');
const email = searchParams.get('email');
// 分页处理,这里获取到的分页是字符串,需要转换成整数
const take = toNumber(size);
const skip = (toNumber(current) - 1) * take;
const take = Number(size);
const skip = (Number(current) - 1) * take;
// 条件判断
const where: Prisma.UserWhereInput = {}; // 查询参数
// 模糊查询
Expand All @@ -55,7 +53,7 @@ export async function GET(request: NextRequest) {
responseMessage({
records,
total,
current: toNumber(current),
current: Number(current),
size: take,
}),
);
Expand Down
6 changes: 3 additions & 3 deletions src/app/dashboard/components/GithubCommit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-12-20 09:19:01
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2024-12-23 09:13:59
* @LastEditTime: 2025-01-08 14:36:29
* @Description: Github 提交日志
*/
'use client';
Expand All @@ -15,11 +15,11 @@ import { RiGitCommitLine, RiResetRightLine } from '@remixicon/react';
import { useRequest } from 'ahooks';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import { get, map } from 'lodash-es';
import { useTranslations } from 'next-intl';

import ContentLoading from '@/components/ContentLoading';
import { Empty } from '@/components/ui/empty';
import { get } from '@/lib/radash';
import { isSuccess } from '@/lib/utils';
// dayjs 相对时间
dayjs.locale('zh-cn');
Expand Down Expand Up @@ -67,7 +67,7 @@ export default function GithubCommit() {
<ContentLoading loading={loading} />
{commitList?.length ? (
<Listbox aria-label={t('dashboard.github-log')} variant="faded" topContent={renderTopContent}>
{map(commitList, (item) => (
{commitList.map((item) => (
<ListboxItem key={item.sha} showDivider textValue={item.sha} onPress={() => window.open(item.html_url)}>
<div className="flex flex-col gap-1">
<div className="flex gap-2 items-center">
Expand Down
14 changes: 7 additions & 7 deletions src/app/dashboard/components/JuejinArticle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-12-18 17:04:59
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2025-01-02 16:29:46
* @LastEditTime: 2025-01-08 14:49:28
* @Description: 掘金文章列表
*/
'use client';
Expand All @@ -11,12 +11,12 @@ import { Chip, cn, Pagination, User } from '@nextui-org/react';
import { RiArticleLine, RiFontSize2, RiTimeLine } from '@remixicon/react';
import { useRequest } from 'ahooks';
import dayjs from 'dayjs';
import { ceil, get, map, take, toString } from 'lodash-es';
import { useTranslations } from 'next-intl';
import { useEffect, useState } from 'react';

import ContentLoading from '@/components/ContentLoading';
import { Empty } from '@/components/ui/empty';
import { get } from '@/lib/radash';
import { getJuejinArticle } from '@/services/auth';

export default function JuejinArticle() {
Expand Down Expand Up @@ -45,21 +45,21 @@ export default function JuejinArticle() {
...common,
});
setTotal(get(result, 'data.total', 0));
return take(get(result, 'data.records', []), pageSize);
return get(result, 'data.records', []).slice(0, pageSize);
},
{
manual: true,
},
);

useEffect(() => {
fetchJuejinArticleList({ cursor: toString(pageSize * (currentPage - 1)) });
fetchJuejinArticleList({ cursor: String(pageSize * (currentPage - 1)) });
}, [currentPage, fetchJuejinArticleList]);
return (
<div className={cn('relative flex flex-col gap-3 pr-4', `opacity-${loading ? '50' : '100'}`)}>
<ContentLoading loading={loading} />
{juejinArticleList?.length ? (
map(juejinArticleList || [], ({ article_id, author_user_info, article_info, tags }: any) => {
juejinArticleList.map(({ article_id, author_user_info, article_info, tags }: any) => {
// 文章内容
const content = get(article_info, 'brief_content', '');
return (
Expand Down Expand Up @@ -94,7 +94,7 @@ export default function JuejinArticle() {
<div className="line-clamp-2 text-xs text-muted-foreground leading-5">{content}</div>
{tags.length ? (
<div className="flex items-center gap-2">
{map(tags, (tag) => (
{tags.map((tag) => (
<Chip key={tag.tag_id} size="sm" variant="flat">
{tag.tag_name}
</Chip>
Expand All @@ -114,7 +114,7 @@ export default function JuejinArticle() {
showControls
size="sm"
initialPage={currentPage}
total={ceil(total / pageSize)}
total={Math.ceil(total / pageSize)}
onChange={setCurrentPage}
/>
</div>
Expand Down
14 changes: 7 additions & 7 deletions src/app/dashboard/components/PageViewCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-12-18 13:57:51
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2025-01-02 08:57:31
* @LastEditTime: 2025-01-08 14:59:51
* @Description: 访问量
*/
import { cn } from '@nextui-org/react';
import { Card, CardBody, CardFooter, CardHeader } from '@nextui-org/react';
import { RiArrowDownLine, RiArrowUpLine, RiResetRightLine } from '@remixicon/react';
import { useMount, useSetState } from 'ahooks';
import dayjs from 'dayjs';
import { map, random, sum, toNumber } from 'lodash-es';
import { useTranslations } from 'next-intl';
import { ReactNode, useState } from 'react';
import CountUp from 'react-countup';
import { Area, AreaChart, CartesianGrid, ResponsiveContainer } from 'recharts';

import ContentLoading from '@/components/ContentLoading';
import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from '@/components/ui/chart';
import { random, sum } from '@/lib/radash';

type ChartData = {
month: string;
Expand All @@ -43,7 +43,7 @@ export default function PageViewCard() {
});
setTimeout(() => {
setData({
complete: toNumber(random(1, 100, true).toFixed(2)),
complete: random(1, 100),
loading: false,
});
}, 1500);
Expand Down Expand Up @@ -83,10 +83,10 @@ export default function PageViewCard() {
reset();

setArrow(
random() < 0.5 ? (
<RiArrowDownLine key={random()} size={16} color="#F5222D" />
random(0, 1) < 0.5 ? (
<RiArrowDownLine key={random(0, 1)} size={16} color="#F5222D" />
) : (
<RiArrowUpLine key={random()} size={16} color="#52C41A" />
<RiArrowUpLine key={random(0, 1)} size={16} color="#52C41A" />
),
);
});
Expand All @@ -98,7 +98,7 @@ export default function PageViewCard() {
<div className="flex items-center gap-2">
<div className="text-sm font-medium">{t('page-view')}</div>
<div className="text-2xl font-bold">
<CountUp end={sum(map(chartData, 'value'))} separator="," />
<CountUp end={sum(chartData.map((v) => v.value))} separator="," />
</div>
</div>
<RiResetRightLine
Expand Down
14 changes: 7 additions & 7 deletions src/app/dashboard/components/PaymentNumberCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-12-18 13:57:51
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2025-01-02 08:58:57
* @LastEditTime: 2025-01-08 15:00:13
* @Description: 支付笔数
*/
import { Card, CardBody, CardFooter, CardHeader } from '@nextui-org/react';
import { RiArrowDownLine, RiArrowUpLine, RiResetRightLine } from '@remixicon/react';
import { useMount, useSetState } from 'ahooks';
import dayjs from 'dayjs';
import { map, random, sum, toNumber } from 'lodash-es';
import { useTranslations } from 'next-intl';
import { ReactNode, useState } from 'react';
import CountUp from 'react-countup';
import { Bar, BarChart, CartesianGrid, ResponsiveContainer } from 'recharts';

import ContentLoading from '@/components/ContentLoading';
import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent } from '@/components/ui/chart';
import { random, sum } from '@/lib/radash';

type ChartData = {
month: string;
Expand All @@ -42,7 +42,7 @@ export default function PaymentNumberCard() {
});
setTimeout(() => {
setData({
complete: toNumber(random(1, 100, true).toFixed(2)),
complete: random(1, 100),
loading: false,
});
}, 1500);
Expand Down Expand Up @@ -82,10 +82,10 @@ export default function PaymentNumberCard() {
reset();

setArrow(
random() < 0.5 ? (
<RiArrowDownLine key={random()} size={16} color="#F5222D" />
random(0, 1) < 0.5 ? (
<RiArrowDownLine key={random(0, 1)} size={16} color="#F5222D" />
) : (
<RiArrowUpLine key={random()} size={16} color="#52C41A" />
<RiArrowUpLine key={random(0, 1)} size={16} color="#52C41A" />
),
);
});
Expand All @@ -97,7 +97,7 @@ export default function PaymentNumberCard() {
<div className="flex items-center gap-2">
<div className="text-sm font-medium">{t('payment-number')}</div>
<div className="text-2xl font-bold">
<CountUp end={sum(map(chartData, 'value'))} separator="," />
<CountUp end={sum(chartData.map((v) => v.value))} separator="," />
</div>
</div>
<RiResetRightLine
Expand Down
18 changes: 9 additions & 9 deletions src/app/dashboard/components/SaleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
* @Author: 白雾茫茫丶<baiwumm.com>
* @Date: 2024-12-18 13:49:07
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2025-01-02 09:19:40
* @LastEditTime: 2025-01-08 15:04:43
* @Description: 总销售额卡片
*/
'use client';

import { Card, CardBody, CardFooter, CardHeader, Divider } from '@nextui-org/react';
import { RiArrowDownLine, RiArrowUpLine, RiResetRightLine } from '@remixicon/react';
import { useMount, useSetState } from 'ahooks';
import { random, toNumber } from 'lodash-es';
import { useTranslations } from 'next-intl';
import { ReactNode, useState } from 'react';
import CountUp from 'react-countup';

import ContentLoading from '@/components/ContentLoading';
import { random } from '@/lib/radash';

export default function SaleCard() {
const t = useTranslations('Pages.dashboard');
Expand All @@ -37,10 +37,10 @@ export default function SaleCard() {
});
setTimeout(() => {
setData({
total: random(10000000, 100000000, true),
date: toNumber(random(1, 100, true).toFixed(2)),
week: toNumber(random(1, 100, true).toFixed(2)),
complete: toNumber(random(1, 100, true).toFixed(2)),
total: random(10000000, 100000000),
date: random(1, 100),
week: random(1, 100),
complete: random(1, 100),
loading: false,
});
}, 1500);
Expand All @@ -51,10 +51,10 @@ export default function SaleCard() {

// 创建一个包含随机箭头组件的数组
const randomArrows = Array.from({ length: 3 }).map(() =>
random() < 0.5 ? (
<RiArrowDownLine key={random()} size={16} color="#F5222D" />
random(0, 1) < 0.5 ? (
<RiArrowDownLine key={random(0, 1)} size={16} color="#F5222D" />
) : (
<RiArrowUpLine key={random()} size={16} color="#52C41A" />
<RiArrowUpLine key={random(0, 1)} size={16} color="#52C41A" />
),
);

Expand Down
Loading

0 comments on commit c105a58

Please sign in to comment.