Commit 190115d2b16f539fb8e8407a5f89f3407ab1383a

Authored by 田强
1 parent 95de3e0e

refactor: 完善 demo

  1 +#!/usr/bin/env sh
  2 +. "$(dirname -- "$0")/_/husky.sh"
  3 +
  4 +pnpm lint-staged
@@ -8,7 +8,7 @@ export default defineConfig({ @@ -8,7 +8,7 @@ export default defineConfig({
8 'process.env.site': 'http://qx-test.qgutech.com', 8 'process.env.site': 'http://qx-test.qgutech.com',
9 // 'process.env.apiUrl': 'http://192.168.181.107/qgyun-api', 9 // 'process.env.apiUrl': 'http://192.168.181.107/qgyun-api',
10 // 'process.env.apiUrl': 'http://192.168.1.180/qx-api', 10 // 'process.env.apiUrl': 'http://192.168.1.180/qx-api',
11 - 'process.env.apiUrl': 'http://test.qgutech.com/qx-api', 11 + 'process.env.apiUrl': 'http://test.qixiaocloud.com/qx-api',
12 // 'process.env.apiUrl': 'https://uat.qgutech.com/qx-api', 12 // 'process.env.apiUrl': 'https://uat.qgutech.com/qx-api',
13 'process.env.wf.appCode': 'wf', 13 'process.env.wf.appCode': 'wf',
14 'process.env.wf.funCode': 'ew57e', 14 'process.env.wf.funCode': 'ew57e',
  1 +import { useState, useCallback } from 'react';
  2 +
  3 +export default () => {
  4 + const [counter, setCounter] = useState(0);
  5 +
  6 + const increment = useCallback(() => setCounter((c) => c + 1), []);
  7 + const decrement = useCallback(() => setCounter((c) => c - 1), []);
  8 +
  9 + return { counter, increment, decrement };
  10 +};
1 -import React, { memo, useEffect } from 'react'; 1 +import React, { memo } from 'react';
2 import { Space } from 'antd'; 2 import { Space } from 'antd';
3 import { QxSearchForm, QxTable, QxToolbar } from '@/src/components/view-render'; 3 import { QxSearchForm, QxTable, QxToolbar } from '@/src/components/view-render';
  4 +import { useRequest } from 'ahooks';
4 import { getData } from './services'; 5 import { getData } from './services';
5 import data from './data.json'; 6 import data from './data.json';
  7 +import styles from './styles.less';
  8 +
  9 +const prefixCls = 'app-view';
6 10
7 const AppView: React.FC<AppViewProps> = (props) => { 11 const AppView: React.FC<AppViewProps> = (props) => {
8 const { search, list, bar } = data; 12 const { search, list, bar } = data;
  13 + const { data: tableData = {} as any, run, loading } = useRequest(getData);
  14 +
9 const changeFullscreen = () => {}; 15 const changeFullscreen = () => {};
10 -  
11 - useEffect(() => {  
12 - getData().then((res: any) => {  
13 - console.log('res', res);  
14 - });  
15 - }, []);  
16 16
17 return ( 17 return (
18 - <Space direction="vertical" size={20}>  
19 - <QxSearchForm {...search} />  
20 - <QxToolbar  
21 - isFullscreen  
22 - changeFullscreen={changeFullscreen}  
23 - buttons={bar.buttons}  
24 - />  
25 - <QxTable columns={list.columns} />  
26 - </Space> 18 + <div className={styles[prefixCls]}>
  19 + <Space direction="vertical" size={20}>
  20 + <QxSearchForm {...search} onSearch={() => run()} />
  21 + <QxToolbar
  22 + isFullscreen
  23 + changeFullscreen={changeFullscreen}
  24 + buttons={bar.buttons}
  25 + />
  26 + <QxTable
  27 + loading={loading}
  28 + columns={list.columns}
  29 + dataSource={tableData.list}
  30 + />
  31 + </Space>
  32 + </div>
27 ); 33 );
28 }; 34 };
29 35
  1 +@prefix-cls: ~'app-view';
  2 +
  3 +.@{prefix-cls} {
  4 + padding: 10px;
  5 +}