diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..c76c14f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "marscode.marscode-extension" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..137d9f4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "marscode.chatLanguage": "cn", + "marscode.codeCompletionPro": { + "enableCodeCompletionPro": true + }, + "marscode.enableInlineCommand": true +} \ No newline at end of file diff --git a/apps/web/src/app/main/component/People.tsx b/apps/web/src/app/main/component/People.tsx new file mode 100644 index 0000000..835b87e --- /dev/null +++ b/apps/web/src/app/main/component/People.tsx @@ -0,0 +1,51 @@ +import { useEffect } from 'react'; +import { api } from '@nice/client'; + +function People() { + // 使用 useQuery 钩子从 API 获取数据,限制查询结果数量为 10 + const { data } = api.staff.findMany.useQuery({ + take: 10, // 限制查询结果数量 + }); + // 当 data 发生变化时,打印数据到控制台 + useEffect(() => { + console.log(data); + }, [data]); + + return ( +
+ { + // 遍历 data 并渲染每个元素 + data?.map((i) => { + return ( + + + + + + + + + + + + + {data?.map((i) => ( + + + + + + + + + ))} + +
UsernameIDShownamePasswordPhone NumberOrder
{i.username}{i.id}{i.showname}{i.password}{i.phoneNumber}{i.order}
+ ); + }) + } +
+ ); +} + +export default People; diff --git a/apps/web/src/app/main/home/page.tsx b/apps/web/src/app/main/home/page.tsx index 7c1e5a3..e3d0133 100755 --- a/apps/web/src/app/main/home/page.tsx +++ b/apps/web/src/app/main/home/page.tsx @@ -1,10 +1,31 @@ -import { api } from "@nice/client" -import { useEffect } from "react" +import { api } from '@nice/client'; +import { useState, useEffect, useMemo } from 'react'; +import { Button } from 'antd'; +import People from '../component/People'; +// 主页入口组件,负责渲染首页内容 +function HomePage() { + // 使用trpc查询接口获取员工列表(取前10条记录) + // const { data } = api.staff.findMany.useQuery({ + // take: 10, // 限制查询结果数量 + // }); + const [counter, setCounter] = useState(0); + const counterText = useMemo(() => { + return `当前值:${counter}` + }, [counter]); -export default function HomePage() { - const { data } = api.staff.findMany.useQuery({ take: 10 }) - useEffect(() => { - console.log(data) - }, [data]) - return <>Home -} \ No newline at end of file + // useEffect(() => { + // console.log(data); + // }, [data]); + return ( +
+
+ +
{counterText}
+ +
+ +
+ ); +} +//export {HomePage}; MainRoute也要+{} +export default HomePage; \ No newline at end of file diff --git a/config/nginx/conf.d/web.conf b/config/nginx/conf.d/web.conf index 00fbbf1..bf90259 100755 --- a/config/nginx/conf.d/web.conf +++ b/config/nginx/conf.d/web.conf @@ -27,7 +27,8 @@ server { # 压缩HTTP版本 gzip_http_version 1.1; # 压缩的文件类型 - gzip_types text/plain + gzip_types + text/plain text/css application/json application/javascript @@ -90,8 +91,8 @@ server { add_header 'Access-Control-Allow-Origin' '$http_origin' always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always; - add_header 'Access-Control-Allow-Headers' - 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' + add_header 'Access-Control-Allow-Headers' + 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization' always; } # 内部认证服务位置 @@ -110,4 +111,4 @@ server { proxy_set_header Host $host; proxy_set_header X-Query-Params $query_string; } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 8a85a11..8156253 100755 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "dev": "pnpm run --parallel dev", - "db:clear": "pnpm --filter common run db:clear" + "db:clear": "pnpm --filter common run db:clear", + "studio": "pnpm --filter common run studio" }, "keywords": [], "author": "insiinc",