张延森 2 年前
父节点
当前提交
f072fa7bc3

+ 3
- 0
config/config.js 查看文件

@@ -8,6 +8,9 @@ import routes from './routes';
8 8
 const { REACT_APP_ENV } = process.env;
9 9
 
10 10
 export default defineConfig({
11
+  define: {
12
+    API_BASE: REACT_APP_ENV ? '' : ''
13
+  },
11 14
   hash: true,
12 15
   antd: {
13 16
     dark: true,

+ 2
- 2
config/defaultSettings.ts 查看文件

@@ -12,9 +12,9 @@ const Settings: LayoutSettings & {
12 12
   fixedHeader: false,
13 13
   fixSiderbar: true,
14 14
   colorWeak: false,
15
-  title: '军工站',
15
+  title: '军',
16 16
   pwa: false,
17
-  logo: 'https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg',
17
+  logo: '/logo.png',
18 18
   iconfontUrl: '',
19 19
 };
20 20
 

+ 1
- 1
config/proxy.js 查看文件

@@ -11,7 +11,7 @@ export default {
11 11
     // localhost:8000/api/** -> https://preview.pro.ant.design/api/**
12 12
     '/api/': {
13 13
       // 要代理的地址
14
-      target: 'http://192.168.89.76:8087',
14
+      target: 'http://192.168.89.147:8087',
15 15
       // 配置了这个可以从 http 代理到 https
16 16
       // 依赖 origin 的功能可能需要这个,比如 cookie
17 17
       changeOrigin: true,

二进制
public/icons/icon-128x128.png 查看文件


二进制
public/icons/icon-192x192.png 查看文件


二进制
public/icons/icon-512x512.png 查看文件


二进制
public/logo.png 查看文件


+ 0
- 1
public/logo.svg 查看文件

@@ -1 +0,0 @@
1
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200" version="1.1" viewBox="0 0 200 200"><title>Group 28 Copy 5</title><desc>Created with Sketch.</desc><defs><linearGradient id="linearGradient-1" x1="62.102%" x2="108.197%" y1="0%" y2="37.864%"><stop offset="0%" stop-color="#4285EB"/><stop offset="100%" stop-color="#2EC7FF"/></linearGradient><linearGradient id="linearGradient-2" x1="69.644%" x2="54.043%" y1="0%" y2="108.457%"><stop offset="0%" stop-color="#29CDFF"/><stop offset="37.86%" stop-color="#148EFF"/><stop offset="100%" stop-color="#0A60FF"/></linearGradient><linearGradient id="linearGradient-3" x1="69.691%" x2="16.723%" y1="-12.974%" y2="117.391%"><stop offset="0%" stop-color="#FA816E"/><stop offset="41.473%" stop-color="#F74A5C"/><stop offset="100%" stop-color="#F51D2C"/></linearGradient><linearGradient id="linearGradient-4" x1="68.128%" x2="30.44%" y1="-35.691%" y2="114.943%"><stop offset="0%" stop-color="#FA8E7D"/><stop offset="51.264%" stop-color="#F74A5C"/><stop offset="100%" stop-color="#F51D2C"/></linearGradient></defs><g id="Page-1" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="logo" transform="translate(-20.000000, -20.000000)"><g id="Group-28-Copy-5" transform="translate(20.000000, 20.000000)"><g id="Group-27-Copy-3"><g id="Group-25" fill-rule="nonzero"><g id="2"><path id="Shape" fill="url(#linearGradient-1)" d="M91.5880863,4.17652823 L4.17996544,91.5127728 C-0.519240605,96.2081146 -0.519240605,103.791885 4.17996544,108.487227 L91.5880863,195.823472 C96.2872923,200.518814 103.877304,200.518814 108.57651,195.823472 L145.225487,159.204632 C149.433969,154.999611 149.433969,148.181924 145.225487,143.976903 C141.017005,139.771881 134.193707,139.771881 129.985225,143.976903 L102.20193,171.737352 C101.032305,172.906015 99.2571609,172.906015 98.0875359,171.737352 L28.285908,101.993122 C27.1162831,100.824459 27.1162831,99.050775 28.285908,97.8821118 L98.0875359,28.1378823 C99.2571609,26.9692191 101.032305,26.9692191 102.20193,28.1378823 L129.985225,55.8983314 C134.193707,60.1033528 141.017005,60.1033528 145.225487,55.8983314 C149.433969,51.69331 149.433969,44.8756232 145.225487,40.6706018 L108.58055,4.05574592 C103.862049,-0.537986846 96.2692618,-0.500797906 91.5880863,4.17652823 Z"/><path id="Shape" fill="url(#linearGradient-2)" d="M91.5880863,4.17652823 L4.17996544,91.5127728 C-0.519240605,96.2081146 -0.519240605,103.791885 4.17996544,108.487227 L91.5880863,195.823472 C96.2872923,200.518814 103.877304,200.518814 108.57651,195.823472 L145.225487,159.204632 C149.433969,154.999611 149.433969,148.181924 145.225487,143.976903 C141.017005,139.771881 134.193707,139.771881 129.985225,143.976903 L102.20193,171.737352 C101.032305,172.906015 99.2571609,172.906015 98.0875359,171.737352 L28.285908,101.993122 C27.1162831,100.824459 27.1162831,99.050775 28.285908,97.8821118 L98.0875359,28.1378823 C100.999864,25.6271836 105.751642,20.541824 112.729652,19.3524487 C117.915585,18.4685261 123.585219,20.4140239 129.738554,25.1889424 C125.624663,21.0784292 118.571995,14.0340304 108.58055,4.05574592 C103.862049,-0.537986846 96.2692618,-0.500797906 91.5880863,4.17652823 Z"/></g><path id="Shape" fill="url(#linearGradient-3)" d="M153.685633,135.854579 C157.894115,140.0596 164.717412,140.0596 168.925894,135.854579 L195.959977,108.842726 C200.659183,104.147384 200.659183,96.5636133 195.960527,91.8688194 L168.690777,64.7181159 C164.472332,60.5180858 157.646868,60.5241425 153.435895,64.7316526 C149.227413,68.936674 149.227413,75.7543607 153.435895,79.9593821 L171.854035,98.3623765 C173.02366,99.5310396 173.02366,101.304724 171.854035,102.473387 L153.685633,120.626849 C149.47715,124.83187 149.47715,131.649557 153.685633,135.854579 Z"/></g><ellipse id="Combined-Shape" cx="100.519" cy="100.437" fill="url(#linearGradient-4)" rx="23.6" ry="23.581"/></g></g></g></g></svg>

+ 0
- 5
public/pro_icon.svg 查看文件

@@ -1,5 +0,0 @@
1
-<svg width="42" height="42" xmlns="http://www.w3.org/2000/svg">
2
- <g>
3
-  <path fill="#070707" d="m6.717392,13.773912l5.6,0c2.8,0 4.7,1.9 4.7,4.7c0,2.8 -2,4.7 -4.9,4.7l-2.5,0l0,4.3l-2.9,0l0,-13.7zm2.9,2.2l0,4.9l1.9,0c1.6,0 2.6,-0.9 2.6,-2.4c0,-1.6 -0.9,-2.4 -2.6,-2.4l-1.9,0l0,-0.1zm8.9,11.5l2.7,0l0,-5.7c0,-1.4 0.8,-2.3 2.2,-2.3c0.4,0 0.8,0.1 1,0.2l0,-2.4c-0.2,-0.1 -0.5,-0.1 -0.8,-0.1c-1.2,0 -2.1,0.7 -2.4,2l-0.1,0l0,-1.9l-2.7,0l0,10.2l0.1,0zm11.7,0.1c-3.1,0 -5,-2 -5,-5.3c0,-3.3 2,-5.3 5,-5.3s5,2 5,5.3c0,3.4 -1.9,5.3 -5,5.3zm0,-2.1c1.4,0 2.2,-1.1 2.2,-3.2c0,-2 -0.8,-3.2 -2.2,-3.2c-1.4,0 -2.2,1.2 -2.2,3.2c0,2.1 0.8,3.2 2.2,3.2z" class="st0" id="Ant-Design-Pro"/>
4
- </g>
5
-</svg>

+ 64
- 0
src/components/UploadFile/index.jsx 查看文件

@@ -0,0 +1,64 @@
1
+import React, { useCallback, useState } from 'react'
2
+import { UploadOutlined } from '@ant-design/icons';
3
+import { Upload, Button } from 'antd';
4
+import { uploadFile } from '@/services/api/rotationChart';
5
+
6
+const customRequest = ({ file, onError, onSuccess }) => {
7
+  const data = new FormData();
8
+  data.append('file', file);
9
+
10
+  uploadFile(data).then((res) => {
11
+    onSuccess(res.url)
12
+  }).catch((err) => {
13
+    onError(err);
14
+  })
15
+
16
+  return {
17
+    abort() {
18
+      console.log('upload progress is aborted.');
19
+    },
20
+  };
21
+}
22
+
23
+export default (props) => {
24
+  const { value, onChange, preview, ...inputProps } = props;
25
+  const [loading, setLoading] = useState(false);
26
+
27
+  const onUpload = useCallback((e) => {
28
+    const { files } = e.target;
29
+    if (!files || files.length < 1) return;
30
+
31
+    setLoading(true);
32
+    const data = new FormData();
33
+    data.append('file', files[0]);
34
+
35
+    uploadFile(data).then((res) => {
36
+      setLoading(false);
37
+      if (typeof onChange === 'function') {
38
+        onChange(res.url)
39
+      }
40
+    }).catch((err) => {
41
+      setLoading(false);
42
+      // onError(err);
43
+    })
44
+
45
+  }, [onChange])
46
+
47
+  const onClick = () => {
48
+    const input = document.createElement('input');
49
+    input.type = 'file';
50
+    Object.assign(input, inputProps);    
51
+    input.addEventListener('change', onUpload);
52
+    // input.removeEventListener('change', onUpload);
53
+    input.click();
54
+  }
55
+
56
+  return (
57
+    <div>
58
+      <Button icon={<UploadOutlined />} onClick={onClick}>上传文件</Button>
59
+      {
60
+        value && typeof preview === 'function' && preview(value)
61
+      }
62
+    </div>
63
+  )
64
+}

+ 1
- 1
src/components/UploadImage/index.jsx 查看文件

@@ -49,7 +49,7 @@ export default (props) => {
49 49
   return (
50 50
     <Upload
51 51
       // customRequest={uploadFile}
52
-      action={'/api/image/upload'}
52
+      action={'/api/upload'}
53 53
       accept='image/*'
54 54
       listType="picture-card"
55 55
       className="image-uploader"

+ 1
- 1
src/pages/User/Login/index.jsx 查看文件

@@ -63,7 +63,7 @@ const Login = () => {
63 63
       <div className={styles.content}>
64 64
         <LoginForm
65 65
           // logo={<img alt="logo" src="/logo.svg" />}
66
-          title="军工站"
66
+          title="军"
67 67
           onFinish={async (values) => {
68 68
             await handleSubmit(values);
69 69
           }}

+ 1
- 1
src/pages/document.ejs 查看文件

@@ -22,7 +22,7 @@
22 22
       name="viewport"
23 23
       content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
24 24
     />
25
-    <title>军工站</title>
25
+    <title>军</title>
26 26
     <link rel="icon" href="<%= context.config.publicPath +'favicon.ico'%>" type="image/x-icon" />
27 27
   </head>
28 28
   <body>

+ 13
- 34
src/pages/rotationChart/edit/index.jsx 查看文件

@@ -1,5 +1,6 @@
1 1
 import UploadImage from '@/components/UploadImage';
2 2
 import UploadVideo from '@/components/UploadVideo';
3
+import UploadFile from '@/components/UploadFile';
3 4
 import { addBanner, getBannerdById, updataBanner } from '@/services/api/rotationChart';
4 5
 import {
5 6
   PageContainer,
@@ -10,18 +11,18 @@ import {
10 11
   ProFormTextArea,
11 12
 } from '@ant-design/pro-components';
12 13
 import { history, useSearchParams } from '@umijs/max';
13
-import { Card, Col, message, Row, Space } from 'antd';
14
+import { Card, Col, message, Row, Space, Image } from 'antd';
14 15
 import { useEffect, useRef, useState } from 'react';
15 16
 
16 17
 export default (props) => {
17 18
   const [searchParams, setSearchParams] = useSearchParams();
18 19
   const id = searchParams.get('id');
19 20
   const [data, setData] = useState({});
21
+  const [imgLabel, setImgLabel] = useState('图片');
20 22
   const formRef = useRef();
21 23
   useEffect(() => {
22 24
     if (id) {
23 25
       getBannerdById(id).then((res) => {
24
-        console.log(res, '====---');
25 26
         setData(res);
26 27
 
27 28
         formRef.current.setFieldsValue(res);
@@ -83,20 +84,22 @@ export default (props) => {
83 84
             }}
84 85
             placeholder="轮播图类型"
85 86
             rules={[{ required: true, message: 'Please select your country!' }]}
87
+            onChange={({ value }) =>  setImgLabel(value === '1' ? '图片' : '封面')}
86 88
           />
87 89
           <ProForm.Item
88 90
             width="md"
89 91
             name="image"
90
-            label="图片"
92
+            label={imgLabel}
91 93
             // extra="longgggggggggggggggggggggggggggggggggg"
92 94
             // rules={[{ required: true, message: '请上传图片' }]}
93 95
           >
94
-            <UploadImage />
96
+            <UploadFile
97
+              accept="image/*"
98
+              preview={src => <div style={{ marginTop: '2em' }}><Image width={200} src={src} /></div>}
99
+            />
95 100
           </ProForm.Item>
96 101
           <ProForm.Item noStyle shouldUpdate>
97 102
             {(form) => {
98
-              console.log(form, '==');
99
-
100 103
               return form.getFieldValue('type') == '1' ? null : (
101 104
                 <ProForm.Item
102 105
                   width="md"
@@ -105,7 +108,10 @@ export default (props) => {
105 108
                   // extra="longgggggggggggggggggggggggggggggggggg"
106 109
                   // rules={[{ required: true, message: '请上传图片' }]}
107 110
                 >
108
-                  <UploadVideo />
111
+                  <UploadFile
112
+                    accept="video/*"
113
+                    preview={src => <div style={{ marginTop: '6px' }}><video height={360} width={480} src={src} controls /></div>}
114
+                  />
109 115
                 </ProForm.Item>
110 116
               );
111 117
             }}
@@ -130,32 +136,5 @@ export default (props) => {
130 136
         </ProForm>
131 137
       </Card>
132 138
     </PageContainer>
133
-    // <ModalForm
134
-    //   title={`${butttomTitle}`}
135
-    //   trigger={
136
-    //     <Button type="primary" {...butttomProps}>
137
-    //       {butttomTitle}
138
-    //     </Button>
139
-    //   }
140
-    //   autoFocusFirstInput
141
-    //   initialValues={{ type: '1', ...data }}
142
-    //   modalProps={{
143
-    //     onCancel: () => console.log('run'),
144
-    //   }}
145
-    //   submitTimeout={2000}
146
-    //   onFinish={onFinish}
147
-    // >
148
-
149
-    //   <ProFormText width="md" name="platform" label="平台名称" placeholder="请输入平台名称" />
150
-    //   <ProFormText width="md" name="ipAddr" label="IP地址" placeholder="请输入IP地址" />
151
-    //   {/* <ProFormText
152
-    //     width="md"
153
-    //     name="name"
154
-    //     label="推送频率"
155
-    //     tooltip="最长为 24 位"
156
-    //     placeholder="请输入名称"
157
-    //   /> */}
158
-    //   <ProFormTimePicker width="md" name="pushTime" label="推送时间" />
159
-    // </ModalForm>
160 139
   );
161 140
 };

+ 2
- 0
src/pages/rotationChart/list/index.jsx 查看文件

@@ -46,11 +46,13 @@ const RotationChartList = (props) => {
46 46
     {
47 47
       title: '封面图',
48 48
       dataIndex: 'image',
49
+      render: t => !t || '-' === t ? t : <img src={t}  style={{ width: '96px', borderRadius: '6px' }} />
49 50
     },
50 51
 
51 52
     {
52 53
       title: '视频',
53 54
       dataIndex: 'video',
55
+      render: () => '-',
54 56
     },
55 57
     {
56 58
       title: '状态',

+ 7
- 0
src/services/api/rotationChart.js 查看文件

@@ -35,3 +35,10 @@ export const updataBanner = (id, data) => request(`/banner/${id}`, { method: 'pu
35 35
  * @returns
36 36
  */
37 37
 export const deleteBanner = (id) => request(`/banner/${id}`, { method: 'delete' });
38
+
39
+/**
40
+ * 上传文件
41
+ * @param {*} id
42
+ * @returns
43
+ */
44
+ export const uploadFile = (data) => request(`/upload`, { method: 'POST', data });

+ 1
- 4
src/utils/request.js 查看文件

@@ -8,7 +8,7 @@ function requestInterceptor(url, options) {
8 8
 
9 9
   return {
10 10
     // url,
11
-    url: `/api${url}`,
11
+    url: `${API_BASE}/api${url}`,
12 12
     options: {
13 13
       ...options,
14 14
       headers: {
@@ -20,10 +20,7 @@ function requestInterceptor(url, options) {
20 20
 }
21 21
 
22 22
 function responseInterceptor(response) {
23
-  console.log(response, '44114');
24 23
   const { data } = response;
25
-
26
-  console.log(data, data.data, '--==666=');
27 24
   if (data.code === 1000) {
28 25
     return data;
29 26
   } else {