From c3735ef52563da2baad0fd324773d5fbc9c65298 Mon Sep 17 00:00:00 2001 From: mac Date: Mon, 22 Jul 2024 15:45:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BF=AE=E6=94=B9=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E3=80=81=E9=82=AE=E7=AE=B1=E3=80=81=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.ts | 6 ++ src/components/Header/index.tsx | 92 ++++++++++++++++++++++------- src/pages/vip-manage/proxy-list.tsx | 13 ++-- 3 files changed, 86 insertions(+), 25 deletions(-) diff --git a/src/api/index.ts b/src/api/index.ts index 0f765db..343ff56 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -194,4 +194,10 @@ export default { set_adminPermissionList(data: object) { return $axios.post('/admin/setPermissions', data) }, + change_loginPwd(data: object) { + return $axios.post('/admin/revisePassword', data) + }, + change_emailAndName(data: object) { + return $axios.post('/admin/userEmailAndName', data) + } } diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 268a049..55c215a 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -1,11 +1,12 @@ -import React, { useEffect, FC } from 'react' +import React, { useEffect, FC, useState } from 'react' import { useHistory } from 'react-router-dom' -import { Menu, Dropdown, Layout } from 'antd' +import { Menu, Dropdown, Layout, Modal, Form, Input, Button, notification } from 'antd' import { MenuUnfoldOutlined, MenuFoldOutlined } from '@ant-design/icons' import Breadcrumb from '@/components/BreadCrumb' import { connect } from 'react-redux' import * as actions from '@/store/actions' import style from './Header.module.less' +import api from '@/api' interface Props extends ReduxProps { } @@ -13,6 +14,9 @@ const Header: FC = ({ storeData: { collapsed, theme, userInfo }, setStoreData }) => { + + const [form] = Form.useForm() + const [visible, setVisible] = useState(false) const history = useHistory() const { userName = '-' } = userInfo const firstWord = userName.slice(0, 1) @@ -26,8 +30,25 @@ const Header: FC = ({ setStoreData('SET_THEME', themes) } + const onFinish = async (values) => { + const res: any = await api.change_loginPwd(values) + if (res.code === 0) { + form.resetFields() + setVisible(false) + notification.success({ + message: '修改成功,请重新登录' + }) + await setStoreData('SET_USERINFO', {}) + localStorage.setItem('permissions', '') + history.replace({ pathname: '/login' }) + } + } + const menu = ( + setVisible(true)}> + 修改密码 + 退出登录 @@ -71,25 +92,54 @@ const Header: FC = ({ }, [theme]) return ( - -
- {collapsed ? ( - - ) : ( - - )} -
- - - - {firstWord} - {userName} - - - -
- - + <> + +
+ {collapsed ? ( + + ) : ( + + )} +
+ + + + {firstWord} + {userName} + + + +
+ + + setVisible(false)} title="修改密码" footer={() => null}> +
+ + + + + + + ({ + validator(_, value) { + if (!value || getFieldValue('new_password') === value) { + return Promise.resolve(); + } + return Promise.reject(new Error('两个密码不匹配!')); + }, + }),]} name="confrim_password"> + + + + + + +
+
+ ) } export default connect( diff --git a/src/pages/vip-manage/proxy-list.tsx b/src/pages/vip-manage/proxy-list.tsx index 181e3a4..bd817b4 100644 --- a/src/pages/vip-manage/proxy-list.tsx +++ b/src/pages/vip-manage/proxy-list.tsx @@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from "react"; import api from "@/api"; import MyTable from "@/components/MyTable"; import { DeleteFilled, EditOutlined, RightCircleFilled, SolutionOutlined, StopTwoTone } from "@ant-design/icons"; -import { Button, Form, Input, Modal, Popconfirm, Radio, Select, Switch, notification } from "antd"; +import { Button, Form, Input, Modal, Popconfirm, Radio, Select, Switch, message, notification } from "antd"; import { getBaseUrl, getOriginUrl } from "@/utils/axios"; const ProxyList = () => { @@ -71,7 +71,6 @@ const ProxyList = () => { items: [ { label: "当前余额", component: }, { label: "加减金额", name: "balance", rules: [{ required: true, message: '请输入加减金额' }] }, - { label: "邮箱通知", name: "email_flag", initialValue: true, valuePropName: "checked", component: } ] }, assets: { @@ -91,14 +90,19 @@ const ProxyList = () => { onFinish: (values) => onFinish(values, api.set_loginPwd, '重置成功'), items: [ { label: "登录密码", name: "password", rules: [{ required: true, message: '请输入要修改的登录密码' }] }, - { label: "邮箱通知", name: "email_flag", initialValue: true, valuePropName: "checked", component: } ] }, txPwd: { onFinish: (values) => onFinish(values, api.set_txPwd, '重置成功'), items: [ { label: "交易密码", name: "account_password", rules: [{ required: true, message: '请输入要修改的交易密码' }] }, - { label: "邮箱通知", name: "email_flag", initialValue: true, valuePropName: "checked", component: } + ] + }, + email: { + onFinish: (values) => onFinish(values, api.change_emailAndName, '修改成功'), + items: [ + { label: "名称", name: "name", rules: [{ required: true, message: '请输入名称' }], initialValue: currentAccount.current.name || '' }, + { label: "邮箱", name: "email", rules: [{ required: true, message: '请输入邮箱', }, { type: 'email', message: '邮箱格式错误' }], initialValue: currentAccount.current.email || '' }, ] } }; @@ -246,6 +250,7 @@ const ProxyList = () => { 设置级别 重置登录密码 重置交易密码 + 修改名称和邮箱
{renderForm(path)}