From 83b51a5a0774ea8ecb9a06304af3b956a21307c8 Mon Sep 17 00:00:00 2001
From: pjb <123456>
Date: 星期六, 08 三月 2025 09:06:55 +0800
Subject: [PATCH] CUT库条码T开头,截取后10位
---
zy-asrs-flow/src/components/RightContent/AvatarDropdown.jsx | 275 ++++++++++++++++++++++++++----------------------------
1 files changed, 134 insertions(+), 141 deletions(-)
diff --git a/zy-asrs-flow/src/components/RightContent/AvatarDropdown.jsx b/zy-asrs-flow/src/components/RightContent/AvatarDropdown.jsx
index 6e4c9cb..6e674fa 100644
--- a/zy-asrs-flow/src/components/RightContent/AvatarDropdown.jsx
+++ b/zy-asrs-flow/src/components/RightContent/AvatarDropdown.jsx
@@ -1,141 +1,134 @@
-import { outLogin } from '@/services/ant-design-pro/api';
-import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons';
-import { history, useModel } from '@umijs/max';
-import { Spin } from 'antd';
-import { createStyles } from 'antd-style';
-import { stringify } from 'querystring';
-import React, { useCallback } from 'react';
-import { flushSync } from 'react-dom';
-import HeaderDropdown from '../HeaderDropdown';
-import { setRemoteMenu } from '@/services/route'
-import { removeToken } from '@/utils/token-util'
-
-const useStyles = createStyles(({ token }) => {
- return {
- action: {
- display: 'flex',
- height: '48px',
- marginLeft: 'auto',
- overflow: 'hidden',
- alignItems: 'center',
- padding: '0 8px',
- cursor: 'pointer',
- borderRadius: token.borderRadius,
- '&:hover': {
- backgroundColor: token.colorBgTextHover,
- },
- },
- };
-});
-
-export const AvatarName = () => {
- const { initialState } = useModel('@@initialState');
- const { currentUser } = initialState || {};
- return <span className="anticon">{currentUser?.name}</span>;
-};
-
-export const AvatarDropdown = ({ menu, children }) => {
- const { styles } = useStyles();
- const { initialState, setInitialState } = useModel('@@initialState');
-
- // 閫�鍑虹櫥褰曪紝骞朵笖灏嗗綋鍓嶇殑 url 淇濆瓨
- const loginOut = async () => {
- // await outLogin();
- removeToken();
- setRemoteMenu(null);
- const { search, pathname } = window.location;
- const urlParams = new URL(window.location.href).searchParams;
- /** 姝ゆ柟娉曚細璺宠浆鍒� redirect 鍙傛暟鎵�鍦ㄧ殑浣嶇疆 */
- const redirect = urlParams.get('redirect');
- // Note: There may be security issues, please note
- if (window.location.pathname !== '/user/login' && !redirect) {
- history.replace({
- pathname: '/user/login',
- search: stringify({
- redirect: pathname + search,
- }),
- });
- }
- };
-
- const onMenuClick = useCallback((event) => {
- const { key } = event;
- if (key === 'logout') {
- flushSync(() => {
- setInitialState((s) => ({ ...s, currentUser: undefined }));
- });
- loginOut();
- return;
- }
- history.push(`/account/${key}`);
- },
- [setInitialState],
- );
-
- const loading = (
- <span className={styles.action}>
- <Spin
- size="small"
- style={{
- marginLeft: 8,
- marginRight: 8,
- }}
- />
- </span>
- );
-
- if (!initialState) {
- return loading;
- }
-
- const { currentUser } = initialState;
-
- if (!currentUser || !currentUser.name) {
- return loading;
- }
-
- const menuItems = [
- // ...(menu
- // ? [
- // {
- // key: 'center',
- // icon: <UserOutlined />,
- // label: '涓汉涓績',
- // },
- // {
- // key: 'settings',
- // icon: <SettingOutlined />,
- // label: '涓汉璁剧疆',
- // },
- // {
- // type: 'divider' as const,
- // },
- // ]
- // : []),
- {
- key: 'settings',
- icon: <SettingOutlined />,
- label: '涓汉璁剧疆',
- },
- {
- type: 'divider'
- },
- {
- key: 'logout',
- icon: <LogoutOutlined />,
- label: '閫�鍑虹櫥褰�',
- },
- ];
-
- return (
- <HeaderDropdown
- menu={{
- selectedKeys: [],
- onClick: onMenuClick,
- items: menuItems,
- }}
- >
- {children}
- </HeaderDropdown>
- );
-};
+import { outLogin } from '@/services/ant-design-pro/api';
+import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons';
+import { history, useModel } from '@umijs/max';
+import { Spin } from 'antd';
+import { createStyles } from 'antd-style';
+import { stringify } from 'querystring';
+import React, { useCallback } from 'react';
+import { flushSync } from 'react-dom';
+import HeaderDropdown from '../HeaderDropdown';
+import { setRemoteMenu } from '@/services/route'
+import { removeToken } from '@/utils/token-util'
+
+const useStyles = createStyles(({ token }) => {
+ return {
+ action: {
+ display: 'flex',
+ height: '48px',
+ marginLeft: 'auto',
+ overflow: 'hidden',
+ alignItems: 'center',
+ padding: '0 8px',
+ cursor: 'pointer',
+ borderRadius: token.borderRadius,
+ '&:hover': {
+ backgroundColor: token.colorBgTextHover,
+ },
+ },
+ };
+});
+
+export const AvatarName = () => {
+ const { initialState } = useModel('@@initialState');
+ const { currentUser } = initialState || {};
+ return <span className="anticon">{currentUser?.name}</span>;
+};
+
+export const AvatarDropdown = ({ menu, children }) => {
+ const { styles } = useStyles();
+ const { initialState, setInitialState } = useModel('@@initialState');
+
+ // 閫�鍑虹櫥褰曪紝骞朵笖灏嗗綋鍓嶇殑 url 淇濆瓨
+ const loginOut = async () => {
+ // await outLogin();
+ removeToken();
+ setRemoteMenu(null);
+ const { search, pathname } = window.location;
+ const urlParams = new URL(window.location.href).searchParams;
+ /** 姝ゆ柟娉曚細璺宠浆鍒� redirect 鍙傛暟鎵�鍦ㄧ殑浣嶇疆 */
+ const redirect = urlParams.get('redirect');
+ // Note: There may be security issues, please note
+ if (window.location.pathname !== '/user/login' && !redirect) {
+ history.replace({
+ pathname: '/user/login',
+ search: stringify({
+ redirect: pathname + search,
+ }),
+ });
+ }
+ };
+
+ const onMenuClick = useCallback((event) => {
+ const { key } = event;
+ if (key === 'logout') {
+ flushSync(() => {
+ setInitialState((s) => ({ ...s, currentUser: undefined }));
+ });
+ loginOut();
+ return;
+ }
+ history.push(`/user/${key}`);
+ }, [setInitialState]);
+
+ const loading = (
+ <span className={styles.action}>
+ <Spin
+ size="small"
+ style={{
+ marginLeft: 8,
+ marginRight: 8,
+ }}
+ />
+ </span>
+ );
+
+ if (!initialState) {
+ return loading;
+ }
+
+ const { currentUser } = initialState;
+
+ if (!currentUser || !currentUser.name) {
+ return loading;
+ }
+
+ const menuItems = [
+ // ...(menu
+ // ? [
+ // {
+ // key: 'center',
+ // icon: <UserOutlined />,
+ // label: '涓汉涓績',
+ // },
+ // {
+ // key: 'settings',
+ // icon: <SettingOutlined />,
+ // label: '涓汉璁剧疆',
+ // },
+ // {
+ // type: 'divider' as const,
+ // },
+ // ]
+ // : []),
+ // {
+ // type: 'divider'
+ // },
+ {
+ key: 'logout',
+ icon: <LogoutOutlined />,
+ label: '閫�鍑虹櫥褰�',
+ },
+ ];
+
+ return (
+ <HeaderDropdown
+ menu={{
+ selectedKeys: [],
+ onClick: onMenuClick,
+ items: menuItems,
+ }}
+ >
+ {children}
+ </HeaderDropdown>
+ );
+};
--
Gitblit v1.9.1