Merge branch 'feat/update_slave-20240324' into develop
This commit is contained in:
commit
4bbfce77c0
@ -1,5 +1,11 @@
|
||||
# @zhst/biz
|
||||
|
||||
## 0.11.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 添加 traansfer 组件 searchProps 透传
|
||||
|
||||
## 0.10.5
|
||||
|
||||
### Patch Changes
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@zhst/biz",
|
||||
"version": "0.10.5",
|
||||
"version": "0.11.0",
|
||||
"description": "业务库",
|
||||
"keywords": [
|
||||
"business",
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Button, Card, Flex, Input, Tree } from 'antd';
|
||||
import { Button, Card, Flex, Input, InputProps, Tree } from 'antd';
|
||||
import theme from 'antd/es/theme'
|
||||
import { TransferProps, TreeDataNode, TreeProps } from 'antd';
|
||||
import './index.less'
|
||||
@ -11,6 +11,7 @@ const componentName = 'zhst-biz-treeTransfer'
|
||||
export interface TreeTransferProps {
|
||||
dataSource: TreeDataNode[]
|
||||
treeProps?: TreeProps
|
||||
searchInputProps?: InputProps
|
||||
targetItems: TreeDataNode[];
|
||||
checkedKeys: string[];
|
||||
onTreeSelect?: TreeProps['onSelect']
|
||||
@ -26,6 +27,7 @@ const { useToken } = theme
|
||||
const TreeTransfer: React.FC<TreeTransferProps> = ({
|
||||
dataSource,
|
||||
treeProps,
|
||||
searchInputProps,
|
||||
targetItems = [],
|
||||
checkedKeys = [],
|
||||
onTreeCheck,
|
||||
@ -56,7 +58,7 @@ const TreeTransfer: React.FC<TreeTransferProps> = ({
|
||||
title={<div style={{ textAlign: 'center' }} >可选择的范围</div>}
|
||||
bodyStyle={{ padding: 12 }}
|
||||
>
|
||||
<Input prefix={<SearchOutlined />} onChange={e => setKeyWords(e.target.value)} placeholder='请输入设备名称' />
|
||||
<Input prefix={<SearchOutlined />} onChange={e => setKeyWords(e.target.value)} placeholder='请输入设备名称' {...searchInputProps} />
|
||||
<Tree
|
||||
style={{ marginTop: '6px' }}
|
||||
height={420}
|
||||
|
@ -38,6 +38,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@zhst/request": "workspace:^",
|
||||
"antd": "^5.15.4",
|
||||
"base-64": "^1.0.0",
|
||||
"dayjs": "^1.11.10",
|
||||
"file-saver": "^2.0.5",
|
||||
|
@ -4,24 +4,27 @@
|
||||
|
||||
import React, { useState } from 'react'
|
||||
import { getValueByUrl } from '@zhst/func'
|
||||
import { Input, Button, Space } from 'antd'
|
||||
|
||||
const demo = () => {
|
||||
const [inputVal, setInputVal ] = useState<any>(null)
|
||||
const [url, setUrl ] = useState<any>(null)
|
||||
const [keyword, setKeyword ] = useState<any>(null)
|
||||
const [outputVal, setOutPutVal ] = useState<any>(null)
|
||||
|
||||
const handleClick = () => {
|
||||
let val = getValueByUrl('to', inputVal)
|
||||
let val = getValueByUrl(keyword, url)
|
||||
setOutPutVal(val)
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div>
|
||||
<input value={inputVal} onChange={e => setInputVal(e.target.value)} />
|
||||
<button onClick={handleClick} >提交</button>
|
||||
<Space>
|
||||
链接:<Input onChange={(e: { target: { value: any } }) => setUrl(e.target.value)} />
|
||||
获取字段:<Input onChange={(e: { target: { value: any } }) => setKeyword(e.target.value)} />
|
||||
<Button onClick={handleClick} >提交</Button>
|
||||
</Space>
|
||||
<p>输出:{outputVal}</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,12 @@
|
||||
# @zhst/material
|
||||
|
||||
## 0.7.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies
|
||||
- @zhst/biz@0.11.0
|
||||
|
||||
## 0.7.1
|
||||
|
||||
### Patch Changes
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@zhst/material",
|
||||
"version": "0.7.1",
|
||||
"version": "0.7.2",
|
||||
"description": "物料库",
|
||||
"keywords": [
|
||||
"business",
|
||||
|
@ -10,17 +10,17 @@
|
||||
|
||||
## 使用
|
||||
|
||||
```js
|
||||
```jsx
|
||||
import React from 'react';
|
||||
import from '@zhst/slave'
|
||||
import slave from '@zhst/slave'
|
||||
|
||||
slave.init({
|
||||
jumpUrl: `http://10.0.0.222:30058/metarial/login`,
|
||||
to: 'http://www.baidu.com',
|
||||
jumpToLogin: false,
|
||||
tokenKey: 'token',
|
||||
showMsg: false,
|
||||
msgText: '你能不能先登录?'
|
||||
})
|
||||
export default () => <div>测试</div>
|
||||
```
|
||||
|
||||
## API
|
||||
|
@ -21,12 +21,12 @@ export interface ISlaveConfig {
|
||||
}
|
||||
|
||||
class Slave {
|
||||
token: string | null;
|
||||
config?: ISlaveConfig
|
||||
jumpUrl?: string;
|
||||
authTokenDefine: string;
|
||||
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
||||
constructor() {
|
||||
this.token = null
|
||||
this.authTokenDefine = 'ZHST_AUTH_TOKEN'
|
||||
this.jumpUrl = undefined
|
||||
}
|
||||
|
||||
@ -37,20 +37,26 @@ class Slave {
|
||||
tokenKey,
|
||||
showMsg = true,
|
||||
msgText,
|
||||
from,
|
||||
to
|
||||
} = opt
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
let _token = getValueByUrl(tokenKey || 'token', location.href) || localStorage.getItem('ZHST_AUTH_TOKEN')
|
||||
|
||||
this.token = _token
|
||||
localStorage.setItem('ZHST_AUTH_TOKEN', _token as string)
|
||||
let _token = getValueByUrl(tokenKey || 'token', location.href) || this.getToken()
|
||||
let _from = location.origin + location.pathname
|
||||
// TODO: 检验是否为url链接
|
||||
let _to = to
|
||||
this.setToken(_token)
|
||||
|
||||
// 判断当前登录环境
|
||||
this.checkEnv({ showMsg, msgText })
|
||||
|
||||
// 是否执行跳转页面
|
||||
if (jumpToLogin && jumpUrl && !_token) {
|
||||
let jumpUrlObj = new URL(jumpUrl)
|
||||
|
||||
// 判断是否为同一个域,采用不同的跳转方式
|
||||
// 同一个域名下
|
||||
if (jumpUrlObj.origin === location.origin) {
|
||||
history.pushState('', '', jumpUrl)
|
||||
} else {
|
||||
@ -60,17 +66,33 @@ class Slave {
|
||||
}
|
||||
|
||||
// 判端是否登录
|
||||
checkEnv(_opt: { showMsg: boolean, msgText?: string }) {
|
||||
if (!this.token && _opt.showMsg) {
|
||||
checkEnv(_opt: { showMsg: boolean, msgText?: string }): boolean {
|
||||
const _token = this.getToken() || String(this.getToken())
|
||||
if (!_token && _token !== 'null' && _opt.showMsg) {
|
||||
message.error(_opt.msgText || '请先登录!')
|
||||
return
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
public logOut() {
|
||||
localStorage.removeItem('ZHST_AUTH_TOKEN')
|
||||
this.removeToken()
|
||||
location.replace(location.origin + location.pathname)
|
||||
}
|
||||
|
||||
public setToken(val: string | null) {
|
||||
val && localStorage.setItem(this.authTokenDefine, val)
|
||||
}
|
||||
|
||||
public removeToken(cb?: () => void) {
|
||||
localStorage.removeItem(this.authTokenDefine)
|
||||
cb?.()
|
||||
}
|
||||
|
||||
public getToken() {
|
||||
return localStorage.getItem(this.authTokenDefine)
|
||||
}
|
||||
}
|
||||
|
||||
export default new Slave()
|
||||
|
112
pnpm-lock.yaml
112
pnpm-lock.yaml
@ -104,6 +104,9 @@ importers:
|
||||
'@zhst/request':
|
||||
specifier: workspace:^
|
||||
version: link:../request
|
||||
antd:
|
||||
specifier: ^5.15.4
|
||||
version: 5.15.4(react-dom@18.2.0)(react@18.2.0)
|
||||
base-64:
|
||||
specifier: ^1.0.0
|
||||
version: 1.0.0
|
||||
@ -554,6 +557,23 @@ packages:
|
||||
stylis: 4.3.1
|
||||
dev: false
|
||||
|
||||
/@ant-design/cssinjs@1.18.5(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-Ub4n3d+MAX/qtE5S9PM8iOn5ocU7GUAIC4Adc2X8UCMXnsRRfpJBHsBdtQ1qoAuaQ7lU2M1BTCuJ+fkv4fOWiw==}
|
||||
peerDependencies:
|
||||
react: '>=16.0.0'
|
||||
react-dom: '>=16.0.0'
|
||||
dependencies:
|
||||
'@babel/runtime': 7.24.1
|
||||
'@emotion/hash': 0.8.0
|
||||
'@emotion/unitless': 0.7.5
|
||||
classnames: 2.5.1
|
||||
csstype: 3.1.3
|
||||
rc-util: 5.39.1(react-dom@18.2.0)(react@18.2.0)
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
stylis: 4.3.1
|
||||
dev: false
|
||||
|
||||
/@ant-design/icons-svg@4.3.2:
|
||||
resolution: {integrity: sha512-s9WV19cXTC/Tux/XpDru/rCfPZQhGaho36B+9RrN1v5YsaKmE6dJ+fq6LQnXVBVYjzkqykEEK+1XG+SYiottTQ==}
|
||||
|
||||
@ -593,6 +613,22 @@ packages:
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
dev: false
|
||||
|
||||
/@ant-design/icons@5.3.5(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-Vyv/OsKz56BsKBtcRlLP6G8RGaRW43f7G5dK3XNPCaeV4YyehLVaITuNKi2YJG9hMVURkBdzdGhveNQlnKTFqw==}
|
||||
engines: {node: '>=8'}
|
||||
peerDependencies:
|
||||
react: '>=16.0.0'
|
||||
react-dom: '>=16.0.0'
|
||||
dependencies:
|
||||
'@ant-design/colors': 7.0.2
|
||||
'@ant-design/icons-svg': 4.4.2
|
||||
'@babel/runtime': 7.24.1
|
||||
classnames: 2.5.1
|
||||
rc-util: 5.39.1(react-dom@18.2.0)(react@18.2.0)
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
dev: false
|
||||
|
||||
/@ant-design/pro-card@2.5.29(antd@5.13.2)(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-QCtqiYZpl1uPFqgPacCkaP+8m5D604WScyfLZBoxIxtpA1SVe0dBIYyeB3cExgxkA7MZZwueeTIyE8B7okqgPw==}
|
||||
peerDependencies:
|
||||
@ -7024,6 +7060,68 @@ packages:
|
||||
- moment
|
||||
dev: false
|
||||
|
||||
/antd@5.15.4(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-79eLOQW1DG92yzulx+ValfHFjvPnaaI41BffGquAnzx42Ws3eEcKofsa2jNRyJN5NWr9I5wqvABDq9rRRfGGsg==}
|
||||
peerDependencies:
|
||||
react: '>=16.9.0'
|
||||
react-dom: '>=16.9.0'
|
||||
dependencies:
|
||||
'@ant-design/colors': 7.0.2
|
||||
'@ant-design/cssinjs': 1.18.5(react-dom@18.2.0)(react@18.2.0)
|
||||
'@ant-design/icons': 5.3.5(react-dom@18.2.0)(react@18.2.0)
|
||||
'@ant-design/react-slick': 1.0.2(react@18.2.0)
|
||||
'@babel/runtime': 7.24.1
|
||||
'@ctrl/tinycolor': 3.6.1
|
||||
'@rc-component/color-picker': 1.5.3(react-dom@18.2.0)(react@18.2.0)
|
||||
'@rc-component/mutate-observer': 1.1.0(react-dom@18.2.0)(react@18.2.0)
|
||||
'@rc-component/tour': 1.14.2(react-dom@18.2.0)(react@18.2.0)
|
||||
'@rc-component/trigger': 2.0.0(react-dom@18.2.0)(react@18.2.0)
|
||||
classnames: 2.5.1
|
||||
copy-to-clipboard: 3.3.3
|
||||
dayjs: 1.11.10
|
||||
qrcode.react: 3.1.0(react@18.2.0)
|
||||
rc-cascader: 3.24.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-checkbox: 3.2.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-collapse: 3.7.3(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-dialog: 9.4.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-drawer: 7.1.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-dropdown: 4.2.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-field-form: 1.42.1(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-image: 7.6.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-input: 1.4.5(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-input-number: 9.0.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-mentions: 2.11.1(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-menu: 9.13.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-motion: 2.9.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-notification: 5.3.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-pagination: 4.0.4(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-picker: 4.3.0(dayjs@1.11.10)(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-progress: 3.5.1(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-rate: 2.12.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-resize-observer: 1.4.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-segmented: 2.3.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-select: 14.13.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-slider: 10.5.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-steps: 6.0.1(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-switch: 4.1.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-table: 7.42.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-tabs: 14.1.1(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-textarea: 1.6.3(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-tooltip: 6.2.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-tree: 5.8.5(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-tree-select: 5.19.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-upload: 4.5.2(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-util: 5.39.1(react-dom@18.2.0)(react@18.2.0)
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
scroll-into-view-if-needed: 3.1.0
|
||||
throttle-debounce: 5.0.0
|
||||
transitivePeerDependencies:
|
||||
- date-fns
|
||||
- luxon
|
||||
- moment
|
||||
dev: false
|
||||
|
||||
/anymatch@3.1.3:
|
||||
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
|
||||
engines: {node: '>= 8'}
|
||||
@ -15616,6 +15714,20 @@ packages:
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
dev: false
|
||||
|
||||
/rc-collapse@3.7.3(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-60FJcdTRn0X5sELF18TANwtVi7FtModq649H11mYF1jh83DniMoM4MqY627sEKRCTm4+WXfGDcB7hY5oW6xhyw==}
|
||||
peerDependencies:
|
||||
react: '>=16.9.0'
|
||||
react-dom: '>=16.9.0'
|
||||
dependencies:
|
||||
'@babel/runtime': 7.24.1
|
||||
classnames: 2.5.1
|
||||
rc-motion: 2.9.0(react-dom@18.2.0)(react@18.2.0)
|
||||
rc-util: 5.39.1(react-dom@18.2.0)(react@18.2.0)
|
||||
react: 18.2.0
|
||||
react-dom: 18.2.0(react@18.2.0)
|
||||
dev: false
|
||||
|
||||
/rc-dialog@9.3.4(react-dom@18.2.0)(react@18.2.0):
|
||||
resolution: {integrity: sha512-975X3018GhR+EjZFbxA2Z57SX5rnu0G0/OxFgMMvZK4/hQWEm3MHaNvP4wXpxYDoJsp+xUvVW+GB9CMMCm81jA==}
|
||||
peerDependencies:
|
||||
|
Loading…
Reference in New Issue
Block a user