Commit dc85fd11444404db801a3bc2871b50f00baf64a5

Authored by 史婷婷
1 parent ed271b3f

feat: micro-app-template-stt-定制部门临时版本

1 import { defineConfig } from 'umi'; 1 import { defineConfig } from 'umi';
2 2
3 export default defineConfig({ 3 export default defineConfig({
4 - runtimePublicPath: true 4 + runtimePublicPath: true,
  5 + devServer: {
  6 + port: 5203,
  7 + proxy: {
  8 + dev: {
  9 + '/api/': {
  10 + target: 'https://preview.pro.ant.design',
  11 + changeOrigin: true,
  12 + pathRewrite: { '^': '' },
  13 + },
  14 + '/open/': {
  15 + target: 'https://test.qgutech.com',
  16 + changeOrigin: true,
  17 + },
  18 + },
  19 + test: {
  20 + '/api/': {
  21 + target: 'https://preview.pro.ant.design',
  22 + changeOrigin: true,
  23 + pathRewrite: { '^': '' },
  24 + },
  25 + },
  26 + pre: {
  27 + '/api/': {
  28 + target: 'your pre url',
  29 + changeOrigin: true,
  30 + pathRewrite: { '^': '' },
  31 + },
  32 + },
  33 + },
  34 + },
  35 + define: {
  36 + 'process.env.site': 'http://qx-test.qgutech.com',
  37 + // 'process.env.apiUrl': 'http://192.168.181.107/qgyun-api',
  38 + // 'process.env.apiUrl': 'http://192.168.1.180/qx-api',
  39 + 'process.env.apiUrl': 'http://test.qgutech.com/qx-api',
  40 + // 'process.env.apiUrl': 'https://qinggutest01.gifthulu.com/qx-api',
  41 + // 'process.env.apiUrl': 'https://uat.qgutech.com/qx-api',
  42 + 'process.env.openUrl': '/open',
  43 + }
5 }); 44 });
@@ -5,7 +5,8 @@ @@ -5,7 +5,8 @@
5 Install dependencies, 5 Install dependencies,
6 6
7 ```bash 7 ```bash
8 -$ pnpm i 8 +$ pnpm i
  9 +$ npm i --force
