@jiangood/open-admin 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -48,5 +48,5 @@
48
48
  "test:e2e": "playwright test",
49
49
  "test:e2e:ui": "playwright test --ui"
50
50
  },
51
- "version": "3.0.0"
51
+ "version": "3.0.2"
52
52
  }
@@ -9,7 +9,7 @@ import axios from "axios";
9
9
  import qs from 'qs';
10
10
 
11
11
  const axiosInstance = axios.create({
12
- baseURL: import.meta.env.VITE_SERVLET_CONTEXT || '',
12
+ baseURL: import.meta.env.VITE_SERVER_SERVLET_CONTEXT_PATH,
13
13
  withCredentials: true,
14
14
  headers: {'Content-Type': 'application/json'},
15
15
  paramsSerializer: (params) => qs.stringify(params, {indices: false})
@@ -6,9 +6,28 @@ import ErrorBoundary from '../components/ErrorBoundary';
6
6
 
7
7
  interface PageFrameProps {
8
8
  url: string;
9
+ show?: boolean;
9
10
  }
10
11
 
11
12
  export class PageFrame extends React.Component<PageFrameProps> {
13
+ componentRef = React.createRef<any>();
14
+
15
+ componentDidMount() {
16
+ this.callOnShowIfActive();
17
+ }
18
+
19
+ componentDidUpdate(prevProps: PageFrameProps) {
20
+ if (!prevProps.show && this.props.show) {
21
+ this.callOnShowIfActive();
22
+ }
23
+ }
24
+
25
+ callOnShowIfActive() {
26
+ if (this.props.show && this.componentRef.current?.onShow) {
27
+ this.componentRef.current.onShow();
28
+ }
29
+ }
30
+
12
31
  render() {
13
32
  const {url} = this.props;
14
33
  const qIndex = url.indexOf('?');
@@ -21,7 +40,7 @@ export class PageFrame extends React.Component<PageFrameProps> {
21
40
  if (matched) {
22
41
  const {component: Comp, params} = matched;
23
42
  const location = {pathname, search, query: UrlUtils.getParams(url)};
24
- content = <Comp params={params} location={location}/>;
43
+ content = <Comp ref={this.componentRef} params={params} location={location}/>;
25
44
  } else {
26
45
  content = <Result status={404} title='页面不存在!' subTitle={<div>路由地址:{pathname}</div>}/>;
27
46
  }
@@ -65,7 +65,7 @@ export class UrlUtils {
65
65
  * 为路径添加 SERVLET_CONTEXT 前缀
66
66
  */
67
67
  static contextPath(path: string): string {
68
- const base = import.meta.env.VITE_SERVLET_CONTEXT || '';
68
+ const base = import.meta.env.VITE_SERVER_SERVLET_CONTEXT_PATH;
69
69
  return base + path;
70
70
  }
71
71
  }
@@ -10,7 +10,7 @@ interface RequestOptions extends AxiosRequestConfig {
10
10
  }
11
11
 
12
12
  const axiosInstance = axios.create({
13
- baseURL: import.meta.env.VITE_SERVLET_CONTEXT || '',
13
+ baseURL: import.meta.env.VITE_SERVER_SERVLET_CONTEXT_PATH,
14
14
  withCredentials: true,
15
15
  headers: { 'Content-Type': 'application/json' },
16
16
  paramsSerializer: (params: Record<string, unknown>) => qs.stringify(params, {indices: false})
@@ -113,7 +113,7 @@ export class TabLayout extends React.Component {
113
113
  <div style={{flex: 1, overflow: 'hidden'}}>
114
114
  {tabs.map(t => (
115
115
  <div key={t.key} style={{display: t.key === activeKey ? 'block' : 'none', height: '100%'}}>
116
- <PageFrame key={t.refreshKey} url={t.key}/>
116
+ <PageFrame key={t.refreshKey} url={t.key} show={t.key === activeKey}/>
117
117
  </div>
118
118
  ))}
119
119
  </div>
@@ -8,6 +8,7 @@ export default class extends React.Component {
8
8
 
9
9
  state = {
10
10
  usersModalOpen: false,
11
+ usersModalLoading: false,
11
12
  selectedRecord: null,
12
13
 
13
14
  userList: [],
@@ -132,12 +133,15 @@ export default class extends React.Component {
132
133
  ]
133
134
 
134
135
  handleSaveUsers = () => {
136
+ this.setState({usersModalLoading: true})
135
137
  const params = {
136
138
  id: this.state.selectedRecord.id,
137
139
  userIdList: this.state.targetKeys
138
140
  }
139
141
  HttpUtils.post('admin/sysRole/grant-users', params).then(rs => {
140
- this.setState({usersModalOpen: false})
142
+ this.setState({usersModalOpen: false, usersModalLoading: false})
143
+ }).catch(() => {
144
+ this.setState({usersModalLoading: false})
141
145
  })
142
146
  }
143
147
 
@@ -213,6 +217,7 @@ export default class extends React.Component {
213
217
 
214
218
  <Modal title={'角色用户' + "【" + this.state.selectedRecord?.name + '】'}
215
219
  open={this.state.usersModalOpen}
220
+ confirmLoading={this.state.usersModalLoading}
216
221
  destroyOnHidden
217
222
  mask={{ closable: false }}
218
223
  width={800}