Skip to content

Commit 9a28584

Browse files
author
Marvin
committed
feat:add upload component
1 parent 94a5cd3 commit 9a28584

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+33316
-26
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"version": "0.0.7"
3+
}

packages/web-core-ui/packages/ui/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
"@wu-component/wu-tooltip": "latest",
132132
"@wu-component/wu-transition": "latest",
133133
"@wu-component/wu-tree": "latest",
134-
"@wu-component/wu-tree-v2": "latest"
134+
"@wu-component/wu-tree-v2": "latest",
135+
"@wu-component/wu-upload": "latest"
135136
},
136137
"repository": {
137138
"type": "git",

packages/web-core-ui/packages/ui/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ export * from '@wu-component/wu-transition/src/index';
5252

5353
/*********************************复杂组件*************************************/
5454
export * from '@wu-component/wu-date-picker/src/index';
55+
export * from '@wu-component/wu-upload/src/index';
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_size = 4
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/**
2+
dist/**
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
sourceType: 'module',
5+
},
6+
plugins: [ '@typescript-eslint/eslint-plugin' ],
7+
extends: [
8+
'plugin:@typescript-eslint/eslint-recommended',
9+
'plugin:@typescript-eslint/recommended',
10+
'prettier',
11+
'prettier/@typescript-eslint',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
jest: true,
17+
'shared-node-browser': true,
18+
es6: true
19+
},
20+
rules: {
21+
'@typescript-eslint/no-empty-interface': 'off',
22+
'@typescript-eslint/no-namespace': 'off',
23+
'@typescript-eslint/ban-types': 'off',
24+
'@typescript-eslint/no-var-requires': 'off',
25+
'@typescript-eslint/interface-name-prefix': 'off',
26+
'@typescript-eslint/explicit-function-return-type': 'off',
27+
'@typescript-eslint/no-explicit-any': 'off',
28+
'@typescript-eslint/explicit-module-boundary-types': 'off',
29+
'@typescript-eslint/ban-ts-comment': 'off',
30+
'@typescript-eslint/no-empty-function': 'off',
31+
'@typescript-eslint/no-unused-vars': 'off',
32+
'prefer-rest-params': 'off',
33+
'@typescript-eslint/no-this-alias': 'off',
34+
'semi':[ 'error','always' ],
35+
'prefer-spread': 'off',
36+
"array-bracket-spacing": [ "error","always" ],
37+
"object-curly-spacing": [ "error","always" ]
38+
},
39+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 300,
5+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import { resolve } from "path";
2+
import { terser } from "rollup-plugin-terser";
3+
import { nodeResolve } from "@rollup/plugin-node-resolve";
4+
import commonjs from "@rollup/plugin-commonjs";
5+
import postcss from "rollup-plugin-postcss";
6+
import typescript from "rollup-plugin-typescript2";
7+
import json from "@rollup/plugin-json";
8+
import replace from "@rollup/plugin-replace";
9+
import scss from 'rollup-plugin-scss'
10+
import autoprefixer from 'autoprefixer'
11+
import url from '@rollup/plugin-url';
12+
const output = resolve(__dirname, "../dist");
13+
const getPath = _path => resolve(__dirname, _path);
14+
// import pkg from "../package.json";
15+
//const name = pkg.name;
16+
const name = 'WebUIPlus';
17+
const extensions = [
18+
'.js',
19+
'.ts',
20+
'.tsx'
21+
]
22+
let defaults = { compilerOptions: { declaration: true } };
23+
24+
25+
26+
// 单独打包
27+
const config = [
28+
{
29+
input: `./src/index.tsx`,
30+
plugins: [
31+
terser(),
32+
url({
33+
include: ['**/*.svg', '**/*.png', '**/*.jp(e)?g', '**/*.gif', '**/*.webp', '**/*.ttf', '**/*.woff']
34+
}),
35+
nodeResolve(),
36+
commonjs(),
37+
postcss({
38+
name: 'index',
39+
extensions: [ '.css', 'scss' ],
40+
to: `./dist/index.css`,
41+
plugins: [
42+
autoprefixer()
43+
],
44+
// extract: `${output}/${name}/lib/index.css`
45+
extract: false
46+
}),
47+
// tsPlugin,
48+
typescript({
49+
tsconfig: getPath('../tsconfig.build.json'), // 导入本地ts配置
50+
tsconfigDefaults: defaults,
51+
tsconfigOverride: {
52+
compilerOptions: {
53+
declaration: true
54+
}
55+
},
56+
extensions
57+
}),
58+
json(),
59+
replace({
60+
preventAssignment: true
61+
})
62+
],
63+
output: [
64+
{ name: name, file: `${output}/index.umd.js`, format: 'umd' },
65+
{ file: `${output}/index.cjs.js`, format: 'cjs' },
66+
{ file: `${output}/index.esm.js`, format: 'es' }
67+
68+
]
69+
}
70+
]
71+
72+
export default config;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
3+
const { exists, copyDir} = require('./lib/copy')
4+
const fs = require("fs");
5+
const path = require("path");
6+
7+
const fsCopy = (sourcePath, deptPath)=> {
8+
exists(sourcePath,deptPath, copyDir)
9+
}
10+
11+
function copyDirFun(srcDir, desDir, callback) {
12+
fs.readdir(srcDir, { withFileTypes: true }, (err, files) => {
13+
for (const file of files) {
14+
//判断是否为文件夹
15+
if (file.isDirectory()) {
16+
const dirS = path.resolve(srcDir, file.name);
17+
const dirD = path.resolve(desDir, file.name);
18+
//判断是否存在dirD文件夹
19+
if (!fs.existsSync(dirD)) {
20+
fs.mkdir(dirD, (err) => {
21+
if (err) console.log(err);
22+
});
23+
}
24+
copyDir(dirS, dirD);
25+
} else {
26+
const srcFile = path.resolve(srcDir, file.name);
27+
const desFile = path.resolve(desDir, file.name);
28+
fs.copyFileSync(srcFile, desFile);
29+
callback()
30+
}
31+
}
32+
})
33+
}
34+
module.exports = {
35+
fsCopy,
36+
copyDirFun
37+
}
38+
39+
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
const fs = require('fs')
2+
3+
/**
4+
* 复制一个文件夹下的文件到另一个文件夹
5+
* @param src 源文件夹,即需要写出的文件
6+
* @param dst 目标文件夹,需要写入的文件
7+
*/
8+
const copyDir = function (src, dst) {
9+
if(!fs.existsSync(src)) {
10+
return;
11+
}
12+
// 读取目录中的所有文件/目录
13+
fs.readdir(src, function (err, paths) {
14+
console.log(src);
15+
if (err) {
16+
throw err
17+
}
18+
paths.forEach(function (path) {
19+
const _src = src + '/' + path
20+
const _dst = dst + '/' + path
21+
let readable;
22+
let writable
23+
fs.stat(_src, function (err, st) {
24+
if (err) {
25+
throw err
26+
}
27+
// 判断是否为文件
28+
if (st.isFile()) {
29+
// 创建读取流
30+
readable = fs.createReadStream(_src)
31+
// 创建写入流
32+
writable = fs.createWriteStream(_dst)
33+
// 通过管道来传输流
34+
readable.pipe(writable)
35+
}
36+
// 如果是目录则递归调用自身
37+
else if (st.isDirectory()) {
38+
exists(_src, _dst, copyDir)
39+
}
40+
})
41+
})
42+
})
43+
}
44+
/**
45+
* 在复制目录前需要判断该目录是否存在,
46+
* 不存在需要先创建目录
47+
* @param src
48+
* @param dst
49+
* @param callback
50+
*/
51+
const exists = function (src, dst, callback) {
52+
// 如果路径存在,则返回 true,否则返回 false。
53+
if (fs.existsSync(dst)) {
54+
callback(src, dst)
55+
} else {
56+
fs.mkdir(dst, function () {
57+
callback(src, dst)
58+
})
59+
}
60+
}
61+
/**
62+
* 判断数组中的元素是否包含此字符串
63+
* @param arr
64+
* @param obj
65+
* @returns {boolean}
66+
*/
67+
const contains = function (arr, obj) {
68+
let flag = false
69+
arr.map((val) => {
70+
if (obj.includes(val)) {
71+
flag = true
72+
}
73+
})
74+
return flag
75+
}
76+
77+
module.exports = {
78+
exists,
79+
copyDir
80+
}

0 commit comments

Comments
 (0)