master
wei 2024-09-17 10:34:19 +00:00
parent 1d7335e8b8
commit 3919b572c8
39 changed files with 594 additions and 187 deletions

View File

@ -20,6 +20,10 @@
"emmet.includeLanguages": {
"postcss": "css"
},
"tailwindCSS.experimental.configFile": {
"apps/web/src/app/tailwind-config.ts": "apps/web/src/app/**"
},
"stylelint.enable": true,
"stylelint.snippet": ["css", "scss", "less", "postcss"],
"stylelint.validate": ["css", "scss", "less", "postcss"],

View File

@ -34,3 +34,7 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
## components.json
Shadcn config files

View File

@ -9,6 +9,8 @@ schema.prisma
```generator client {
provider = "prisma-client-js"
// prismaSchemaFolder 设置读取schema文件夹下所有的模型文件
previewFeatures = ["prismaSchemaFolder"]
}
datasource db {

View File

@ -12,7 +12,7 @@
"dbrs": "cross-env NODE_ENV=development prisma migrate reset -f",
"dbs": "cross-env NODE_ENV=development prisma db seed",
"dbo": "prisma studio",
"addsc": "pnpm dlx shadcn-ui@latest add",
"addsc": "pnpm dlx shadcn-ui@latest add -c ./src/app",
"dev": "next dev",
"build": "next build",
"start": "next start",
@ -21,12 +21,13 @@
"lint:style": "stylelint \"**/*.css\" --fix --cache --cache-location node_modules/.cache/stylelint/"
},
"dependencies": {
"@3rapp/utils": "workspace:*",
"@3rapp/store": "workspace:*",
"@faker-js/faker": "^8.4.1",
"@prisma/client": "^5.16.1",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-slot": "^1.1.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"immutable": "^4.3.6",
@ -35,7 +36,8 @@
"prisma-paginate": "^5.2.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tailwind-merge": "^2.3.0"
"tailwind-merge": "^2.3.0",
"uuid": "^10.0.0"
},
"devDependencies": {
"@3rapp/core": "workspace:*",
@ -43,6 +45,7 @@
"@types/node": "^20.12.12",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"@types/uuid": "^10.0.0",
"autoprefixer": "^10.4.19",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
@ -54,6 +57,10 @@
"prisma": "^5.16.1",
"prisma-extension-bark": "^0.2.2",
"stylelint": "^16.5.0",
"stylelint-config-css-modules": "^4.4.0",
"stylelint-config-recess-order": "^5.0.1",
"stylelint-config-standard": "^36.0.1",
"stylelint-prettier": "^5.0.2",
"tailwindcss": "^3.4.3",
"tailwindcss-animate": "^1.0.7",
"ts-node": "^10.9.2",

View File

View File

@ -0,0 +1,57 @@
import { Slot } from '@radix-ui/react-slot';
import { cva, type VariantProps } from 'class-variance-authority';
import * as React from 'react';
import { cn } from '@/libs/utils';
const buttonVariants = cva(
'tw-inline-flex tw-items-center tw-justify-center tw-whitespace-nowrap tw-rounded-md tw-text-sm tw-font-medium tw-transition-colors focus-visible:tw-outline-none focus-visible:tw-ring-1 focus-visible:tw-ring-ring disabled:tw-pointer-events-none disabled:tw-opacity-50',
{
variants: {
variant: {
default:
'tw-bg-primary tw-text-primary-foreground tw-shadow hover:tw-bg-primary/90',
destructive:
'tw-bg-destructive tw-text-destructive-foreground tw-shadow-sm hover:tw-bg-destructive/90',
outline:
'tw-border tw-border-input tw-bg-background tw-shadow-sm hover:tw-bg-accent hover:tw-text-accent-foreground',
secondary:
'tw-bg-secondary tw-text-secondary-foreground tw-shadow-sm hover:tw-bg-secondary/80',
ghost: 'hover:tw-bg-accent hover:tw-text-accent-foreground',
link: 'tw-text-primary tw-underline-offset-4 hover:tw-underline',
},
size: {
default: 'tw-h-9 tw-px-4 tw-py-2',
sm: 'tw-h-8 tw-rounded-md tw-px-3 tw-text-xs',
lg: 'tw-h-10 tw-rounded-md tw-px-8',
icon: 'tw-h-9 tw-w-9',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
},
);
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
asChild?: boolean;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'button';
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
},
);
Button.displayName = 'Button';
export { Button, buttonVariants };

View File

@ -4,14 +4,15 @@
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/styles/index.css",
"config": "tailwind-config.ts",
"css": "styles/index.css",
"baseColor": "zinc",
"cssVariables": true,
"prefix": "tw-"
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
"components": "@/app/_components",
"ui": "@/app/_components/shadcn",
"utils": "@/libs/utils"
}
}

View File

@ -1,3 +0,0 @@
.app {
@apply tw-bg-[color: #ededed] tw-flex tw-w-full tw-h-[100vh] tw-p-0 tw-m-0;
}

View File

@ -1,19 +1,17 @@
import { Metadata } from 'next';
import { PropsWithChildren } from 'react';
import '@/styles/index.css';
import '@/app/styles/index.css';
export const metadata: Metadata = {
title: 'nextapp',
description: '3r教室Next.js全栈开发课程',
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
const RootLayout: React.FC<PropsWithChildren> = ({ children }) => {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
};
export default RootLayout;

View File

@ -0,0 +1,20 @@
import clsx from 'clsx';
export const container = clsx(
'tw-h-[100vh]',
'tw-w-full',
'tw-p-0',
'tw-m-0',
'tw-flex',
'tw-flex-auto',
'tw-items-center',
'tw-justify-center',
);
export const block = clsx(
'tw-shadow-md',
'tw-p-5',
'tw-bg-black',
'tw-text-center',
'tw-text-white',
'tw-text-lg',
);

View File

@ -1,7 +1,14 @@
export default function Page() {
return (
<div>
<h1>Page</h1>
import { Button } from './_components/shadcn/button';
import { block, container } from './page.module.css';
const App: React.FC = () => (
<main className={container}>
<div className={block}>
3R<span>Nextjs</span>
<Button asChild variant="destructive">
<p> </p>
</Button>
</div>
</main>
);
}
export default App;

View File

@ -0,0 +1,4 @@
body {
@apply tw-bg-[url(images/bg-dark.png)] tw-bg-cover tw-bg-fixed tw-bg-center;
font-size: var(--font-size-base);
}

View File

Before

Width:  |  Height:  |  Size: 257 KiB

After

Width:  |  Height:  |  Size: 257 KiB

View File

@ -1,8 +1,10 @@
@import './vars.css';
@import './app.css';
@import 'tailwindcss/base';
@import './tailwind/base.css';
@import 'tailwindcss/components';
@import './tailwind/components.css';
@import 'tailwindcss/utilities';
@import './tailwind/utilities.css';
@import './app.css';
@config "../tailwind.config.ts";

View File

@ -0,0 +1,42 @@
@layer base {
html,
body {
@apply tw-h-[100vh] tw-w-full tw-p-0 tw-m-0 tw-text-[var(--font-color-base)];
}
html {
font-family: var(--font-family-standard);
}
body {
font-size: var(--font-size-base);
}
a {
@apply tw-text-[var(--font-color-link)];
}
h1 {
@apply tw-text-3xl;
}
h2 {
@apply tw-text-2xl;
}
h3 {
@apply tw-text-xl;
}
h4 {
@apply tw-text-lg;
}
h5 {
@apply tw-text-sm;
}
}
* {
@apply tw-border-border;
}

View File

@ -0,0 +1,38 @@
@layer utilities {
/* 鼠标移动到文字或链接加深颜色 */
.tw-hover {
@apply hover:tw-text-[var(--font-color-link-hover)];
/* 只显示一行文字, 溢出部分以省略号代替 */
.tw-ellips {
@apply tw-inline-block tw-overflow-hidden tw-max-w-full tw-whitespace-nowrap tw-text-ellipsis tw-break-all;
}
/* 鼠标移动到文字或链接出现动画下划线 */
.tw-animate-decoration {
background: linear-gradient(var(--font-color-link-hover), var(--font-color-link-hover))
0% 100% / 0% 1px no-repeat;
transition: background-size ease-out 200ms;
&:not(:focus):hover {
background-size: 100% 1px;
}
}
/* 粗下划线 */
.tw-animate-decoration-lg:not(:focus):hover {
background-size: 100% 2px;
}
/* 取消下划线 */
.tw-none-animate-decoration {
background-size: 0 !important;
transition: none !important;
&:hover,
&:not(:focus):hover {
background-size: 100% 0 !important;
}
}
}
}

View File

@ -1,3 +1,27 @@
@layer base {
:root {
/* 默认文字大小 */
--font-size-base: 0.875rem;
/* 默认字体 */
--font-family-standard: 'Source Sans Pro', 'Hiragino Sans GB', 'Microsoft Yahei', simsun,
helvetica, arial, sans-serif, monospace;
/* 默认代码字体 */
--font-family-code: 'Fira Code', 'Source Sans Pro', 'Hiragino Sans GB', 'Microsoft Yahei',
simsun, helvetica, arial, sans-serif, monospace;
/* 默认文字颜色 */
--font-color-base: #2d2929;
/* 链接文字颜色 */
--font-color-link: #131212;
/* 鼠标移动到文字或链接上后的文字颜色 */
--font-color-link-hover: #0b0b0b;
}
}
@layer base {
:root {
--background: 0 0% 100%;
@ -20,6 +44,11 @@
--input: 240 5.9% 90%;
--ring: 240 10% 3.9%;
--radius: 0.5rem;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
}
.dark {
@ -42,23 +71,10 @@
--border: 240 3.7% 15.9%;
--input: 240 3.7% 15.9%;
--ring: 240 4.9% 83.9%;
}
html {
font-family: var(--font-family-standard);
}
body {
font-size: var(--font-size-base);
}
}
@layer base {
* {
@apply tw-border-border;
}
body {
@apply tw-bg-background tw-text-foreground;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

View File

@ -0,0 +1,89 @@
/* eslint-disable global-require */
/* eslint-disable import/no-extraneous-dependencies */
import type { Config } from 'tailwindcss';
const config = {
darkMode: ['class'],
content: ['./src/app/**/*.{ts,tsx}'],
prefix: 'tw-',
theme: {
container: {
center: true,
padding: '2rem',
screens: {
xs: '480px',
sm: '576px',
md: '768px',
lg: '992px',
xl: '1200px',
'2xl': '1400px',
},
},
extend: {
colors: {
border: 'hsl(var(--border))',
input: 'hsl(var(--input))',
ring: 'hsl(var(--ring))',
background: 'hsl(var(--background))',
foreground: 'hsl(var(--foreground))',
primary: {
DEFAULT: 'hsl(var(--primary))',
foreground: 'hsl(var(--primary-foreground))',
},
secondary: {
DEFAULT: 'hsl(var(--secondary))',
foreground: 'hsl(var(--secondary-foreground))',
},
destructive: {
DEFAULT: 'hsl(var(--destructive))',
foreground: 'hsl(var(--destructive-foreground))',
},
muted: {
DEFAULT: 'hsl(var(--muted))',
foreground: 'hsl(var(--muted-foreground))',
},
accent: {
DEFAULT: 'hsl(var(--accent))',
foreground: 'hsl(var(--accent-foreground))',
},
popover: {
DEFAULT: 'hsl(var(--popover))',
foreground: 'hsl(var(--popover-foreground))',
},
card: {
DEFAULT: 'hsl(var(--card))',
foreground: 'hsl(var(--card-foreground))',
},
},
borderRadius: {
lg: 'var(--radius)',
md: 'calc(var(--radius) - 2px)',
sm: 'calc(var(--radius) - 4px)',
},
keyframes: {
'accordion-down': {
from: { height: '0' },
to: { height: 'var(--radix-accordion-content-height)' },
},
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: '0' },
},
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out',
},
boxShadow: {
nysm: '0 0 2px 0 rgb(0 0 0 / 0.05)',
ny: '0 0 3px 0 rgb(0 0 0 / 0.1), 0 0 2px - 1px rgb(0 0 0 / 0.1)',
nymd: '0 0 6px -1px rgb(0 0 0 / 0.1), 0 0 4px -2px rgb(0 0 0 / 0.1)',
nylg: '0 0 15px -3px rgb(0 0 0 / 0.1), 0 0 6px -4px rgb(0 0 0 / 0.1)',
spread: '0 5px 40px rgb(0 0 0 / 0.1)',
},
},
},
plugins: [require('tailwindcss-animate')],
} satisfies Config;
export default config;

View File

@ -0,0 +1,11 @@
model Post {
id String @id @default(uuid())
thumb String
title String
summary String?
body String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@map("posts")
}

View File

@ -1,11 +1,10 @@
import { getRandListData, getRandomMin } from '@3rapp/utils';
import { faker } from '@faker-js/faker';
import { isNil } from 'lodash';
import { prisma } from '../client';
import { getRandListData, getRandomIndex } from './utils';
const forumTags = [
{
name: 'react',
@ -42,8 +41,8 @@ export const main = async () => {
data: {
publishedAt,
title: faker.lorem.sentence({ min: 3, max: 10 }),
body: faker.lorem.paragraphs(getRandomIndex(8), '<br/>\n'),
views: getRandomIndex(2100),
body: faker.lorem.paragraphs(getRandomMin(8), '<br/>\n'),
views: getRandomMin(2100),
tags: {
connect: getRandListData(tags),
},

View File

@ -1,34 +1,5 @@
import { base, zh_CN, en, Faker } from '@faker-js/faker';
/**
* N
* @param count
*/
export const getRandomIndex = (count: number) => Math.floor(Math.random() * count);
/**
*
* @param list
*/
export const getRandItemData = <T extends Record<string, any>>(list: T[]) => {
return list[getRandomIndex(list.length)];
};
/**
*
* @param list
*/
export const getRandListData = <T extends Record<string, any>>(list: T[]) => {
const result: T[] = [];
for (let i = 0; i < getRandomIndex(list.length); i++) {
const random = getRandItemData<T>(list);
if (!result.find((item) => item.id === random.id)) {
result.push(random);
}
}
return result;
};
/**
* faker,
*/

View File

@ -0,0 +1,72 @@
/**
*
*/
export interface PaginateMeta {
/**
*
*/
itemCount: number;
/**
*
*/
totalItems?: number;
/**
*
*/
perPage: number;
/**
*
*/
totalPages?: number;
/**
*
*/
currentPage: number;
}
/**
*
*/
export interface PaginateOptions {
/**
*
*/
page?: number;
/**
*
*/
limit?: number;
}
/**
*
*/
export interface PaginateReturn<E extends Record<string, any>> {
meta: PaginateMeta;
items: E[];
}
/**
*
*/
export interface IPost {
/**
* ID
*/
id: string;
/**
*
*/
title: string;
/**
*
*/
body: string;
/**
*
*/
thumb: string;
/**
*
*/
summary?: string;
}

View File

@ -1,6 +0,0 @@
import { type ClassValue, clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

View File

@ -1,4 +1,5 @@
/* eslint-disable no-var */
import { PrismaClient } from '@prisma/client';
import { withBark } from 'prisma-extension-bark';
import paginateExt from 'prisma-paginate';
@ -9,7 +10,7 @@ const prismaClientSingleton = () => {
.$extends(paginateExt);
};
declare global {
// eslint-disable-next-line vars-on-top
// eslint-disable-next-line vars-on-top, @typescript-eslint/no-redundant-type-constituents
var prismaGlobal: undefined | ReturnType<typeof prismaClientSingleton>;
}
const db = globalThis.prismaGlobal ?? prismaClientSingleton();

View File

@ -0,0 +1,45 @@
import { type ClassValue, clsx } from 'clsx';
import { isNil } from 'lodash';
import { twMerge } from 'tailwind-merge';
import { PaginateOptions, PaginateReturn } from '@/database/types';
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
/**
*
* @param data
* @param options
*/
export const paginate = async <T extends Record<string, any>>(
data: T[],
options: PaginateOptions,
): Promise<PaginateReturn<T>> => {
// 当设置每页数据量小于1时则设置为每页一条数据
const limit = isNil(options.limit) || options.limit < 1 ? 1 : options.limit;
// 如果当前页小于1则设置当前页为第一页
const page = isNil(options.page) || options.page < 1 ? 1 : options.page;
// 起始数据游标如果页面是第一页则从第1条数据开始截取如果大于第一页则从当前页的第一条数据开始截取
const start = page > 1 ? (page - 1) * limit + 1 : 0;
const items = data.slice(start, start + limit);
// 页面数量
const totalPages =
data.length % limit === 0
? Math.floor(data.length / limit)
: Math.floor(data.length / limit) + 1;
// 计算最后一页的数据量
const remainder = data.length % limit !== 0 ? data.length % limit : limit;
// 根据最优一页的数据量得出当前页面的数据量
const itemCount = page < totalPages ? limit : remainder;
return {
items,
meta: {
totalItems: data.length,
itemCount,
perPage: limit,
totalPages,
currentPage: page,
},
};
};

View File

@ -1,5 +0,0 @@
html,
body,
#root {
@apply tw-h-[100vh] tw-w-full tw-flex tw-p-0 tw-m-0;
}

View File

@ -1,2 +0,0 @@
@layer utilities {
}

View File

@ -1,12 +0,0 @@
:root {
/* 标准字体大小 */
--font-size-base: 0.875rem;
/* 标准字体 */
--font-family-standard: 'Source Sans Pro', 'Hiragino Sans GB', 'Microsoft Yahei', simsun,
helvetica, arial, sans-serif, monospace;
/* 代码字体 */
--font-family-firacode: 'Fira Code', 'Source Sans Pro', 'Hiragino Sans GB', 'Microsoft Yahei',
simsun, helvetica, arial, sans-serif, monospace;
}

View File

@ -1,82 +1,19 @@
/* eslint-disable @typescript-eslint/no-require-imports */
/* eslint-disable global-require */
import type { Config } from 'tailwindcss';
const config = {
darkMode: ['class'],
content: ['./src/**/*.{ts,tsx}'],
prefix: 'tw-',
theme: {
container: {
center: true,
padding: '2rem',
screens: {
xs: '480px',
sm: '576px',
md: '768px',
lg: '992px',
xl: '1200px',
'2xl': '1400px',
},
},
extend: {
colors: {
border: 'hsl(var(--border))',
input: 'hsl(var(--input))',
ring: 'hsl(var(--ring))',
background: 'hsl(var(--background))',
foreground: 'hsl(var(--foreground))',
primary: {
DEFAULT: 'hsl(var(--primary))',
foreground: 'hsl(var(--primary-foreground))',
},
secondary: {
DEFAULT: 'hsl(var(--secondary))',
foreground: 'hsl(var(--secondary-foreground))',
},
destructive: {
DEFAULT: 'hsl(var(--destructive))',
foreground: 'hsl(var(--destructive-foreground))',
},
muted: {
DEFAULT: 'hsl(var(--muted))',
foreground: 'hsl(var(--muted-foreground))',
},
accent: {
DEFAULT: 'hsl(var(--accent))',
foreground: 'hsl(var(--accent-foreground))',
},
popover: {
DEFAULT: 'hsl(var(--popover))',
foreground: 'hsl(var(--popover-foreground))',
},
card: {
DEFAULT: 'hsl(var(--card))',
foreground: 'hsl(var(--card-foreground))',
},
},
borderRadius: {
lg: 'var(--radius)',
md: 'calc(var(--radius) - 2px)',
sm: 'calc(var(--radius) - 4px)',
},
keyframes: {
'accordion-down': {
from: { height: '0' },
to: { height: 'var(--radix-accordion-content-height)' },
},
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: '0' },
},
},
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out',
boxShadow: {
nysm: '0 0 2px 0 rgb(0 0 0 / 0.05)',
ny: '0 0 3px 0 rgb(0 0 0 / 0.1), 0 0 2px - 1px rgb(0 0 0 / 0.1)',
nymd: '0 0 6px -1px rgb(0 0 0 / 0.1), 0 0 4px -2px rgb(0 0 0 / 0.1)',
nylg: '0 0 15px -3px rgb(0 0 0 / 0.1), 0 0 6px -4px rgb(0 0 0 / 0.1)',
spread: '0 5px 40px rgb(0 0 0 / 0.1)',
},
},
},
plugins: [require('tailwindcss-animate')],
} satisfies Config;
export default config;

View File

@ -2,7 +2,7 @@
"extends": "@3rapp/core/tsconfig/next.json",
"compilerOptions": {
"paths": {
"@/*": ["/src/*"]
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "typings/**/*.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],

View File

@ -28,7 +28,7 @@ module.exports = {
'at-rule-no-unknown': [
true,
{
ignoreAtRules: ['layer', 'apply', 'screen', 'define-mixin', 'mixin', 'tailwind'],
ignoreAtRules: ['layer', 'apply', 'screen', 'define-mixin', 'mixin', 'config'],
},
],

View File

@ -1,2 +1,3 @@
export * from './utils/tools';
export * from './utils/nesttools';
export * from './utils/random';

View File

@ -0,0 +1,56 @@
/**
* N
* @param count
*/
export const getRandomMin = (count: number) => Math.floor(Math.random() * count);
/**
*
* @param min
* @param max
*/
export const getRandomInt = (min: number, max: number) =>
Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min) + 1)) + min;
/**
*
* @param length
*/
export const getRandomCharString = (length: number) => {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
};
/**
*
* @param list
*/
export const getRandItemData = <T>(list: T[]) => {
return list[getRandomMin(list.length)];
};
/**
*
* @param list
*/
export const getRandListData = <T>(list: T[]) => {
const result: T[] = [];
for (let i = 0; i < getRandomMin(list.length); i++) {
const random = getRandItemData<T>(list);
const canPush = !result.find((item) => {
if ('id' in (random as Record<string, any>)) {
const check = random as Record<string, any>;
const current = item as Record<string, any>;
return current.id === check.id;
}
return item === random;
});
if (canPush) result.push(random);
}
return result;
};

View File

@ -1,5 +1,3 @@
import { resolve } from 'path';
import deepmerge from 'deepmerge';
/**
@ -22,18 +20,6 @@ export const deepMerge = <T1, T2>(
return deepmerge(x, y, options) as T2 extends T1 ? T1 : T1 & T2;
};
/**
* dir
* scripts/test.ts,srcscripts.,pathResolve('../src')src
* @param dir
*/
export const pathResolve = (dir: string) => {
const { stack } = new Error();
const stackLines = stack.split('\n');
const callerLine = stackLines[2].trim();
const callerFilePath = callerLine.match(/\(([^:)]+):/)[1];
return resolve(callerFilePath, dir);
};
/**
* null
* @param value

View File

@ -346,6 +346,9 @@ importers:
'@3rapp/store':
specifier: workspace:*
version: link:../../packages/store
'@3rapp/utils':
specifier: workspace:*
version: link:../../packages/utils
'@faker-js/faker':
specifier: ^8.4.1
version: 8.4.1
@ -359,7 +362,7 @@ importers:
specifier: ^2.1.1
version: 2.1.1(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
'@radix-ui/react-slot':
specifier: ^1.0.2
specifier: ^1.1.0
version: 1.1.0(@types/react@18.3.3)(react@18.3.1)
class-variance-authority:
specifier: ^0.7.0
@ -388,6 +391,9 @@ importers:
tailwind-merge:
specifier: ^2.3.0
version: 2.4.0
uuid:
specifier: ^10.0.0
version: 10.0.0
devDependencies:
'@3rapp/core':
specifier: workspace:*
@ -404,6 +410,9 @@ importers:
'@types/react-dom':
specifier: ^18.3.0
version: 18.3.0
'@types/uuid':
specifier: ^10.0.0
version: 10.0.0
autoprefixer:
specifier: ^10.4.19
version: 10.4.19(postcss@8.4.40)
@ -437,6 +446,18 @@ importers:
stylelint:
specifier: ^16.5.0
version: 16.7.0(typescript@5.5.4)
stylelint-config-css-modules:
specifier: ^4.4.0
version: 4.4.0(stylelint@16.7.0(typescript@5.5.4))
stylelint-config-recess-order:
specifier: ^5.0.1
version: 5.0.1(stylelint@16.7.0(typescript@5.5.4))
stylelint-config-standard:
specifier: ^36.0.1
version: 36.0.1(stylelint@16.7.0(typescript@5.5.4))
stylelint-prettier:
specifier: ^5.0.2
version: 5.0.2(prettier@3.3.3)(stylelint@16.7.0(typescript@5.5.4))
tailwindcss:
specifier: ^3.4.3
version: 3.4.7(ts-node@10.9.2(@swc/core@1.7.3(@swc/helpers@0.5.11))(@types/node@20.14.12)(typescript@5.5.4))
@ -13952,38 +13973,82 @@ snapshots:
client-only: 0.0.1
react: 18.3.1
stylelint-config-css-modules@4.4.0(stylelint@16.7.0(typescript@5.5.4)):
dependencies:
stylelint: 16.7.0(typescript@5.5.4)
optionalDependencies:
stylelint-scss: 6.5.0(stylelint@16.7.0(typescript@5.5.4))
stylelint-config-css-modules@4.4.0(stylelint@16.8.1(typescript@5.5.4)):
dependencies:
stylelint: 16.8.1(typescript@5.5.4)
optionalDependencies:
stylelint-scss: 6.5.0(stylelint@16.8.1(typescript@5.5.4))
stylelint-config-recess-order@5.0.1(stylelint@16.7.0(typescript@5.5.4)):
dependencies:
stylelint: 16.7.0(typescript@5.5.4)
stylelint-order: 6.0.4(stylelint@16.7.0(typescript@5.5.4))
stylelint-config-recess-order@5.0.1(stylelint@16.8.1(typescript@5.5.4)):
dependencies:
stylelint: 16.8.1(typescript@5.5.4)
stylelint-order: 6.0.4(stylelint@16.8.1(typescript@5.5.4))
stylelint-config-recommended@14.0.1(stylelint@16.7.0(typescript@5.5.4)):
dependencies:
stylelint: 16.7.0(typescript@5.5.4)
stylelint-config-recommended@14.0.1(stylelint@16.8.1(typescript@5.5.4)):
dependencies:
stylelint: 16.8.1(typescript@5.5.4)
stylelint-config-standard@36.0.1(stylelint@16.7.0(typescript@5.5.4)):
dependencies:
stylelint: 16.7.0(typescript@5.5.4)
stylelint-config-recommended: 14.0.1(stylelint@16.7.0(typescript@5.5.4))
stylelint-config-standard@36.0.1(stylelint@16.8.1(typescript@5.5.4)):
dependencies:
stylelint: 16.8.1(typescript@5.5.4)
stylelint-config-recommended: 14.0.1(stylelint@16.8.1(typescript@5.5.4))
stylelint-order@6.0.4(stylelint@16.7.0(typescript@5.5.4)):
dependencies:
postcss: 8.4.41
postcss-sorting: 8.0.2(postcss@8.4.41)
stylelint: 16.7.0(typescript@5.5.4)
stylelint-order@6.0.4(stylelint@16.8.1(typescript@5.5.4)):
dependencies:
postcss: 8.4.41
postcss-sorting: 8.0.2(postcss@8.4.41)
stylelint: 16.8.1(typescript@5.5.4)
stylelint-prettier@5.0.2(prettier@3.3.3)(stylelint@16.7.0(typescript@5.5.4)):
dependencies:
prettier: 3.3.3
prettier-linter-helpers: 1.0.0
stylelint: 16.7.0(typescript@5.5.4)
stylelint-prettier@5.0.2(prettier@3.3.3)(stylelint@16.8.1(typescript@5.5.4)):
dependencies:
prettier: 3.3.3
prettier-linter-helpers: 1.0.0
stylelint: 16.8.1(typescript@5.5.4)
stylelint-scss@6.5.0(stylelint@16.7.0(typescript@5.5.4)):
dependencies:
css-tree: 2.3.1
is-plain-object: 5.0.0
known-css-properties: 0.34.0
postcss-media-query-parser: 0.2.3
postcss-resolve-nested-selector: 0.1.4
postcss-selector-parser: 6.1.1
postcss-value-parser: 4.2.0
stylelint: 16.7.0(typescript@5.5.4)
optional: true
stylelint-scss@6.5.0(stylelint@16.8.1(typescript@5.5.4)):
dependencies:
css-tree: 2.3.1