@lxzy/code-snippet 0.0.16 → 0.0.18
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/.editorconfig +0 -0
- package/.omo/run-continuation/ses_06cbc1e51ffeeonXDa7nL4s4eI.json +10 -0
- package/.omo/run-continuation/ses_082cd79efffeCIKYhEEM7T5tIa.json +10 -0
- package/build/cdn/antd.min.css +10 -0
- package/build/cdn/antd.min.js +26 -0
- package/build/cdn/axios.min.js +3 -0
- package/build/cdn/lodash.min.js +140 -0
- package/build/cdn/moment.min.js +2 -0
- package/build/cdn/react-dom.development.min.js +1 -0
- package/build/cdn/react-dom.production.min.js +245 -0
- package/build/cdn/react.development.min.js +1 -0
- package/build/cdn/react.production.min.js +31 -0
- package/build/code-snippet.css +2 -0
- package/build/code-snippet.iife.js +219 -0
- package/index.html +1 -1
- package/package.json +14 -10
- package/src/app-vite.tsx +30 -25
- package/src/components/ErrorBoundary/index.tsx +1 -21
- package/src/{global.css → global.less} +8 -0
- package/src/pages/home.tsx +63 -4
- package/src/pages/ly/ProFormUpload/icons/audio.png +0 -0
- package/src/pages/ly/ProFormUpload/icons/excel.png +0 -0
- package/src/pages/ly/ProFormUpload/icons/file.png +0 -0
- package/src/pages/ly/ProFormUpload/icons/pdf.png +0 -0
- package/src/pages/ly/ProFormUpload/icons/ppt.png +0 -0
- package/src/pages/ly/ProFormUpload/icons/rar.png +0 -0
- package/src/pages/ly/ProFormUpload/icons/txt.png +0 -0
- package/src/pages/ly/ProFormUpload/icons/video.png +0 -0
- package/src/pages/ly/ProFormUpload/icons/word.png +0 -0
- package/src/pages/ly/ProFormUpload/icons/zip.png +0 -0
- package/src/pages/ly/ProFormUpload/index.less +158 -0
- package/src/pages/ly/ProFormUpload/index.tsx +276 -0
- package/src/pages/ly/ProFormUpload/service.ts +79 -0
- package/src/umi/index.ts +2 -2
- package/tsconfig.json +10 -5
- package/vite.config.ts +0 -44
- package/src/main.tsx +0 -24
package/index.html
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lxzy/code-snippet",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"files": [
|
|
5
5
|
"*",
|
|
6
6
|
"!dist",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"pub": "npm publish"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ant-design/icons": "^
|
|
21
|
-
"@ant-design/pro-components": "^
|
|
20
|
+
"@ant-design/icons": "^4",
|
|
21
|
+
"@ant-design/pro-components": "^1",
|
|
22
22
|
"@ice/stark-app": "^1.5.0",
|
|
23
23
|
"ahooks": "^3.1.9",
|
|
24
|
-
"antd": "
|
|
24
|
+
"antd": "4",
|
|
25
25
|
"axios": "^1.18.1",
|
|
26
26
|
"classnames": "^2.3.0",
|
|
27
27
|
"dayjs": "^1.11.0",
|
|
@@ -31,17 +31,15 @@
|
|
|
31
31
|
"lodash-es": "^4.17.21",
|
|
32
32
|
"mockjs": "^1.1.0",
|
|
33
33
|
"moment": "^2.29.0",
|
|
34
|
-
"react": "^
|
|
35
|
-
"react-dom": "^
|
|
36
|
-
"react-router
|
|
37
|
-
"
|
|
34
|
+
"react": "^17",
|
|
35
|
+
"react-dom": "^17",
|
|
36
|
+
"react-router": "5.3.4",
|
|
37
|
+
"react-router-dom": "5.3.4",
|
|
38
38
|
"unstated-next": "^1.1.0",
|
|
39
39
|
"validator": "^13.7.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^22.1.0",
|
|
43
|
-
"@types/react": "^18.0.0",
|
|
44
|
-
"@types/react-dom": "^18.0.0",
|
|
45
43
|
"@vitejs/plugin-react-swc": "^3",
|
|
46
44
|
"less": "^4.6.7",
|
|
47
45
|
"prettier": "^2.2.0",
|
|
@@ -49,5 +47,11 @@
|
|
|
49
47
|
"vite": "^6.0.0",
|
|
50
48
|
"vite-plugin-external": "^6.2.2",
|
|
51
49
|
"vite-plugin-mock": "^3.0.2"
|
|
50
|
+
},
|
|
51
|
+
"resolutions": {
|
|
52
|
+
"@types/react": "^17",
|
|
53
|
+
"@types/react-dom": "^17",
|
|
54
|
+
"@types/react-router": "5.1.20",
|
|
55
|
+
"@types/react-router-dom": "5.3.3"
|
|
52
56
|
}
|
|
53
57
|
}
|
package/src/app-vite.tsx
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { Suspense, lazy, useEffect } from 'react';
|
|
2
|
+
import ReactDom from 'react-dom';
|
|
2
3
|
import {
|
|
3
|
-
|
|
4
|
+
Switch,
|
|
4
5
|
Route,
|
|
5
|
-
|
|
6
|
+
Redirect,
|
|
6
7
|
useLocation,
|
|
7
|
-
|
|
8
|
+
HashRouter,
|
|
8
9
|
} from 'react-router-dom';
|
|
9
|
-
|
|
10
10
|
import history from '@/umi';
|
|
11
11
|
import BasicLayout from '@/layouts/index';
|
|
12
12
|
import { getBasename } from '@ice/stark-app';
|
|
13
13
|
import routes from '../routes';
|
|
14
14
|
import { PageLoading } from '@ant-design/pro-components';
|
|
15
15
|
import { ConfigProvider } from 'antd';
|
|
16
|
+
import 'antd/es/notification/style/index.less';
|
|
16
17
|
import moment from 'moment';
|
|
17
18
|
import 'moment/dist/locale/zh-cn';
|
|
19
|
+
import './global.less';
|
|
20
|
+
|
|
18
21
|
moment.locale('zh-cn');
|
|
19
22
|
|
|
20
23
|
const pageModules = import.meta.glob([
|
|
@@ -43,32 +46,34 @@ const RouteWrapper = ({ componentPath }) => {
|
|
|
43
46
|
const App = () => {
|
|
44
47
|
return (
|
|
45
48
|
<ConfigProvider>
|
|
46
|
-
<
|
|
49
|
+
<HashRouter>
|
|
47
50
|
<BasicLayout>
|
|
48
51
|
<Suspense fallback={<PageLoading />}>
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
<Switch>
|
|
53
|
+
{routes.map((route, i) =>
|
|
54
|
+
route.redirect ? (
|
|
55
|
+
<Route key={route.path || i} path={route.path} exact>
|
|
56
|
+
<Redirect to={route.redirect} />
|
|
57
|
+
</Route>
|
|
58
|
+
) : (
|
|
59
|
+
<Route
|
|
60
|
+
key={route.path || i}
|
|
61
|
+
path={route.path}
|
|
62
|
+
exact={route.path !== undefined}
|
|
63
|
+
render={() => (
|
|
64
|
+
<RouteWrapper componentPath={route.component} />
|
|
65
|
+
)}
|
|
66
|
+
/>
|
|
67
|
+
),
|
|
68
|
+
)}
|
|
69
|
+
</Switch>
|
|
70
|
+
</Suspense>
|
|
68
71
|
</BasicLayout>
|
|
69
|
-
</
|
|
72
|
+
</HashRouter>
|
|
70
73
|
</ConfigProvider>
|
|
71
74
|
);
|
|
72
75
|
};
|
|
73
76
|
|
|
74
77
|
export default App;
|
|
78
|
+
|
|
79
|
+
ReactDom.render(<App></App>, document.getElementById('root'));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Button, Result } from 'antd';
|
|
3
3
|
|
|
4
|
-
class ErrorBoundary extends React.Component {
|
|
4
|
+
class ErrorBoundary extends React.Component<any> {
|
|
5
5
|
state = { hasError: false, isChunkError: false, errorMessage: '' };
|
|
6
6
|
|
|
7
7
|
static getDerivedStateFromError(error) {
|
|
@@ -21,10 +21,6 @@ class ErrorBoundary extends React.Component {
|
|
|
21
21
|
window.location.reload();
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
handleRetry = () => {
|
|
25
|
-
this.setState({ hasError: false, isChunkError: false });
|
|
26
|
-
};
|
|
27
|
-
|
|
28
24
|
render() {
|
|
29
25
|
if (this.state.hasError) {
|
|
30
26
|
if (this.state.isChunkError) {
|
|
@@ -37,26 +33,10 @@ class ErrorBoundary extends React.Component {
|
|
|
37
33
|
<Button type="primary" key="refresh" onClick={this.handleRefresh}>
|
|
38
34
|
刷新浏览器
|
|
39
35
|
</Button>,
|
|
40
|
-
<Button key="retry" onClick={this.handleRetry}>
|
|
41
|
-
重试
|
|
42
|
-
</Button>,
|
|
43
36
|
]}
|
|
44
37
|
/>
|
|
45
38
|
);
|
|
46
39
|
}
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Result
|
|
50
|
-
status="error"
|
|
51
|
-
title="页面出错了"
|
|
52
|
-
subTitle={this.state.errorMessage}
|
|
53
|
-
extra={
|
|
54
|
-
<Button type="primary" onClick={this.handleRefresh}>
|
|
55
|
-
刷新浏览器
|
|
56
|
-
</Button>
|
|
57
|
-
}
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
60
40
|
}
|
|
61
41
|
|
|
62
42
|
return this.props.children;
|
package/src/pages/home.tsx
CHANGED
|
@@ -1,13 +1,72 @@
|
|
|
1
1
|
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import styles from './index.module.less';
|
|
3
|
-
import { DatePicker } from 'antd';
|
|
3
|
+
import { DatePicker, notification } from 'antd';
|
|
4
4
|
|
|
5
5
|
export default function Home(props) {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const [duration, setDuration] = useState(null);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
function findBox(dataView, type, offset, end) {
|
|
10
|
+
while (offset < end) {
|
|
11
|
+
const size = dataView.getUint32(offset);
|
|
12
|
+
if (size === 0) break;
|
|
13
|
+
const boxType = String.fromCharCode(
|
|
14
|
+
dataView.getUint8(offset + 4),
|
|
15
|
+
dataView.getUint8(offset + 5),
|
|
16
|
+
dataView.getUint8(offset + 6),
|
|
17
|
+
dataView.getUint8(offset + 7),
|
|
18
|
+
);
|
|
19
|
+
if (boxType === type) return offset;
|
|
20
|
+
offset += size;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getVideoDuration(buffer) {
|
|
26
|
+
const dataView = new DataView(buffer);
|
|
27
|
+
const fileEnd = buffer.byteLength;
|
|
28
|
+
|
|
29
|
+
let moovOffset = findBox(dataView, 'moov', 0, fileEnd);
|
|
30
|
+
if (moovOffset === null) return null;
|
|
31
|
+
|
|
32
|
+
const moovSize = dataView.getUint32(moovOffset);
|
|
33
|
+
const mvhdOffset = findBox(
|
|
34
|
+
dataView,
|
|
35
|
+
'mvhd',
|
|
36
|
+
moovOffset + 8,
|
|
37
|
+
moovOffset + moovSize,
|
|
38
|
+
);
|
|
39
|
+
if (mvhdOffset === null) return null;
|
|
40
|
+
|
|
41
|
+
const version = dataView.getUint8(mvhdOffset + 8);
|
|
42
|
+
let timescale, duration;
|
|
43
|
+
|
|
44
|
+
if (version === 0) {
|
|
45
|
+
timescale = dataView.getUint32(mvhdOffset + 12 + 8);
|
|
46
|
+
duration = dataView.getUint32(mvhdOffset + 12 + 12);
|
|
47
|
+
} else {
|
|
48
|
+
const view64 = new DataView(buffer);
|
|
49
|
+
timescale = view64.getUint32(mvhdOffset + 20 + 8);
|
|
50
|
+
const high = view64.getUint32(mvhdOffset + 20 + 12);
|
|
51
|
+
const low = view64.getUint32(mvhdOffset + 20 + 16);
|
|
52
|
+
duration = high * 2 ** 32 + low;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return duration / timescale;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
pm.sendRequest('http://vjs.zencdn.net/v/oceans.mp4', function (err, res) {
|
|
59
|
+
const dur = getVideoDuration(res.rawBody.buffer);
|
|
60
|
+
console.log('视频时长(秒):', dur);
|
|
61
|
+
});
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
8
64
|
return (
|
|
9
65
|
<div>
|
|
10
|
-
<
|
|
66
|
+
<p>
|
|
67
|
+
视频时长:
|
|
68
|
+
{duration !== null ? `${duration.toFixed(2)} 秒` : '加载中...'}
|
|
69
|
+
</p>
|
|
11
70
|
</div>
|
|
12
71
|
);
|
|
13
72
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// 包裹容器:卡片模式下自定义卡片因多了文件名而高于 antd 默认项高,
|
|
2
|
+
// 需把列表项容器高度改为自适应,否则换行后会与下一行重叠。
|
|
3
|
+
// antd v5 用 cssinjs 运行时注入样式,与本地选择器特异性相同时会覆盖本地样式,故用 !important 提升优先级。
|
|
4
|
+
.wrapper {
|
|
5
|
+
:global {
|
|
6
|
+
.ant-upload-list-picture-card {
|
|
7
|
+
align-items: flex-start;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ant-upload-list-picture-card .ant-upload-list-item-container {
|
|
11
|
+
height: auto !important;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.card {
|
|
17
|
+
position: relative;
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
align-items: center;
|
|
21
|
+
width: 104px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.thumb {
|
|
25
|
+
position: relative;
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
width: 104px;
|
|
30
|
+
height: 104px;
|
|
31
|
+
padding: 8px;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
background-color: #fafafa;
|
|
34
|
+
border: 1px solid #d9d9d9;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
|
|
38
|
+
img {
|
|
39
|
+
max-width: 100%;
|
|
40
|
+
max-height: 100%;
|
|
41
|
+
object-fit: contain;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
video {
|
|
45
|
+
max-width: 100%;
|
|
46
|
+
max-height: 100%;
|
|
47
|
+
object-fit: contain;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.mask {
|
|
52
|
+
position: absolute;
|
|
53
|
+
inset: 0;
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
gap: 12px;
|
|
58
|
+
color: #fff;
|
|
59
|
+
font-size: 16px;
|
|
60
|
+
background-color: rgba(0, 0, 0, 0.45);
|
|
61
|
+
opacity: 0;
|
|
62
|
+
transition: opacity 0.2s;
|
|
63
|
+
|
|
64
|
+
span {
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
|
|
67
|
+
&:hover {
|
|
68
|
+
color: #40a9ff;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.thumb:hover .mask {
|
|
74
|
+
opacity: 1;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.name {
|
|
78
|
+
width: 104px;
|
|
79
|
+
margin-top: 4px;
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
color: rgba(0, 0, 0, 0.65);
|
|
82
|
+
font-size: 12px;
|
|
83
|
+
line-height: 18px;
|
|
84
|
+
white-space: nowrap;
|
|
85
|
+
text-overflow: ellipsis;
|
|
86
|
+
text-align: center;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.error {
|
|
90
|
+
color: #ff4d4f;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 列表模式(picture / text)
|
|
94
|
+
.listItem {
|
|
95
|
+
display: flex;
|
|
96
|
+
align-items: center;
|
|
97
|
+
gap: 8px;
|
|
98
|
+
padding: 4px 8px;
|
|
99
|
+
border-radius: 6px;
|
|
100
|
+
|
|
101
|
+
&:hover {
|
|
102
|
+
background-color: #f5f5f5;
|
|
103
|
+
|
|
104
|
+
.listActions {
|
|
105
|
+
opacity: 1;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.listThumb {
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
flex: none;
|
|
115
|
+
width: 40px;
|
|
116
|
+
height: 40px;
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
cursor: pointer;
|
|
119
|
+
|
|
120
|
+
img,
|
|
121
|
+
video {
|
|
122
|
+
max-width: 100%;
|
|
123
|
+
max-height: 100%;
|
|
124
|
+
object-fit: contain;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.listName {
|
|
129
|
+
flex: auto;
|
|
130
|
+
overflow: hidden;
|
|
131
|
+
color: rgba(0, 0, 0, 0.65);
|
|
132
|
+
font-size: 14px;
|
|
133
|
+
white-space: nowrap;
|
|
134
|
+
text-overflow: ellipsis;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
|
|
137
|
+
&:hover {
|
|
138
|
+
color: #40a9ff;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.listActions {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex: none;
|
|
145
|
+
gap: 12px;
|
|
146
|
+
color: rgba(0, 0, 0, 0.45);
|
|
147
|
+
font-size: 14px;
|
|
148
|
+
opacity: 0;
|
|
149
|
+
transition: opacity 0.2s;
|
|
150
|
+
|
|
151
|
+
span {
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
|
|
154
|
+
&:hover {
|
|
155
|
+
color: #40a9ff;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|