From d59dfda1f64f9c95b17be6100443756ba1a90722 Mon Sep 17 00:00:00 2001 From: qujay <371226673@qq.com> Date: Mon, 17 Oct 2022 00:13:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=89=8D=E7=AB=AF=E4=B8=AA?= =?UTF-8?q?=E4=BA=BA=E4=BF=A1=E6=81=AF=E5=A4=B4=E5=83=8F=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zlt-web/src/main/frontend/config/proxy.ts | 6 ++- zlt-web/src/main/frontend/config/routes.ts | 17 -------- zlt-web/src/main/frontend/src/access.ts | 4 +- .../src/pages/system/UserInfo/index.tsx | 43 +++++++++++-------- .../frontend/src/services/login/typings.d.ts | 9 +--- .../main/frontend/src/services/system/api.ts | 2 +- .../frontend/src/services/system/typings.d.ts | 19 +++++++- 7 files changed, 52 insertions(+), 48 deletions(-) diff --git a/zlt-web/src/main/frontend/config/proxy.ts b/zlt-web/src/main/frontend/config/proxy.ts index 166ab746..65f2c9c4 100644 --- a/zlt-web/src/main/frontend/config/proxy.ts +++ b/zlt-web/src/main/frontend/config/proxy.ts @@ -6,7 +6,7 @@ * For details, please see * https://pro.ant.design/docs/deploy */ -export default { + export default { dev: { '/api-uaa/': { target: 'http://127.0.0.1:9900', @@ -28,6 +28,10 @@ export default { target: 'http://127.0.0.1:9900', changeOrigin: true, }, + '/api-file/': { + target: 'http://127.0.0.1:9900', + changeOrigin: true, + }, }, test: { '/api/': { diff --git a/zlt-web/src/main/frontend/config/routes.ts b/zlt-web/src/main/frontend/config/routes.ts index c5ea20fe..73857fab 100644 --- a/zlt-web/src/main/frontend/config/routes.ts +++ b/zlt-web/src/main/frontend/config/routes.ts @@ -82,23 +82,6 @@ icon: 'smile', component: './Welcome', }, - { - path: '/admin', - name: 'admin', - icon: 'crown', - access: 'canAdmin', - routes: [ - { - path: '/admin/sub-page', - name: 'sub-page', - icon: 'smile', - component: './Welcome', - }, - { - component: './404', - }, - ], - }, { path: '/', redirect: '/welcome', diff --git a/zlt-web/src/main/frontend/src/access.ts b/zlt-web/src/main/frontend/src/access.ts index e823e24b..c1c63a90 100644 --- a/zlt-web/src/main/frontend/src/access.ts +++ b/zlt-web/src/main/frontend/src/access.ts @@ -1,9 +1,9 @@ /** * @see https://umijs.org/zh-CN/plugins/plugin-access * */ -export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) { + export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) { const { currentUser } = initialState ?? {}; return { - canAdmin: currentUser && currentUser.access === 'admin', + canAdmin: currentUser , }; } diff --git a/zlt-web/src/main/frontend/src/pages/system/UserInfo/index.tsx b/zlt-web/src/main/frontend/src/pages/system/UserInfo/index.tsx index f4f830e4..1c41744a 100644 --- a/zlt-web/src/main/frontend/src/pages/system/UserInfo/index.tsx +++ b/zlt-web/src/main/frontend/src/pages/system/UserInfo/index.tsx @@ -1,11 +1,10 @@ -import { currentUser2 } from '@/services/login/api'; -import { importImage, importUser, saveOrUpdateUser } from '@/services/system/api'; +import { importImage, saveOrUpdateUser } from '@/services/system/api'; import { UploadOutlined } from '@ant-design/icons'; import type { ProFormInstance } from '@ant-design/pro-components'; import { PageContainer, ProFormText, ProForm, ProFormRadio } from '@ant-design/pro-components'; import { Button, message, Upload } from 'antd'; -import { RcFile } from 'antd/lib/upload'; -import React, { useRef } from 'react'; +import type { RcFile } from 'antd/lib/upload'; +import React, { useRef, useState } from 'react'; import { useModel } from 'umi'; import styles from './index.less'; @@ -35,18 +34,16 @@ const handleImport = async (file: RcFile) => { formData.append('file', file); const result = await importImage(formData); hide(); - if (result.resp_code === 0) { - message.success('上传头像成功'); - } else { - message.error(result.resp_msg); - } + message.success('上传头像成功'); + return result; } catch (error) { hide(); message.error('上传头像失败'); + return null; } }; -const AvatarView = ({ avatar }: { avatar: string }) => ( +const AvatarUpload = ({ avatar, setImage }: { avatar: string, setImage: (headImgUrl: string) => void }) => ( <>