Spaces:
Running
Running
muxi feng
commited on
Commit
·
3283b52
1
Parent(s):
013ade0
修复编译问题
Browse files- app/api/user/info/route.ts +1 -1
- app/components/login.tsx +2 -1
- app/components/user.tsx +2 -1
- app/store/user.ts +17 -10
app/api/user/info/route.ts
CHANGED
@@ -21,7 +21,7 @@ export async function POST(req: NextRequest) {
|
|
21 |
flag:false,
|
22 |
msg:"未登录!"
|
23 |
}
|
24 |
-
|
25 |
return new Response(JSON.stringify(msg))
|
26 |
}
|
27 |
let msg=await res.json()
|
|
|
21 |
flag:false,
|
22 |
msg:"未登录!"
|
23 |
}
|
24 |
+
console.log(res.status)
|
25 |
return new Response(JSON.stringify(msg))
|
26 |
}
|
27 |
let msg=await res.json()
|
app/components/login.tsx
CHANGED
@@ -6,6 +6,7 @@ import { IconButton } from "./button";
|
|
6 |
import { useUserStore } from "../store";
|
7 |
import { useEffect, useState } from "react";
|
8 |
import Image from 'next/image'
|
|
|
9 |
|
10 |
|
11 |
export function Login(){
|
@@ -28,7 +29,7 @@ export function Login(){
|
|
28 |
|
29 |
const loginTo=async ()=>{
|
30 |
setStatus("false")
|
31 |
-
await userStore.login(user,password,code)
|
32 |
setTimeout(()=>{
|
33 |
setStatus("")
|
34 |
},4000)
|
|
|
6 |
import { useUserStore } from "../store";
|
7 |
import { useEffect, useState } from "react";
|
8 |
import Image from 'next/image'
|
9 |
+
import { encrypt } from "../rsaEncrypt";
|
10 |
|
11 |
|
12 |
export function Login(){
|
|
|
29 |
|
30 |
const loginTo=async ()=>{
|
31 |
setStatus("false")
|
32 |
+
await userStore.login(user,String(encrypt(password)),code)
|
33 |
setTimeout(()=>{
|
34 |
setStatus("")
|
35 |
},4000)
|
app/components/user.tsx
CHANGED
@@ -16,6 +16,7 @@ import { ErrorBoundary } from "./error";
|
|
16 |
import { useNavigate } from "react-router-dom";
|
17 |
import { Avatar, AvatarPicker } from "./emoji";
|
18 |
import { useUserStore } from "../store/user";
|
|
|
19 |
|
20 |
function UserPwdModal(props: { onClose?: () => void }) {
|
21 |
const useStor = useUserStore()
|
@@ -32,7 +33,7 @@ function UserPwdModal(props: { onClose?: () => void }) {
|
|
32 |
showToast("新密码与旧密码一致!")
|
33 |
return false
|
34 |
}
|
35 |
-
await useStor.updatePass(oldPwd,newPwd)
|
36 |
}
|
37 |
|
38 |
return (
|
|
|
16 |
import { useNavigate } from "react-router-dom";
|
17 |
import { Avatar, AvatarPicker } from "./emoji";
|
18 |
import { useUserStore } from "../store/user";
|
19 |
+
import { encrypt } from "../rsaEncrypt";
|
20 |
|
21 |
function UserPwdModal(props: { onClose?: () => void }) {
|
22 |
const useStor = useUserStore()
|
|
|
33 |
showToast("新密码与旧密码一致!")
|
34 |
return false
|
35 |
}
|
36 |
+
await useStor.updatePass(String(encrypt(oldPwd)),String(encrypt(newPwd)))
|
37 |
}
|
38 |
|
39 |
return (
|
app/store/user.ts
CHANGED
@@ -4,7 +4,6 @@ import { StoreKey } from "../constant";
|
|
4 |
import { showToast } from "../components/ui-lib";
|
5 |
import { useAccessStore } from "./access";
|
6 |
import { getHeaders } from "../requests";
|
7 |
-
import { encrypt } from "../rsaEncrypt";
|
8 |
|
9 |
export interface shuixianRes {
|
10 |
code: number;
|
@@ -31,9 +30,19 @@ function getLogin(){
|
|
31 |
}
|
32 |
|
33 |
export interface eladminRes {
|
34 |
-
data:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
flag:boolean;
|
36 |
msg:string;
|
|
|
37 |
}
|
38 |
|
39 |
export interface codeRes {
|
@@ -176,11 +185,9 @@ export const useUserStore = create<UserStore>()(
|
|
176 |
set(() => ({ wallet: get().wallet - wallet }));
|
177 |
},
|
178 |
async login(user, password,code) {
|
179 |
-
let enPassword=encrypt(password);
|
180 |
-
console.log(enPassword)
|
181 |
let body={
|
182 |
"username": user,
|
183 |
-
"password":
|
184 |
"code": code,
|
185 |
"uuid": get().uuid
|
186 |
}
|
@@ -356,8 +363,8 @@ export const useUserStore = create<UserStore>()(
|
|
356 |
},
|
357 |
async updatePass(oldPass,newPass){
|
358 |
let body={
|
359 |
-
oldPass:
|
360 |
-
newPass:
|
361 |
}
|
362 |
let res=await fetch(
|
363 |
"/api/user/updatePass",
|
@@ -370,11 +377,11 @@ export const useUserStore = create<UserStore>()(
|
|
370 |
body:JSON.stringify(body)
|
371 |
},
|
372 |
);
|
373 |
-
|
374 |
-
if(
|
375 |
showToast("修改成功!")
|
376 |
}else{
|
377 |
-
showToast(
|
378 |
}
|
379 |
}
|
380 |
}),
|
|
|
4 |
import { showToast } from "../components/ui-lib";
|
5 |
import { useAccessStore } from "./access";
|
6 |
import { getHeaders } from "../requests";
|
|
|
7 |
|
8 |
export interface shuixianRes {
|
9 |
code: number;
|
|
|
30 |
}
|
31 |
|
32 |
export interface eladminRes {
|
33 |
+
data:{
|
34 |
+
user:object;
|
35 |
+
token:string;
|
36 |
+
nickName:string;
|
37 |
+
wallet:number;
|
38 |
+
vipTime:string;
|
39 |
+
email:string;
|
40 |
+
sigState:string;
|
41 |
+
head:string;
|
42 |
+
};
|
43 |
flag:boolean;
|
44 |
msg:string;
|
45 |
+
message:string;
|
46 |
}
|
47 |
|
48 |
export interface codeRes {
|
|
|
185 |
set(() => ({ wallet: get().wallet - wallet }));
|
186 |
},
|
187 |
async login(user, password,code) {
|
|
|
|
|
188 |
let body={
|
189 |
"username": user,
|
190 |
+
"password": password,
|
191 |
"code": code,
|
192 |
"uuid": get().uuid
|
193 |
}
|
|
|
363 |
},
|
364 |
async updatePass(oldPass,newPass){
|
365 |
let body={
|
366 |
+
oldPass:oldPass,
|
367 |
+
newPass:newPass
|
368 |
}
|
369 |
let res=await fetch(
|
370 |
"/api/user/updatePass",
|
|
|
377 |
body:JSON.stringify(body)
|
378 |
},
|
379 |
);
|
380 |
+
let ress=(await res.json()) as eladminRes
|
381 |
+
if(ress.message==null){
|
382 |
showToast("修改成功!")
|
383 |
}else{
|
384 |
+
showToast(ress.message)
|
385 |
}
|
386 |
}
|
387 |
}),
|