muxi feng commited on
Commit
6fa5e4b
·
1 Parent(s): b22362b

修复编译bug,服务端使用post请求,设置连点禁用

Browse files
app/api/user/findpwd/route.ts CHANGED
@@ -1,6 +1,6 @@
1
  import { NextRequest } from "next/server";
2
 
3
- export async function GET(req: NextRequest) {
4
  try {
5
  const token=req.headers.get("auth") ?? ""
6
  const admin=process.env.ADMIN
 
1
  import { NextRequest } from "next/server";
2
 
3
+ export async function POST(req: NextRequest) {
4
  try {
5
  const token=req.headers.get("auth") ?? ""
6
  const admin=process.env.ADMIN
app/api/user/info/route.ts CHANGED
@@ -1,7 +1,7 @@
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { auth } from "../../auth";
3
 
4
- export async function GET(req: NextRequest) {
5
  try {
6
  const authResult = auth(req);
7
  if (authResult.error) {
 
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { auth } from "../../auth";
3
 
4
+ export async function POST(req: NextRequest) {
5
  try {
6
  const authResult = auth(req);
7
  if (authResult.error) {
app/api/user/kami/route.ts CHANGED
@@ -1,7 +1,7 @@
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { auth } from "../../auth";
3
 
4
- export async function GET(req: NextRequest) {
5
  try {
6
  const authResult = auth(req);
7
  if (authResult.error) {
 
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { auth } from "../../auth";
3
 
4
+ export async function POST(req: NextRequest) {
5
  try {
6
  const authResult = auth(req);
7
  if (authResult.error) {
app/api/user/login/route.ts CHANGED
@@ -1,6 +1,6 @@
1
  import { NextRequest } from "next/server";
2
 
3
- export async function GET(req: NextRequest) {
4
  try {
5
  const admin=process.env.ADMIN
6
  const key=process.env.KEY
 
1
  import { NextRequest } from "next/server";
2
 
3
+ export async function POST(req: NextRequest) {
4
  try {
5
  const admin=process.env.ADMIN
6
  const key=process.env.KEY
app/api/user/mail/route.ts CHANGED
@@ -1,6 +1,6 @@
1
  import { NextRequest } from "next/server";
2
 
3
- export async function GET(req: NextRequest) {
4
  try {
5
  const admin=process.env.ADMIN
6
  const key=process.env.KEY
 
1
  import { NextRequest } from "next/server";
2
 
3
+ export async function POST(req: NextRequest) {
4
  try {
5
  const admin=process.env.ADMIN
6
  const key=process.env.KEY
app/api/user/register/route.ts CHANGED
@@ -1,6 +1,6 @@
1
  import { NextRequest } from "next/server";
2
 
3
- export async function GET(req: NextRequest) {
4
  try {
5
  const admin=process.env.ADMIN
6
  const key=process.env.KEY
 
1
  import { NextRequest } from "next/server";
2
 
3
+ export async function POST(req: NextRequest) {
4
  try {
5
  const admin=process.env.ADMIN
6
  const key=process.env.KEY
app/api/user/set/route.ts CHANGED
@@ -1,7 +1,7 @@
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { auth } from "../../auth";
3
 
4
- export async function GET(req: NextRequest) {
5
  try {
6
  const authResult = auth(req);
7
  if (authResult.error) {
 
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { auth } from "../../auth";
3
 
4
+ export async function POST(req: NextRequest) {
5
  try {
6
  const authResult = auth(req);
7
  if (authResult.error) {
app/api/user/sig/route.ts CHANGED
@@ -1,7 +1,7 @@
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { auth } from "../../auth";
3
 
4
- export async function GET(req: NextRequest) {
5
  try {
6
  const authResult = auth(req);
7
  if (authResult.error) {
 
1
  import { NextRequest, NextResponse } from "next/server";
2
  import { auth } from "../../auth";
3
 
4
+ export async function POST(req: NextRequest) {
5
  try {
6
  const authResult = auth(req);
7
  if (authResult.error) {
app/components/findpwd.tsx CHANGED
@@ -9,6 +9,7 @@ import { useState } from "react";
9
 
10
  export function FindPwd(){
11
  const [user, setUser] = useState("");
 
12
 
13
  const onUser = (text: string) => {
14
  setUser(text)
@@ -16,6 +17,10 @@ export function FindPwd(){
16
 
17
  function findpwd(){
18
  useUserStore.getState().findPwd(user)
 
 
 
 
19
  }
20
 
21
  return (
@@ -50,6 +55,7 @@ export function FindPwd(){
50
  <div>
51
  <IconButton
52
  text="找回密码"
 
53
  className={styles.loginButton}
54
  onClick={()=>{
55
  findpwd()
 
9
 
10
  export function FindPwd(){
11
  const [user, setUser] = useState("");
12
+ const [status, setStatus] = useState("");
13
 
14
  const onUser = (text: string) => {
15
  setUser(text)
 
17
 
18
  function findpwd(){
19
  useUserStore.getState().findPwd(user)
20
+ setStatus("false")
21
+ setTimeout(()=>{
22
+ setStatus("")
23
+ },4000)
24
  }
25
 
26
  return (
 
55
  <div>
56
  <IconButton
57
  text="找回密码"
58
+ disabled={!!status}
59
  className={styles.loginButton}
60
  onClick={()=>{
61
  findpwd()
app/components/login.tsx CHANGED
@@ -10,6 +10,7 @@ import { useState } from "react";
10
  export function Login(){
11
  const userStore=useUserStore()
12
  const [user, setUser] = useState("");
 
13
  const [password, setPassword] = useState("");
14
 
15
  const onUser = (text: string) => {
@@ -21,6 +22,10 @@ export function Login(){
21
 
22
  const loginTo=()=>{
23
  userStore.login(user,password)
 
 
 
 
24
  }
25
 
26
  return (
@@ -64,6 +69,7 @@ export function Login(){
64
  <div>
65
  <IconButton
66
  text="登录"
 
67
  className={styles.loginButton}
68
  onClick={()=>{
69
  loginTo()
 
10
  export function Login(){
11
  const userStore=useUserStore()
12
  const [user, setUser] = useState("");
13
+ const [status, setStatus] = useState("");
14
  const [password, setPassword] = useState("");
15
 
16
  const onUser = (text: string) => {
 
22
 
23
  const loginTo=()=>{
24
  userStore.login(user,password)
25
+ setStatus("false")
26
+ setTimeout(()=>{
27
+ setStatus("")
28
+ },4000)
29
  }
30
 
31
  return (
 
69
  <div>
70
  <IconButton
71
  text="登录"
72
+ disabled={!!status}
73
  className={styles.loginButton}
74
  onClick={()=>{
75
  loginTo()
app/components/register.tsx CHANGED
@@ -16,6 +16,7 @@ export function Register(){
16
  const [password, setPassword] = useState("");
17
  const [mail, setMail] = useState("");
18
  const [code, setCode] = useState("");
 
19
 
20
  const onUserName = (text: string) => {
21
  setUserName(text)
@@ -33,8 +34,12 @@ export function Register(){
33
  setCode(text)
34
  };
35
 
36
- const loginTo=()=>{
37
  userStore.register(userName,password,name,mail,code)
 
 
 
 
38
  }
39
 
40
  const getMailCode=()=>{
@@ -139,9 +144,10 @@ export function Register(){
139
  <div>
140
  <IconButton
141
  text="注册"
 
142
  className={styles.registerButton}
143
  onClick={()=>{
144
- loginTo()
145
  }}
146
  ></IconButton>
147
  </div>
 
16
  const [password, setPassword] = useState("");
17
  const [mail, setMail] = useState("");
18
  const [code, setCode] = useState("");
19
+ const [status, setStatus] = useState("");
20
 
21
  const onUserName = (text: string) => {
22
  setUserName(text)
 
34
  setCode(text)
35
  };
36
 
37
+ const registerTo=()=>{
38
  userStore.register(userName,password,name,mail,code)
39
+ setStatus("false")
40
+ setTimeout(()=>{
41
+ setStatus("")
42
+ },4000)
43
  }
44
 
45
  const getMailCode=()=>{
 
144
  <div>
145
  <IconButton
146
  text="注册"
147
+ disabled={!!status}
148
  className={styles.registerButton}
149
  onClick={()=>{
150
+ registerTo()
151
  }}
152
  ></IconButton>
153
  </div>
app/requests.ts CHANGED
@@ -175,7 +175,7 @@ export async function requestUsage() {
175
 
176
  function updateWallet() {
177
  fetch("/api/user/set?user="+useUserStore.getState().user+"&project=wallet&projectName=num&data=1",{
178
- method:"GET",
179
  headers:{
180
  ...getHeaders()
181
  }
 
175
 
176
  function updateWallet() {
177
  fetch("/api/user/set?user="+useUserStore.getState().user+"&project=wallet&projectName=num&data=1",{
178
+ method:"POST",
179
  headers:{
180
  ...getHeaders()
181
  }
app/store/user.ts CHANGED
@@ -102,7 +102,7 @@ export const useUserStore = create<UserStore>()(
102
  },
103
  async updateName(name:string){
104
  let res=await fetch("/api/user/set?user="+get().user+"&project=name&projectName=name&data="+name,{
105
- method: "GET",
106
  headers:{
107
  ...getHeaders()
108
  }
@@ -122,7 +122,7 @@ export const useUserStore = create<UserStore>()(
122
  },
123
  async login(user, password) {
124
  let res=await fetch("/api/user/login?user="+user+"&password="+password,{
125
- method: "GET"
126
  });
127
  let response = await res.json() as shuixianRes
128
  console.log(response)
@@ -130,7 +130,10 @@ export const useUserStore = create<UserStore>()(
130
  useUserStore.getState().updateUser(user)
131
  useUserStore.getState().updatePassword(password)
132
  useAccessStore.getState().updateAuth(response.token)
133
- window.location.href="/#/chat"
 
 
 
134
  await this.getUserInfo()
135
  }else{
136
  showToast(response.msg)
@@ -138,20 +141,22 @@ export const useUserStore = create<UserStore>()(
138
  },
139
  async register(user, password, name, mail, code) {
140
  let res=await fetch("/api/user/register?user="+user+"&password="+password+"&name="+name+"&mail="+mail+"&code="+code,{
141
- method: "GET"
142
  });
143
  let response = await res.json() as shuixianRes
144
  console.log(response)
145
  if(response.code=1){
146
  showToast(response.msg)
147
- window.location.href="/#/login"
 
 
148
  }else{
149
  showToast(response.msg)
150
  }
151
  },
152
  async getMailCode(user:string,mail:string) {
153
  let res=await fetch("/api/user/mail?user="+user+"&mail="+mail,{
154
- method: "GET"
155
  });
156
  let response = await res.json() as shuixianRes
157
  console.log(response)
@@ -159,7 +164,7 @@ export const useUserStore = create<UserStore>()(
159
  },
160
  async userSig() {
161
  let res=await fetch("/api/user/sig?user="+get().user+"&password="+get().password,{
162
- method: "GET",
163
  headers:{
164
  ...getHeaders()
165
  }
@@ -173,7 +178,7 @@ export const useUserStore = create<UserStore>()(
173
  },
174
  async getUserInfo() {
175
  let resdata=await fetch("/api/user/info?user="+get().user+"&password="+get().password,{
176
- method: "GET",
177
  headers:{
178
  ...getHeaders()
179
  }
@@ -184,7 +189,7 @@ export const useUserStore = create<UserStore>()(
184
  },
185
  async findPwd(user) {
186
  let res=await fetch("/api/user/findpwd?user="+user,{
187
- method: "GET",
188
  headers:{
189
  ...getHeaders()
190
  }
@@ -199,7 +204,7 @@ export const useUserStore = create<UserStore>()(
199
  },
200
  async useKami(code) {
201
  let res=await fetch("/api/user/kami?user="+get().user+"&password="+get().password+"&code="+code,{
202
- method: "GET",
203
  headers:{
204
  ...getHeaders()
205
  }
 
102
  },
103
  async updateName(name:string){
104
  let res=await fetch("/api/user/set?user="+get().user+"&project=name&projectName=name&data="+name,{
105
+ method: "POST",
106
  headers:{
107
  ...getHeaders()
108
  }
 
122
  },
123
  async login(user, password) {
124
  let res=await fetch("/api/user/login?user="+user+"&password="+password,{
125
+ method: "POST"
126
  });
127
  let response = await res.json() as shuixianRes
128
  console.log(response)
 
130
  useUserStore.getState().updateUser(user)
131
  useUserStore.getState().updatePassword(password)
132
  useAccessStore.getState().updateAuth(response.token)
133
+ showToast(response.msg)
134
+ setTimeout(()=>{
135
+ window.location.href="/#/chat"
136
+ },1000)
137
  await this.getUserInfo()
138
  }else{
139
  showToast(response.msg)
 
141
  },
142
  async register(user, password, name, mail, code) {
143
  let res=await fetch("/api/user/register?user="+user+"&password="+password+"&name="+name+"&mail="+mail+"&code="+code,{
144
+ method: "POST"
145
  });
146
  let response = await res.json() as shuixianRes
147
  console.log(response)
148
  if(response.code=1){
149
  showToast(response.msg)
150
+ setTimeout(()=>{
151
+ window.location.href="/#/login"
152
+ },1000)
153
  }else{
154
  showToast(response.msg)
155
  }
156
  },
157
  async getMailCode(user:string,mail:string) {
158
  let res=await fetch("/api/user/mail?user="+user+"&mail="+mail,{
159
+ method: "POST"
160
  });
161
  let response = await res.json() as shuixianRes
162
  console.log(response)
 
164
  },
165
  async userSig() {
166
  let res=await fetch("/api/user/sig?user="+get().user+"&password="+get().password,{
167
+ method: "POST",
168
  headers:{
169
  ...getHeaders()
170
  }
 
178
  },
179
  async getUserInfo() {
180
  let resdata=await fetch("/api/user/info?user="+get().user+"&password="+get().password,{
181
+ method: "POST",
182
  headers:{
183
  ...getHeaders()
184
  }
 
189
  },
190
  async findPwd(user) {
191
  let res=await fetch("/api/user/findpwd?user="+user,{
192
+ method: "POST",
193
  headers:{
194
  ...getHeaders()
195
  }
 
204
  },
205
  async useKami(code) {
206
  let res=await fetch("/api/user/kami?user="+get().user+"&password="+get().password+"&code="+code,{
207
+ method: "POST",
208
  headers:{
209
  ...getHeaders()
210
  }