2031
This commit is contained in:
parent
62bd20c906
commit
10dda20662
|
@ -1,10 +1,45 @@
|
||||||
import { api } from "@nice/client"
|
import { api, useStaff } from "@nice/client"
|
||||||
import { useEffect } from "react"
|
import { useAuth } from "@web/src/providers/auth-provider";
|
||||||
|
import { Button, Tag } from "antd";
|
||||||
export default function HomePage() {
|
import { useEffect, useMemo, useState } from "react";
|
||||||
const { data } = api.staff.findMany.useQuery({ take: 10 })
|
function HomePage(){
|
||||||
useEffect(() => {
|
const {data} = api.staff.findMany.useQuery({
|
||||||
|
take: 10
|
||||||
|
})
|
||||||
|
const {user,}=useAuth()
|
||||||
|
const {update,create}=useStaff()
|
||||||
|
const [counter, setCounter] = useState(0)
|
||||||
|
const counterText=useMemo(()=>{
|
||||||
|
return `当前计数为:${counter}`
|
||||||
|
},[counter])
|
||||||
|
// const test=async ()=>{
|
||||||
|
|
||||||
|
// await update.mutateAsync({
|
||||||
|
// where: {
|
||||||
|
// username: user?.username
|
||||||
|
// },
|
||||||
|
// data: {
|
||||||
|
// username: "test"
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
useEffect(()=>{
|
||||||
console.log(data)
|
console.log(data)
|
||||||
}, [data])
|
},[data])
|
||||||
return <>Home</>
|
|
||||||
}
|
return <div className="p-2 space-y-2">
|
||||||
|
<Tag>当前计数为:{counter}</Tag>
|
||||||
|
<div className="p-z space-x-2">
|
||||||
|
<Button type="primary" onClick={()=>{setCounter(counter + 1)}}>加1</Button>
|
||||||
|
<Button danger onClick={()=>{setCounter(counter - 1)}}>减1</Button>
|
||||||
|
</div>
|
||||||
|
{
|
||||||
|
data?.map(i=>{
|
||||||
|
return <div className="p-2 rounded border shadow"><Tag>i.username</Tag></div>
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
export default HomePage;
|
||||||
|
// export {HomePage};//main-route那里也需要加括号
|
|
@ -6,7 +6,7 @@ export const MainRoute: CustomRouteObject = {
|
||||||
element: <MainLayout></MainLayout>,
|
element: <MainLayout></MainLayout>,
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
index: true,
|
index: true, //默认为主页,app进入第一次进入这个页面
|
||||||
element: <HomePage />,
|
element: <HomePage />,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -27,7 +27,8 @@ server {
|
||||||
# 压缩HTTP版本
|
# 压缩HTTP版本
|
||||||
gzip_http_version 1.1;
|
gzip_http_version 1.1;
|
||||||
# 压缩的文件类型
|
# 压缩的文件类型
|
||||||
gzip_types text/plain
|
gzip_types
|
||||||
|
text/plain
|
||||||
text/css
|
text/css
|
||||||
application/json
|
application/json
|
||||||
application/javascript
|
application/javascript
|
||||||
|
@ -90,8 +91,8 @@ server {
|
||||||
add_header 'Access-Control-Allow-Origin' '$http_origin' always;
|
add_header 'Access-Control-Allow-Origin' '$http_origin' always;
|
||||||
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||||||
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
|
add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
|
||||||
add_header 'Access-Control-Allow-Headers'
|
add_header 'Access-Control-Allow-Headers'
|
||||||
'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'
|
'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'
|
||||||
always;
|
always;
|
||||||
}
|
}
|
||||||
# 内部认证服务位置
|
# 内部认证服务位置
|
||||||
|
@ -110,4 +111,4 @@ server {
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header X-Query-Params $query_string;
|
proxy_set_header X-Query-Params $query_string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"dev": "pnpm run --parallel dev",
|
"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": [],
|
"keywords": [],
|
||||||
"author": "insiinc",
|
"author": "insiinc",
|
||||||
|
|
Loading…
Reference in New Issue