Spaces:
Running
Running
muxi feng
commited on
Commit
·
28f2243
1
Parent(s):
47eb5bf
增加登出接口和其他的配置
Browse files- app/api/user/findpwd/route.ts +5 -10
- app/api/user/logout/route.ts +34 -0
- app/api/user/restmail/route.ts +16 -0
- app/api/user/sig/route.ts +1 -1
- app/api/user/updatePass/route.ts +36 -0
- app/api/user/vip/route.ts +1 -1
- app/components/findpwd.module.scss +32 -3
- app/components/findpwd.tsx +60 -9
- app/components/login.module.scss +4 -4
- app/components/login.tsx +1 -1
- app/components/register.module.scss +4 -4
- app/components/user.tsx +91 -7
- app/locales/cn.ts +8 -1
- app/locales/de.ts +8 -1
- app/locales/en.ts +8 -1
- app/locales/es.ts +8 -1
- app/locales/it.ts +8 -1
- app/locales/jp.ts +8 -1
- app/locales/tr.ts +8 -1
- app/locales/tw.ts +8 -1
- app/store/user.ts +57 -7
app/api/user/findpwd/route.ts
CHANGED
@@ -2,21 +2,16 @@ import { NextRequest } from "next/server";
|
|
2 |
|
3 |
export async function POST(req: NextRequest) {
|
4 |
try {
|
5 |
-
const
|
6 |
-
const
|
7 |
-
|
8 |
-
|
9 |
-
let res=await fetch("https://dujiaoka.dwzynj.top/main/api/user/find_password.php?admin="+admin+"&key="+key+"&user="+user, {
|
10 |
-
method: "GET",
|
11 |
-
headers:{
|
12 |
-
"token":token
|
13 |
-
},
|
14 |
})
|
15 |
let msg=await res.json()
|
16 |
// console.log(msg)
|
17 |
return new Response(JSON.stringify(msg))
|
18 |
} catch (e) {
|
19 |
-
console.error("[
|
20 |
return new Response(JSON.stringify(e));
|
21 |
}
|
22 |
}
|
|
|
2 |
|
3 |
export async function POST(req: NextRequest) {
|
4 |
try {
|
5 |
+
const mail=req.nextUrl.searchParams.get("mail")
|
6 |
+
const code=req.nextUrl.searchParams.get("code")
|
7 |
+
let res=await fetch("https://eladmin.dwzynj.top/api/users/restPwd?mail="+mail+"&code="+code, {
|
8 |
+
method: "POST"
|
|
|
|
|
|
|
|
|
|
|
9 |
})
|
10 |
let msg=await res.json()
|
11 |
// console.log(msg)
|
12 |
return new Response(JSON.stringify(msg))
|
13 |
} catch (e) {
|
14 |
+
console.error("[eladmin] ", e);
|
15 |
return new Response(JSON.stringify(e));
|
16 |
}
|
17 |
}
|
app/api/user/logout/route.ts
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
8 |
+
return NextResponse.json(authResult, {
|
9 |
+
status: 401,
|
10 |
+
});
|
11 |
+
}
|
12 |
+
const token=req.headers.get("auth") ?? ""
|
13 |
+
let res=await fetch("https://eladmin.dwzynj.top/auth/logout", {
|
14 |
+
method: "DELETE",
|
15 |
+
headers:{
|
16 |
+
"Authorization":token
|
17 |
+
}
|
18 |
+
})
|
19 |
+
if(res.status==401){
|
20 |
+
let msg={
|
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()
|
28 |
+
console.log(msg)
|
29 |
+
return new Response(JSON.stringify(msg))
|
30 |
+
} catch (e) {
|
31 |
+
console.error("[eladmin] ", e);
|
32 |
+
return new Response(JSON.stringify(e));
|
33 |
+
}
|
34 |
+
}
|
app/api/user/restmail/route.ts
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { NextRequest } from "next/server";
|
2 |
+
|
3 |
+
export async function POST(req: NextRequest) {
|
4 |
+
try {
|
5 |
+
const mail=req.nextUrl.searchParams.get("mail")
|
6 |
+
let res=await fetch("https://eladmin.dwzynj.top/api/code/email/resetPass?email="+mail, {
|
7 |
+
method: "POST"
|
8 |
+
})
|
9 |
+
let msg=await res.json()
|
10 |
+
// console.log(res.status)
|
11 |
+
return new Response(JSON.stringify(msg))
|
12 |
+
} catch (e) {
|
13 |
+
console.error("[eladmin] ", e);
|
14 |
+
return new Response(JSON.stringify(e));
|
15 |
+
}
|
16 |
+
}
|
app/api/user/sig/route.ts
CHANGED
@@ -28,7 +28,7 @@ export async function POST(req: NextRequest) {
|
|
28 |
// console.log(msg)
|
29 |
return new Response(JSON.stringify(msg))
|
30 |
} catch (e) {
|
31 |
-
console.error("[
|
32 |
return new Response(JSON.stringify(e));
|
33 |
}
|
34 |
}
|
|
|
28 |
// console.log(msg)
|
29 |
return new Response(JSON.stringify(msg))
|
30 |
} catch (e) {
|
31 |
+
console.error("[eladmin] ", e);
|
32 |
return new Response(JSON.stringify(e));
|
33 |
}
|
34 |
}
|
app/api/user/updatePass/route.ts
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
8 |
+
return NextResponse.json(authResult, {
|
9 |
+
status: 401,
|
10 |
+
});
|
11 |
+
}
|
12 |
+
const token=req.headers.get("auth") ?? ""
|
13 |
+
let res=await fetch("https://eladmin.dwzynj.top/api/users/updatePass", {
|
14 |
+
method: "POST",
|
15 |
+
headers:{
|
16 |
+
"Content-Type":'application/json;charset=utf-8',
|
17 |
+
"Authorization":token
|
18 |
+
},
|
19 |
+
body:JSON.stringify(await req.json())
|
20 |
+
})
|
21 |
+
if(res.status==401){
|
22 |
+
let msg={
|
23 |
+
flag:false,
|
24 |
+
message:"未登录!"
|
25 |
+
}
|
26 |
+
// console.log(res.status)
|
27 |
+
return new Response(JSON.stringify(msg))
|
28 |
+
}
|
29 |
+
let msg=await res.json()
|
30 |
+
// console.log(msg)
|
31 |
+
return new Response(JSON.stringify(msg))
|
32 |
+
} catch (e) {
|
33 |
+
console.error("[eladmin] ", e);
|
34 |
+
return new Response(JSON.stringify(e));
|
35 |
+
}
|
36 |
+
}
|
app/api/user/vip/route.ts
CHANGED
@@ -28,7 +28,7 @@ export async function POST(req: NextRequest) {
|
|
28 |
console.log(msg)
|
29 |
return new Response(JSON.stringify(msg))
|
30 |
} catch (e) {
|
31 |
-
console.error("[
|
32 |
return new Response(JSON.stringify(e));
|
33 |
}
|
34 |
}
|
|
|
28 |
console.log(msg)
|
29 |
return new Response(JSON.stringify(msg))
|
30 |
} catch (e) {
|
31 |
+
console.error("[eladmin] ", e);
|
32 |
return new Response(JSON.stringify(e));
|
33 |
}
|
34 |
}
|
app/components/findpwd.module.scss
CHANGED
@@ -55,12 +55,12 @@
|
|
55 |
}
|
56 |
|
57 |
.wangji{
|
58 |
-
padding-right:
|
59 |
font-size: 12px;
|
60 |
}
|
61 |
|
62 |
.zhuce{
|
63 |
-
padding-left:
|
64 |
font-size: 12px;
|
65 |
}
|
66 |
|
@@ -68,7 +68,36 @@
|
|
68 |
background-color: #1db144;
|
69 |
color: white;
|
70 |
padding: 0;
|
71 |
-
width:
|
72 |
display: block;
|
73 |
margin: 0 auto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
}
|
|
|
55 |
}
|
56 |
|
57 |
.wangji{
|
58 |
+
padding-right: 60px;
|
59 |
font-size: 12px;
|
60 |
}
|
61 |
|
62 |
.zhuce{
|
63 |
+
padding-left: 60px;
|
64 |
font-size: 12px;
|
65 |
}
|
66 |
|
|
|
68 |
background-color: #1db144;
|
69 |
color: white;
|
70 |
padding: 0;
|
71 |
+
width: 183px;
|
72 |
display: block;
|
73 |
margin: 0 auto;
|
74 |
+
}
|
75 |
+
|
76 |
+
.code{
|
77 |
+
border: var(--border-in-light);
|
78 |
+
padding: 10px;
|
79 |
+
margin-right: 10px;
|
80 |
+
border-radius: 10px;
|
81 |
+
-webkit-appearance: none;
|
82 |
+
-moz-appearance: none;
|
83 |
+
appearance: none;
|
84 |
+
cursor: pointer;
|
85 |
+
background-color: var(--white);
|
86 |
+
color: var(--black);
|
87 |
+
text-align: left;
|
88 |
+
width: 60px;
|
89 |
+
}
|
90 |
+
|
91 |
+
.codebox{
|
92 |
+
vertical-align: bottom;
|
93 |
+
}
|
94 |
+
|
95 |
+
.codeButton{
|
96 |
+
background-color: #1db144;
|
97 |
+
color: white;
|
98 |
+
padding: 0;
|
99 |
+
width: 93px;
|
100 |
+
display: inline;
|
101 |
+
margin: 0 auto;
|
102 |
+
font-size: 8px;
|
103 |
}
|
app/components/findpwd.tsx
CHANGED
@@ -4,25 +4,59 @@ import ChatIcon from "../icons/chatgpt.svg"
|
|
4 |
import styles from "./findpwd.module.scss";
|
5 |
import { IconButton } from "./button";
|
6 |
import { useUserStore } from "../store";
|
7 |
-
import { useState } from "react";
|
8 |
|
9 |
|
10 |
export function FindPwd(){
|
11 |
-
const
|
|
|
12 |
const [status, setStatus] = useState("");
|
|
|
|
|
|
|
13 |
|
14 |
-
const
|
15 |
-
|
16 |
};
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
20 |
setStatus("false")
|
|
|
21 |
setTimeout(()=>{
|
22 |
setStatus("")
|
23 |
},4000)
|
24 |
}
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return (
|
27 |
<ErrorBoundary>
|
28 |
<div className="window-header">
|
@@ -43,10 +77,27 @@ export function FindPwd(){
|
|
43 |
<input
|
44 |
type="input"
|
45 |
className={styles.name}
|
46 |
-
placeholder={Locale.User.
|
47 |
-
onInput={(e) =>
|
48 |
-
value={
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
></input>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
</div>
|
51 |
<div>
|
52 |
<span className={styles.wangji}><a href="/#/login">{Locale.User.Login}</a></span>
|
|
|
4 |
import styles from "./findpwd.module.scss";
|
5 |
import { IconButton } from "./button";
|
6 |
import { useUserStore } from "../store";
|
7 |
+
import { useEffect, useState } from "react";
|
8 |
|
9 |
|
10 |
export function FindPwd(){
|
11 |
+
const userStore=useUserStore()
|
12 |
+
const [email, setEmail] = useState("");
|
13 |
const [status, setStatus] = useState("");
|
14 |
+
const [code, setCode] = useState("");
|
15 |
+
const [codeStatus, setcodeStatus] = useState("");
|
16 |
+
const [getcode, setgetcode] = useState("");
|
17 |
|
18 |
+
const onEmail = (text: string) => {
|
19 |
+
setEmail(text)
|
20 |
};
|
21 |
|
22 |
+
const onCode = (text: string) => {
|
23 |
+
setCode(text)
|
24 |
+
};
|
25 |
+
|
26 |
+
async function findpwd(){
|
27 |
setStatus("false")
|
28 |
+
await useUserStore.getState().findPwd(email,code)
|
29 |
setTimeout(()=>{
|
30 |
setStatus("")
|
31 |
},4000)
|
32 |
}
|
33 |
|
34 |
+
const getMailCode=()=>{
|
35 |
+
userStore.getRestPwdCode(email)
|
36 |
+
getCode()
|
37 |
+
}
|
38 |
+
var countdown=60;
|
39 |
+
const getCode=()=>{
|
40 |
+
if (countdown == 0) {
|
41 |
+
setcodeStatus("")
|
42 |
+
setgetcode("发送验证码")
|
43 |
+
countdown = 60;
|
44 |
+
return;
|
45 |
+
} else {
|
46 |
+
setcodeStatus("true")
|
47 |
+
setgetcode("(" + countdown + ")")
|
48 |
+
countdown--;
|
49 |
+
}
|
50 |
+
setTimeout(function() {
|
51 |
+
getCode() }
|
52 |
+
,1000)
|
53 |
+
}
|
54 |
+
|
55 |
+
useEffect(()=>{
|
56 |
+
setcodeStatus("")
|
57 |
+
setgetcode("发送验证码")
|
58 |
+
},[])
|
59 |
+
|
60 |
return (
|
61 |
<ErrorBoundary>
|
62 |
<div className="window-header">
|
|
|
77 |
<input
|
78 |
type="input"
|
79 |
className={styles.name}
|
80 |
+
placeholder={Locale.User.Email}
|
81 |
+
onInput={(e) => onEmail(e.currentTarget.value)}
|
82 |
+
value={email}
|
83 |
+
></input>
|
84 |
+
</div>
|
85 |
+
<div className={styles.codebox}>
|
86 |
+
<input
|
87 |
+
type="input"
|
88 |
+
className={styles.code}
|
89 |
+
placeholder={Locale.User.Code}
|
90 |
+
onInput={(e) => onCode(e.currentTarget.value)}
|
91 |
+
value={code}
|
92 |
></input>
|
93 |
+
<IconButton
|
94 |
+
disabled={!!codeStatus}
|
95 |
+
text={getcode}
|
96 |
+
className={styles.codeButton}
|
97 |
+
onClick={()=>{
|
98 |
+
getMailCode()
|
99 |
+
}}
|
100 |
+
></IconButton>
|
101 |
</div>
|
102 |
<div>
|
103 |
<span className={styles.wangji}><a href="/#/login">{Locale.User.Login}</a></span>
|
app/components/login.module.scss
CHANGED
@@ -24,7 +24,7 @@
|
|
24 |
-moz-appearance: none;
|
25 |
appearance: none;
|
26 |
cursor: pointer;
|
27 |
-
width:
|
28 |
background-color: var(--white);
|
29 |
color: var(--black);
|
30 |
text-align: left;
|
@@ -74,12 +74,12 @@
|
|
74 |
}
|
75 |
|
76 |
.wangji{
|
77 |
-
padding-right:
|
78 |
font-size: 12px;
|
79 |
}
|
80 |
|
81 |
.zhuce{
|
82 |
-
padding-left:
|
83 |
font-size: 12px;
|
84 |
}
|
85 |
|
@@ -87,7 +87,7 @@
|
|
87 |
background-color: #1db144;
|
88 |
color: white;
|
89 |
padding: 0;
|
90 |
-
width:
|
91 |
display: block;
|
92 |
margin: 0 auto;
|
93 |
}
|
|
|
24 |
-moz-appearance: none;
|
25 |
appearance: none;
|
26 |
cursor: pointer;
|
27 |
+
width: 80px;
|
28 |
background-color: var(--white);
|
29 |
color: var(--black);
|
30 |
text-align: left;
|
|
|
74 |
}
|
75 |
|
76 |
.wangji{
|
77 |
+
padding-right: 50px;
|
78 |
font-size: 12px;
|
79 |
}
|
80 |
|
81 |
.zhuce{
|
82 |
+
padding-left: 50px;
|
83 |
font-size: 12px;
|
84 |
}
|
85 |
|
|
|
87 |
background-color: #1db144;
|
88 |
color: white;
|
89 |
padding: 0;
|
90 |
+
width: 183px;
|
91 |
display: block;
|
92 |
margin: 0 auto;
|
93 |
}
|
app/components/login.tsx
CHANGED
@@ -27,8 +27,8 @@ export function Login(){
|
|
27 |
};
|
28 |
|
29 |
const loginTo=async ()=>{
|
30 |
-
await userStore.login(user,password,code)
|
31 |
setStatus("false")
|
|
|
32 |
setTimeout(()=>{
|
33 |
setStatus("")
|
34 |
},4000)
|
|
|
27 |
};
|
28 |
|
29 |
const loginTo=async ()=>{
|
|
|
30 |
setStatus("false")
|
31 |
+
await userStore.login(user,password,code)
|
32 |
setTimeout(()=>{
|
33 |
setStatus("")
|
34 |
},4000)
|
app/components/register.module.scss
CHANGED
@@ -23,7 +23,7 @@
|
|
23 |
background-color: var(--white);
|
24 |
color: var(--black);
|
25 |
text-align: left;
|
26 |
-
width:
|
27 |
}
|
28 |
|
29 |
.codebox{
|
@@ -74,12 +74,12 @@
|
|
74 |
}
|
75 |
|
76 |
.wangji{
|
77 |
-
padding-right:
|
78 |
font-size: 12px;
|
79 |
}
|
80 |
|
81 |
.zhuce{
|
82 |
-
padding-left:
|
83 |
font-size: 12px;
|
84 |
}
|
85 |
|
@@ -87,7 +87,7 @@
|
|
87 |
background-color: #1db144;
|
88 |
color: white;
|
89 |
padding: 0;
|
90 |
-
width:
|
91 |
display: block;
|
92 |
margin: 0 auto;
|
93 |
}
|
|
|
23 |
background-color: var(--white);
|
24 |
color: var(--black);
|
25 |
text-align: left;
|
26 |
+
width: 60px;
|
27 |
}
|
28 |
|
29 |
.codebox{
|
|
|
74 |
}
|
75 |
|
76 |
.wangji{
|
77 |
+
padding-right: 50px;
|
78 |
font-size: 12px;
|
79 |
}
|
80 |
|
81 |
.zhuce{
|
82 |
+
padding-left: 50px;
|
83 |
font-size: 12px;
|
84 |
}
|
85 |
|
|
|
87 |
background-color: #1db144;
|
88 |
color: white;
|
89 |
padding: 0;
|
90 |
+
width: 183px;
|
91 |
display: block;
|
92 |
margin: 0 auto;
|
93 |
}
|
app/components/user.tsx
CHANGED
@@ -2,7 +2,7 @@ import { useState, useEffect } from "react";
|
|
2 |
|
3 |
import styles from "./user.module.scss";
|
4 |
import EditIcon from "../icons/edit.svg";
|
5 |
-
import { List, ListItem, Popover, showModal, showToast } from "./ui-lib";
|
6 |
|
7 |
import { IconButton } from "./button";
|
8 |
import {
|
@@ -16,11 +16,84 @@ 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 |
|
21 |
export function User() {
|
22 |
const navigate = useNavigate();
|
23 |
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
|
|
|
24 |
const config = useAppConfig();
|
25 |
const updateConfig = config.update;
|
26 |
|
@@ -164,7 +237,6 @@ export function User() {
|
|
164 |
|
165 |
<ListItem title="充值">
|
166 |
<IconButton
|
167 |
-
icon={<EditIcon />}
|
168 |
text="购买卡密"
|
169 |
onClick={()=>{
|
170 |
window.location.href="https://qtka.scgzfw.cn/links/879AEC7D"
|
@@ -174,7 +246,6 @@ export function User() {
|
|
174 |
|
175 |
<ListItem title={Locale.User.SigState}>
|
176 |
<IconButton
|
177 |
-
icon={<EditIcon />}
|
178 |
disabled={!accessStore.auth}
|
179 |
text="签到(送积分)"
|
180 |
onClick={()=>{
|
@@ -182,6 +253,15 @@ export function User() {
|
|
182 |
}}
|
183 |
/>
|
184 |
</ListItem>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
</List>
|
186 |
|
187 |
<List>
|
@@ -191,14 +271,18 @@ export function User() {
|
|
191 |
disabled={!accessStore.auth}
|
192 |
text="登出"
|
193 |
onClick={()=>{
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
197 |
showToast("登出成功!")
|
198 |
}}
|
199 |
/>
|
200 |
</ListItem>
|
201 |
</List>
|
|
|
|
|
|
|
202 |
</div>
|
203 |
</ErrorBoundary>
|
204 |
);
|
|
|
2 |
|
3 |
import styles from "./user.module.scss";
|
4 |
import EditIcon from "../icons/edit.svg";
|
5 |
+
import { List, ListItem, Modal, Popover, showModal, showToast } from "./ui-lib";
|
6 |
|
7 |
import { IconButton } from "./button";
|
8 |
import {
|
|
|
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()
|
22 |
+
const [oldPwd, setOldPwd] = useState('');
|
23 |
+
const [newPwd, setNewPwd] = useState('');
|
24 |
+
const [newPwd1, setNewPwd1] = useState('');
|
25 |
+
|
26 |
+
async function updatePass():Promise<any>{
|
27 |
+
if(newPwd!=newPwd1){
|
28 |
+
showToast("两次输入的新密码不一致!")
|
29 |
+
return false
|
30 |
+
}
|
31 |
+
if(oldPwd==newPwd1||oldPwd==newPwd){
|
32 |
+
showToast("新密码与旧密码一致!")
|
33 |
+
return false
|
34 |
+
}
|
35 |
+
await useStor.updatePass(oldPwd,newPwd)
|
36 |
+
}
|
37 |
+
|
38 |
+
return (
|
39 |
+
<div className="modal-mask">
|
40 |
+
<Modal
|
41 |
+
title={Locale.User.Pass.Title}
|
42 |
+
onClose={() => props.onClose?.()}
|
43 |
+
actions={[
|
44 |
+
<IconButton
|
45 |
+
key="add"
|
46 |
+
icon={<EditIcon />}
|
47 |
+
onClick={()=>{
|
48 |
+
updatePass().then(()=>{
|
49 |
+
props.onClose?.()
|
50 |
+
})
|
51 |
+
}}
|
52 |
+
bordered
|
53 |
+
text={Locale.User.Save}
|
54 |
+
/>,
|
55 |
+
]}
|
56 |
+
>
|
57 |
+
<div>
|
58 |
+
<List>
|
59 |
+
<ListItem title={Locale.User.Pass.OldPwd}>
|
60 |
+
<input
|
61 |
+
type="password"
|
62 |
+
className={styles.kamicode}
|
63 |
+
value={oldPwd}
|
64 |
+
onChange={(e)=>{setOldPwd(e.currentTarget.value)}}
|
65 |
+
>
|
66 |
+
</input>
|
67 |
+
</ListItem>
|
68 |
+
<ListItem title={Locale.User.Pass.NewPwd}>
|
69 |
+
<input
|
70 |
+
type="password"
|
71 |
+
className={styles.kamicode}
|
72 |
+
value={newPwd}
|
73 |
+
onChange={(e)=>{setNewPwd(e.currentTarget.value)}}
|
74 |
+
>
|
75 |
+
</input>
|
76 |
+
</ListItem>
|
77 |
+
<ListItem title={Locale.User.Pass.NewPwd1}>
|
78 |
+
<input
|
79 |
+
type="password"
|
80 |
+
className={styles.kamicode}
|
81 |
+
value={newPwd1}
|
82 |
+
onChange={(e)=>{setNewPwd1(e.currentTarget.value)}}
|
83 |
+
>
|
84 |
+
</input>
|
85 |
+
</ListItem>
|
86 |
+
</List>
|
87 |
+
</div>
|
88 |
+
</Modal>
|
89 |
+
</div>
|
90 |
+
);
|
91 |
+
}
|
92 |
|
93 |
export function User() {
|
94 |
const navigate = useNavigate();
|
95 |
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
|
96 |
+
const [shouldShowPwdModal, setShowPwdModal] = useState(false);
|
97 |
const config = useAppConfig();
|
98 |
const updateConfig = config.update;
|
99 |
|
|
|
237 |
|
238 |
<ListItem title="充值">
|
239 |
<IconButton
|
|
|
240 |
text="购买卡密"
|
241 |
onClick={()=>{
|
242 |
window.location.href="https://qtka.scgzfw.cn/links/879AEC7D"
|
|
|
246 |
|
247 |
<ListItem title={Locale.User.SigState}>
|
248 |
<IconButton
|
|
|
249 |
disabled={!accessStore.auth}
|
250 |
text="签到(送积分)"
|
251 |
onClick={()=>{
|
|
|
253 |
}}
|
254 |
/>
|
255 |
</ListItem>
|
256 |
+
<ListItem title={Locale.User.Pass.Title}>
|
257 |
+
<IconButton
|
258 |
+
disabled={!accessStore.auth}
|
259 |
+
text={Locale.User.Pass.Title}
|
260 |
+
onClick={()=>{
|
261 |
+
setShowPwdModal(true)
|
262 |
+
}}
|
263 |
+
/>
|
264 |
+
</ListItem>
|
265 |
</List>
|
266 |
|
267 |
<List>
|
|
|
271 |
disabled={!accessStore.auth}
|
272 |
text="登出"
|
273 |
onClick={()=>{
|
274 |
+
useStor.logOut().then(()=>{
|
275 |
+
accessStore.updateAuth("")
|
276 |
+
setUserName("")
|
277 |
+
})
|
278 |
showToast("登出成功!")
|
279 |
}}
|
280 |
/>
|
281 |
</ListItem>
|
282 |
</List>
|
283 |
+
{shouldShowPwdModal && (
|
284 |
+
<UserPwdModal onClose={() => setShowPwdModal(false)} />
|
285 |
+
)}
|
286 |
</div>
|
287 |
</ErrorBoundary>
|
288 |
);
|
app/locales/cn.ts
CHANGED
@@ -76,7 +76,14 @@ const cn = {
|
|
76 |
User:"账号(纯数字)",
|
77 |
Password:"密码(最少六位)",
|
78 |
Email:"邮箱",
|
79 |
-
Code:"验证码"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
},
|
81 |
Settings: {
|
82 |
Title: "设置",
|
|
|
76 |
User:"账号(纯数字)",
|
77 |
Password:"密码(最少六位)",
|
78 |
Email:"邮箱",
|
79 |
+
Code:"验证码",
|
80 |
+
Pass:{
|
81 |
+
Title:"修改密码",
|
82 |
+
OldPwd:"旧密码",
|
83 |
+
NewPwd:"新密码",
|
84 |
+
NewPwd1:"确认密码"
|
85 |
+
},
|
86 |
+
Save:"保存"
|
87 |
},
|
88 |
Settings: {
|
89 |
Title: "设置",
|
app/locales/de.ts
CHANGED
@@ -78,7 +78,14 @@ const de: LocaleType = {
|
|
78 |
User:"Kontonummer (nur Nummern)",
|
79 |
Password:"Passwort (mindestens 6-stellig)",
|
80 |
Email:"Briefkasten",
|
81 |
-
Code:"Captcha"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
},
|
83 |
Settings: {
|
84 |
Title: "Einstellungen",
|
|
|
78 |
User:"Kontonummer (nur Nummern)",
|
79 |
Password:"Passwort (mindestens 6-stellig)",
|
80 |
Email:"Briefkasten",
|
81 |
+
Code:"Captcha",
|
82 |
+
Pass:{
|
83 |
+
Title:"修改密码",
|
84 |
+
OldPwd:"旧密码",
|
85 |
+
NewPwd:"新密码",
|
86 |
+
NewPwd1:"确认密码"
|
87 |
+
},
|
88 |
+
Save:"保存"
|
89 |
},
|
90 |
Settings: {
|
91 |
Title: "Einstellungen",
|
app/locales/en.ts
CHANGED
@@ -78,7 +78,14 @@ const en: LocaleType = {
|
|
78 |
User:"Account Number (Numbers Only)",
|
79 |
Password:"Password (minimum 6 digits)",
|
80 |
Email:"Email",
|
81 |
-
Code:"Captcha"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
},
|
83 |
Settings: {
|
84 |
Title: "Settings",
|
|
|
78 |
User:"Account Number (Numbers Only)",
|
79 |
Password:"Password (minimum 6 digits)",
|
80 |
Email:"Email",
|
81 |
+
Code:"Captcha",
|
82 |
+
Pass:{
|
83 |
+
Title:"Update Password",
|
84 |
+
OldPwd:"Old Password",
|
85 |
+
NewPwd:"New Password",
|
86 |
+
NewPwd1:"Check Password"
|
87 |
+
},
|
88 |
+
Save:"保存"
|
89 |
},
|
90 |
Settings: {
|
91 |
Title: "Settings",
|
app/locales/es.ts
CHANGED
@@ -78,7 +78,14 @@ const es: LocaleType = {
|
|
78 |
User:"Número de cuenta (solo números)",
|
79 |
Password:"Contraseña (mínimo 6 dígitos)",
|
80 |
Email:"Buzón",
|
81 |
-
Code:"Captcha"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
},
|
83 |
Settings: {
|
84 |
Title: "Configuración",
|
|
|
78 |
User:"Número de cuenta (solo números)",
|
79 |
Password:"Contraseña (mínimo 6 dígitos)",
|
80 |
Email:"Buzón",
|
81 |
+
Code:"Captcha",
|
82 |
+
Pass:{
|
83 |
+
Title:"修改密码",
|
84 |
+
OldPwd:"旧密码",
|
85 |
+
NewPwd:"新密码",
|
86 |
+
NewPwd1:"确认密码"
|
87 |
+
},
|
88 |
+
Save:"保存"
|
89 |
},
|
90 |
Settings: {
|
91 |
Title: "Configuración",
|
app/locales/it.ts
CHANGED
@@ -78,7 +78,14 @@ const it: LocaleType = {
|
|
78 |
User:"Numero di conto (solo numeri)",
|
79 |
Password:"Password (minimo 6 cifre)",
|
80 |
Email:"Cassetta Postale",
|
81 |
-
Code:"Captcha"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
},
|
83 |
Settings: {
|
84 |
Title: "Impostazioni",
|
|
|
78 |
User:"Numero di conto (solo numeri)",
|
79 |
Password:"Password (minimo 6 cifre)",
|
80 |
Email:"Cassetta Postale",
|
81 |
+
Code:"Captcha",
|
82 |
+
Pass:{
|
83 |
+
Title:"修改密码",
|
84 |
+
OldPwd:"旧密码",
|
85 |
+
NewPwd:"新密码",
|
86 |
+
NewPwd1:"确认密码"
|
87 |
+
},
|
88 |
+
Save:"保存"
|
89 |
},
|
90 |
Settings: {
|
91 |
Title: "Impostazioni",
|
app/locales/jp.ts
CHANGED
@@ -78,7 +78,14 @@ const jp: LocaleType = {
|
|
78 |
User:"口座番号(番号のみ)",
|
79 |
Password:"パスワード(最低6桁)",
|
80 |
Email:"メールボックス",
|
81 |
-
Code:"キャプチャ"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
},
|
83 |
Settings: {
|
84 |
Title: "設定",
|
|
|
78 |
User:"口座番号(番号のみ)",
|
79 |
Password:"パスワード(最低6桁)",
|
80 |
Email:"メールボックス",
|
81 |
+
Code:"キャプチャ",
|
82 |
+
Pass:{
|
83 |
+
Title:"修改密码",
|
84 |
+
OldPwd:"旧密码",
|
85 |
+
NewPwd:"新密码",
|
86 |
+
NewPwd1:"确认密码"
|
87 |
+
},
|
88 |
+
Save:"保存"
|
89 |
},
|
90 |
Settings: {
|
91 |
Title: "設定",
|
app/locales/tr.ts
CHANGED
@@ -78,7 +78,14 @@ const tr: LocaleType = {
|
|
78 |
User:"Hesap Numarası (Yalnızca Numaralar)",
|
79 |
Password:"Şifre (en az 6 haneli)",
|
80 |
Email:"Posta Kutusu",
|
81 |
-
Code:"Arjantin"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
},
|
83 |
Settings: {
|
84 |
Title: "Ayarlar",
|
|
|
78 |
User:"Hesap Numarası (Yalnızca Numaralar)",
|
79 |
Password:"Şifre (en az 6 haneli)",
|
80 |
Email:"Posta Kutusu",
|
81 |
+
Code:"Arjantin",
|
82 |
+
Pass:{
|
83 |
+
Title:"修改密码",
|
84 |
+
OldPwd:"旧密码",
|
85 |
+
NewPwd:"新密码",
|
86 |
+
NewPwd1:"确认密码"
|
87 |
+
},
|
88 |
+
Save:"保存"
|
89 |
},
|
90 |
Settings: {
|
91 |
Title: "Ayarlar",
|
app/locales/tw.ts
CHANGED
@@ -76,7 +76,14 @@ const tw: LocaleType = {
|
|
76 |
User:"帳號(純數位)",
|
77 |
Password:"密碼(最少六位)",
|
78 |
Email:"郵箱",
|
79 |
-
Code:"驗證碼"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
},
|
81 |
Settings: {
|
82 |
Title: "設定",
|
|
|
76 |
User:"帳號(純數位)",
|
77 |
Password:"密碼(最少六位)",
|
78 |
Email:"郵箱",
|
79 |
+
Code:"驗證碼",
|
80 |
+
Pass:{
|
81 |
+
Title:"修改密码",
|
82 |
+
OldPwd:"旧密码",
|
83 |
+
NewPwd:"新密码",
|
84 |
+
NewPwd1:"确认密码"
|
85 |
+
},
|
86 |
+
Save:"保存"
|
87 |
},
|
88 |
Settings: {
|
89 |
Title: "設定",
|
app/store/user.ts
CHANGED
@@ -79,8 +79,11 @@ export interface UserStore {
|
|
79 |
updateWallet: (wallet: number) => void;
|
80 |
updateName: (name: string) => void;
|
81 |
getUserInfo: () => void;
|
82 |
-
findPwd: (
|
83 |
useKami: (code: string) => void;
|
|
|
|
|
|
|
84 |
}
|
85 |
export const DEFAULT_USER = {
|
86 |
user: "",
|
@@ -202,7 +205,7 @@ export const useUserStore = create<UserStore>()(
|
|
202 |
}, 1000);
|
203 |
await this.getUserInfo();
|
204 |
} else {
|
205 |
-
showToast(
|
206 |
}
|
207 |
},
|
208 |
async register(user, password, name, mail, code) {
|
@@ -285,19 +288,19 @@ export const useUserStore = create<UserStore>()(
|
|
285 |
}
|
286 |
}
|
287 |
},
|
288 |
-
async findPwd(
|
289 |
-
let res = await fetch("/api/user/findpwd?
|
290 |
method: "POST",
|
291 |
headers: {
|
292 |
...getHeaders(),
|
293 |
},
|
294 |
});
|
295 |
-
let response = (await res.json()) as
|
296 |
console.log(response);
|
297 |
-
if (response.
|
298 |
showToast("密码已发送至您的邮箱,请注意查收!");
|
299 |
} else {
|
300 |
-
showToast(response.
|
301 |
}
|
302 |
},
|
303 |
async useKami(code) {
|
@@ -327,6 +330,53 @@ export const useUserStore = create<UserStore>()(
|
|
327 |
}
|
328 |
}
|
329 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
}),
|
331 |
{
|
332 |
name: StoreKey.User,
|
|
|
79 |
updateWallet: (wallet: number) => void;
|
80 |
updateName: (name: string) => void;
|
81 |
getUserInfo: () => void;
|
82 |
+
findPwd: (mail: string,code:string) => void;
|
83 |
useKami: (code: string) => void;
|
84 |
+
logOut:()=>any;
|
85 |
+
getRestPwdCode:(mail:string)=>void;
|
86 |
+
updatePass:(oldPass:string,newPass:string)=>void;
|
87 |
}
|
88 |
export const DEFAULT_USER = {
|
89 |
user: "",
|
|
|
205 |
}, 1000);
|
206 |
await this.getUserInfo();
|
207 |
} else {
|
208 |
+
showToast(response.message);
|
209 |
}
|
210 |
},
|
211 |
async register(user, password, name, mail, code) {
|
|
|
288 |
}
|
289 |
}
|
290 |
},
|
291 |
+
async findPwd(mail,code) {
|
292 |
+
let res = await fetch("/api/user/findpwd?mail=" + mail+"&code="+code, {
|
293 |
method: "POST",
|
294 |
headers: {
|
295 |
...getHeaders(),
|
296 |
},
|
297 |
});
|
298 |
+
let response = (await res.json()) as eladminRes;
|
299 |
console.log(response);
|
300 |
+
if (response.flag) {
|
301 |
showToast("密码已发送至您的邮箱,请注意查收!");
|
302 |
} else {
|
303 |
+
showToast(response.message);
|
304 |
}
|
305 |
},
|
306 |
async useKami(code) {
|
|
|
330 |
}
|
331 |
}
|
332 |
},
|
333 |
+
async logOut(){
|
334 |
+
await fetch(
|
335 |
+
"/api/user/logout",
|
336 |
+
{
|
337 |
+
method: "POST",
|
338 |
+
headers: {
|
339 |
+
...getHeaders(),
|
340 |
+
},
|
341 |
+
},
|
342 |
+
);
|
343 |
+
this.reset()
|
344 |
+
},
|
345 |
+
async getRestPwdCode(mail){
|
346 |
+
await fetch(
|
347 |
+
"/api/user/restmail?mail="+mail,
|
348 |
+
{
|
349 |
+
method: "POST",
|
350 |
+
headers: {
|
351 |
+
...getHeaders(),
|
352 |
+
},
|
353 |
+
},
|
354 |
+
);
|
355 |
+
showToast("发送成功!可能在垃圾邮箱中!")
|
356 |
+
},
|
357 |
+
async updatePass(oldPass,newPass){
|
358 |
+
let body={
|
359 |
+
oldPass:encrypt(oldPass),
|
360 |
+
newPass:encrypt(newPass)
|
361 |
+
}
|
362 |
+
let res=await fetch(
|
363 |
+
"/api/user/updatePass",
|
364 |
+
{
|
365 |
+
method: "POST",
|
366 |
+
headers: {
|
367 |
+
"Content-Type": "application/json",
|
368 |
+
...getHeaders(),
|
369 |
+
},
|
370 |
+
body:JSON.stringify(body)
|
371 |
+
},
|
372 |
+
);
|
373 |
+
res=await res.json()
|
374 |
+
if(res.message==null){
|
375 |
+
showToast("修改成功!")
|
376 |
+
}else{
|
377 |
+
showToast(res.message)
|
378 |
+
}
|
379 |
+
}
|
380 |
}),
|
381 |
{
|
382 |
name: StoreKey.User,
|