9 ``` 10 ```
10 11
11 Start the dev server, 12 Start the dev server,
@@ -13,3 +14,5 @@ Start the dev server, @@ -13,3 +14,5 @@ Start the dev server,
13 ```bash 14 ```bash
14 $ pnpm start 15 $ pnpm start
15 ``` 16 ```
  17 +
  18 +# (功能按钮带参数 是拼接在配置的链接 最后一个问号后面) 例如:_qx_flag、id
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 "private": true, 3 "private": true,
4 "scripts": { 4 "scripts": {
5 "analyze": "cross-env ANALYZE=1 qx-cli build", 5 "analyze": "cross-env ANALYZE=1 qx-cli build",
6 - "start": "cross-env UMI_APP_ENV=dev qx-cli start", 6 + "start": "cross-env SOCKET_SERVER=https://localhost:5203 HTTPS=1 umi dev",
7 "start:test": "cross-env UMI_APP_ENV=test qx-cli start", 7 "start:test": "cross-env UMI_APP_ENV=test qx-cli start",
8 "start:pre": "cross-env UMI_APP_ENV=pre qx-cli start", 8 "start:pre": "cross-env UMI_APP_ENV=pre qx-cli start",
9 "build": "cross-env UMI_APP_ENV=prod qx-cli build", 9 "build": "cross-env UMI_APP_ENV=prod qx-cli build",
1 -import React, { memo } from 'react';  
2 -import { Button } from 'antd';  
3 -import { useModel } from 'umi'; 1 +import React, {memo, useEffect} from 'react';
  2 +import {Button} from 'antd';
  3 +import {useModel} from 'umi';
4 import styles from './styles.less'; 4 import styles from './styles.less';
5 5
6 const prefixCls = 'app-view'; 6 const prefixCls = 'app-view';
7 7
8 const AppView: React.FC<AppViewProps> = (props) => { 8 const AppView: React.FC<AppViewProps> = (props) => {
9 - const { increment, decrement, counter } = useModel('count', (model) => model);  
10 - return (  
11 - <div className={styles[prefixCls]}>  
12 - <p>{counter}</p>  
13 - <Button  
14 - className={styles[`${prefixCls}__button--primary`]}  
15 - onClick={() => increment()}  
16 - >  
17 - increment  
18 - </Button>  
19 - <Button onClick={() => decrement()}>decrement</Button>  
20 - </div>  
21 - ); 9 + const {increment, decrement, counter} = useModel('count', (model) => model);
  10 +
  11 + return (
  12 + <div className={styles[prefixCls]}>
  13 + <p>{counter}</p>
  14 + <Button
  15 + className={styles[`${prefixCls}__button--primary`]}
  16 + onClick={() => increment()}
  17 + >
  18 + increment
  19 + </Button>
  20 + <Button onClick={() => decrement()}>decrement</Button>
  21 + </div>
  22 + );
22 }; 23 };
23 24
24 -interface AppViewProps {} 25 +interface AppViewProps {
  26 +}
25 27
26 export default memo(AppView); 28 export default memo(AppView);
@@ -2,4 +2,4 @@ import request from '@/utils/request'; @@ -2,4 +2,4 @@ import request from '@/utils/request';
2 2
3 export function getData() { 3 export function getData() {
4 return request.get(`http://yapi.qgutech.com/mock/547/mock-api/page`); 4 return request.get(`http://yapi.qgutech.com/mock/547/mock-api/page`);
5 -} 5 +}
@@ -2,12 +2,9 @@ @@ -2,12 +2,9 @@
2 2
3 .@{prefix-cls} { 3 .@{prefix-cls} {
4 padding: 10px; 4 padding: 10px;
5 - color: @B8;  
6 5
7 &__button { 6 &__button {
8 &--primary { 7 &--primary {
9 - background-color: @B8;  
10 - color: @N8;  
11 } 8 }
12 } 9 }
13 } 10 }
  1 +import React, {memo, useEffect} from 'react';
  2 +import { Space } from 'antd';
  3 +import styles from './styles.less';
  4 +
  5 +const prefixCls = 'details-test-view';
  6 +
  7 +const DetailsTestView: React.FC<DetailsTestViewProps> = (props) => {
  8 +
  9 +
  10 + return (
  11 + <div className={styles[prefixCls]}>
  12 + <Space direction="vertical" size={20}>
  13 + details-test
  14 + </Space>
  15 + </div>
  16 + );
  17 +};
  18 +
  19 +interface DetailsTestViewProps {}
  20 +
  21 +export default memo(DetailsTestView);
  1 +@prefix-cls: ~'details-test-view';
  2 +
  3 +.@{prefix-cls} {
  4 + padding: 10px;
  5 +}
  1 +import React, {memo, useEffect} from 'react';
  2 +import { Space } from 'antd';
  3 +import styles from './styles.less';
  4 +import {getPage} from "./services";
  5 +
  6 +const prefixCls = 'test-view';
  7 +
  8 +const TestView: React.FC<AppViewProps> = (props) => {
  9 + // 测试 stt-测试应用-测试百分比组件表单
  10 + const appCode = 'nv32y';
  11 + const funCode = '0rra0';
  12 + const viewCode = 'all';
  13 + const moduleData =
  14 + // @ts-ignore
  15 + window?.parent?.qx?.getModuleData()?.menus ||
  16 + // @ts-ignore
  17 + window?.qx?.getModuleData()?.menus ||
  18 + [];
  19 + const appId =
  20 + moduleData?.find((obj: any) => obj?.appCode === appCode)?.appId || '';
  21 +
  22 + useEffect(() => {
  23 + const _params = {
  24 + appId: appId,
  25 + _code: `${appCode}_index_app`,
  26 + viewType: 'list',
  27 + viewCode: 'all',
  28 + _$search_: true,
  29 + _filter: '',
  30 + _include: true,
  31 + collapseStatus: true,
  32 + pageSize: 10,
  33 + };
  34 + getPage(appCode, funCode, viewCode, _params)
  35 + .then((res: any) => {
  36 + console.log('res', res)
  37 + })
  38 + .catch((e: any) => {
  39 + console.log('e', e)
  40 + });
  41 + }, [])
  42 +
  43 + return (
  44 + <div className={styles[prefixCls]}>
  45 + <Space direction="vertical" size={20}>
  46 + test
  47 + </Space>
  48 + </div>
  49 + );
  50 +};
  51 +
  52 +interface AppViewProps {}
  53 +
  54 +export default memo(TestView);
  1 +import request from '@/utils/request';
  2 +
  3 +/**
  4 + * 分页接口
  5 + * @param appCode
  6 + * @param funCode
  7 + * @param viewCode
  8 + * @param params
  9 + * @param headers
  10 + */
  11 +export function getPage(
  12 + appCode: string,
  13 + funCode: string,
  14 + viewCode: string,
  15 + params: any,
  16 +) {
  17 + return request.get(
  18 + `/qx-apaas-lowcode/runtime/${appCode}/${funCode}/${viewCode}/page`,
  19 + {
  20 + params: params || {},
  21 + autoShowError: true,
  22 + useCancel: true,
  23 + },
  24 + );
  25 +}
  1 +@prefix-cls: ~'test-view';
  2 +
  3 +.@{prefix-cls} {
  4 + padding: 10px;
  5 +}
  1 +/**
  2 + * 功能按钮打开的页面,放入pages/details下面
  3 + * 左侧菜单,自定义页面,放入pages/page-view下面
  4 + * 自定义页面path需要加 /:appCode/
  5 + * **/
1 export default [ 6 export default [
2 { 7 {
3 - path: '/view', 8 + path: '/',
  9 + redirect: '/details/testDetail',
  10 + },
  11 + {
  12 + path: '/:appCode/test',
  13 + component: '@/pages/test',
  14 + layout: true,
  15 + },
  16 + {
  17 + path: '/:appCode/view',
4 component: '@/pages/app-view', 18 component: '@/pages/app-view',
5 layout: true, 19 layout: true,
6 }, 20 },
  21 + {
  22 + path: '/details/testDetail',
  23 + component: '@/pages/details/test',
  24 + layout: true,
  25 + },
7 ]; 26 ];
1 -const { request } = window.qx.sdk; 1 +// qx-fe-layout 项目 已对request实例进行更改了 这里不需要重新处理 todo 田强
  2 +import request from 'umi-request';
2 3
3 -export default request; 4 +// @ts-ignore
  5 +export default window?.qx?.sdk?.request || request;
1 -@import '~@qx/ui/dist/src/style/variable.less'; 1 +@import '~antd/lib/style/themes/variable.less';
  2 +
  3 +@html-selector: html;