oipage 1.7.0 → 1.8.0-alpha.1

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.
Files changed (101) hide show
  1. package/.github/FUNDING.yml +11 -11
  2. package/AUTHORS.txt +6 -6
  3. package/CHANGELOG +9 -1
  4. package/LICENSE +20 -20
  5. package/README.md +1 -9
  6. package/bin/WebSocket/decodeWsFrame.js +43 -43
  7. package/bin/WebSocket/encodeWsFrame.js +28 -28
  8. package/bin/WebSocket/headersToJSON.js +26 -26
  9. package/bin/WebSocket/index.js +80 -80
  10. package/bin/data/mineTypes.json +104 -104
  11. package/bin/disk.js +42 -42
  12. package/bin/help.js +3 -0
  13. package/bin/intercept.js +15 -15
  14. package/bin/network.js +21 -21
  15. package/bin/run +5 -3
  16. package/bin/serve.d.ts +7 -0
  17. package/bin/serve.js +9 -1
  18. package/bin/template/404.html +186 -186
  19. package/bin/tools/deleteEmptyFolder.js +23 -23
  20. package/bin/tools/format.js +75 -75
  21. package/bin/tools/network.js +42 -42
  22. package/bin/tools/openBrowser.js +26 -0
  23. package/bin/tools/resolve404.js +83 -83
  24. package/bin/tools/resolveImport.js +88 -88
  25. package/bin/website-htmls/components/ui-select-file/index.html +7 -7
  26. package/bin/website-htmls/components/ui-select-file/index.js +37 -37
  27. package/bin/website-htmls/components/ui-select-file/index.scss +44 -44
  28. package/bin/website-htmls/dialogs/imageSize/index.html +54 -54
  29. package/bin/website-htmls/dialogs/imageSize/index.js +53 -53
  30. package/bin/website-htmls/dialogs/imageSize/index.scss +138 -138
  31. package/bin/website-htmls/dialogs/index.js +52 -52
  32. package/bin/website-htmls/images/addFile.svg +1 -1
  33. package/bin/website-htmls/images/img-to-pdf.svg +1 -1
  34. package/bin/website-htmls/index.html +17 -17
  35. package/bin/website-htmls/main.js +13 -13
  36. package/bin/website-htmls/pages/App/index.html +6 -6
  37. package/bin/website-htmls/pages/App/index.js +22 -22
  38. package/bin/website-htmls/pages/App/index.scss +43 -43
  39. package/bin/website-htmls/pages/appStore/index.html +5 -24
  40. package/bin/website-htmls/pages/appStore/index.js +19 -19
  41. package/bin/website-htmls/pages/appStore/index.scss +6 -4
  42. package/bin/website-htmls/pages/chart/index.html +8 -8
  43. package/bin/website-htmls/pages/chart/index.js +72 -72
  44. package/bin/website-htmls/pages/chart/index.scss +73 -72
  45. package/bin/website-htmls/pages/home/index.html +22 -0
  46. package/bin/website-htmls/pages/home/index.js +20 -0
  47. package/bin/website-htmls/pages/home/index.scss +29 -0
  48. package/bin/website-htmls/pages/image-editor/index.html +27 -27
  49. package/bin/website-htmls/pages/image-editor/index.js +106 -106
  50. package/bin/website-htmls/pages/image-editor/index.scss +47 -45
  51. package/bin/website-htmls/pages/img-to-pdf/index.html +3 -3
  52. package/bin/website-htmls/pages/img-to-pdf/index.js +44 -44
  53. package/bin/website-htmls/pages/img-to-pdf/index.scss +4 -4
  54. package/bin/website-htmls/router.config.js +26 -19
  55. package/bin/website-htmls/styles/normalize.css +94 -94
  56. package/bin/website-plugins/intercept/chart.js +33 -33
  57. package/bin/website-plugins/intercept/getPackage.js +17 -17
  58. package/bin/website-plugins/intercept/head.js +8 -8
  59. package/bin/website-plugins/intercept/index.js +8 -8
  60. package/bin/website-plugins/intercept/oipage-vislite-intercept.js +30 -30
  61. package/bin/website-plugins/intercept/oipage-zipaper-intercept.js +36 -36
  62. package/bin/website-plugins/loader/index.js +11 -11
  63. package/bin/website-plugins/loader/oipage-html-loader.js +7 -7
  64. package/bin/website-plugins/loader/oipage-scss-loader.js +149 -149
  65. package/nodejs/animation/index.d.ts +19 -19
  66. package/nodejs/animation/index.js +120 -112
  67. package/nodejs/cmdlog/index.d.ts +20 -20
  68. package/nodejs/cmdlog/index.js +75 -75
  69. package/nodejs/disk/index.d.ts +47 -47
  70. package/nodejs/disk/index.js +165 -165
  71. package/nodejs/format/index.d.ts +29 -29
  72. package/nodejs/format/index.js +107 -107
  73. package/nodejs/json/index.d.ts +9 -9
  74. package/nodejs/json/index.js +206 -206
  75. package/nodejs/logform/index.d.ts +18 -18
  76. package/nodejs/logform/index.js +94 -94
  77. package/nodejs/reader/index.d.ts +32 -32
  78. package/nodejs/reader/index.js +20 -20
  79. package/nodejs/throttle/index.d.ts +30 -30
  80. package/nodejs/throttle/index.js +50 -50
  81. package/package.json +1 -1
  82. package/web/XMLHttpRequest/index.d.ts +17 -17
  83. package/web/XMLHttpRequest/index.js +60 -60
  84. package/web/animation/index.d.ts +19 -19
  85. package/web/animation/index.js +120 -112
  86. package/web/format/index.d.ts +29 -29
  87. package/web/format/index.js +107 -107
  88. package/web/json/index.d.ts +9 -9
  89. package/web/json/index.js +206 -206
  90. package/web/onReady/index.d.ts +7 -7
  91. package/web/onReady/index.js +8 -8
  92. package/web/performChunk/index.d.ts +4 -4
  93. package/web/performChunk/index.js +19 -19
  94. package/web/reader/index.d.ts +32 -32
  95. package/web/reader/index.js +20 -20
  96. package/web/style/index.d.ts +21 -21
  97. package/web/style/index.js +19 -19
  98. package/web/throttle/index.d.ts +30 -30
  99. package/web/throttle/index.js +50 -50
  100. package/snipping/chart.png +0 -0
  101. package/snipping/image-editor.png +0 -0
@@ -1,82 +1,82 @@
1
1
  /*!
2
- * cmdlog of OIPage v1.7.0
2
+ * cmdlog of OIPage v1.8.0-alpha.1
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- // 预定义的常量
7
- const MOVE_LEFT = Buffer.from('1b5b3130303044', 'hex').toString();
8
- const MOVE_UP = Buffer.from('1b5b3141', 'hex').toString();
9
- const CLEAR_LINE = Buffer.from('1b5b304b', 'hex').toString();
10
-
11
- // 计算字符串长度的方法
12
- const stringwidth = function (str) {
13
- return str.length;
14
- };
15
-
16
- /**
17
- * 不换行打印
18
- * @param {string} stream 打印的内容
19
- */
20
- let linelog = (function (stream) {
21
-
22
- // 用来记录前置有多少行需要回退
23
- let prevLineCount = 0;
24
-
25
- // 返回实际同行打印的方法
26
- return function (nextStr) {
27
- if (arguments.length == 0) {
28
- prevLineCount = 0;
29
- return;
30
- }
31
- let txt = "";
32
-
33
- // 清除屏幕
34
- for (let i = 0; i < prevLineCount; i++) {
35
- txt += MOVE_LEFT + CLEAR_LINE + (i < prevLineCount - 1 ? MOVE_UP : '');
36
- }
37
-
38
- // 写入屏幕
39
- stream.write(txt + nextStr);
40
-
41
- // 重新计算需要回滚多少行
42
- let prevLines = nextStr.split('\n');
43
- prevLineCount = 0;
44
- for (let i = 0; i < prevLines.length; i++) {
45
- // 因为有时候文字过多,因此拿总长度除以一行长度得出真实的行数
46
- prevLineCount += (Math.ceil(stringwidth(prevLines[i]) / stream.columns) || 1);
47
- }
48
-
49
- };
50
- })(process.stdout);
51
-
52
- /**
53
- * 进度打印
54
- *
55
- * @param {number} percentum 进度0-100
56
- * @param {string} stream 说明文字,可选
57
- */
58
- function deeplog (percentum, stream) {
59
- if (arguments.length == 0) {
60
- linelog();
61
- return;
62
- }
63
-
64
- if (arguments.length <= 1) stream = "";
65
-
66
- let txt = "",
67
- i = 0;
68
-
69
- // 补充已经有的进度
70
- for (; i <= percentum && i <= 100; i += 5) {
71
- txt += "█";
72
- }
73
-
74
- // 补充余下的空白
75
- for (; i <= 100; i += 5) {
76
- txt += "░";
77
- }
78
-
79
- linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
6
+ // 预定义的常量
7
+ const MOVE_LEFT = Buffer.from('1b5b3130303044', 'hex').toString();
8
+ const MOVE_UP = Buffer.from('1b5b3141', 'hex').toString();
9
+ const CLEAR_LINE = Buffer.from('1b5b304b', 'hex').toString();
10
+
11
+ // 计算字符串长度的方法
12
+ const stringwidth = function (str) {
13
+ return str.length;
14
+ };
15
+
16
+ /**
17
+ * 不换行打印
18
+ * @param {string} stream 打印的内容
19
+ */
20
+ let linelog = (function (stream) {
21
+
22
+ // 用来记录前置有多少行需要回退
23
+ let prevLineCount = 0;
24
+
25
+ // 返回实际同行打印的方法
26
+ return function (nextStr) {
27
+ if (arguments.length == 0) {
28
+ prevLineCount = 0;
29
+ return;
30
+ }
31
+ let txt = "";
32
+
33
+ // 清除屏幕
34
+ for (let i = 0; i < prevLineCount; i++) {
35
+ txt += MOVE_LEFT + CLEAR_LINE + (i < prevLineCount - 1 ? MOVE_UP : '');
36
+ }
37
+
38
+ // 写入屏幕
39
+ stream.write(txt + nextStr);
40
+
41
+ // 重新计算需要回滚多少行
42
+ let prevLines = nextStr.split('\n');
43
+ prevLineCount = 0;
44
+ for (let i = 0; i < prevLines.length; i++) {
45
+ // 因为有时候文字过多,因此拿总长度除以一行长度得出真实的行数
46
+ prevLineCount += (Math.ceil(stringwidth(prevLines[i]) / stream.columns) || 1);
47
+ }
48
+
49
+ };
50
+ })(process.stdout);
51
+
52
+ /**
53
+ * 进度打印
54
+ *
55
+ * @param {number} percentum 进度0-100
56
+ * @param {string} stream 说明文字,可选
57
+ */
58
+ function deeplog (percentum, stream) {
59
+ if (arguments.length == 0) {
60
+ linelog();
61
+ return;
62
+ }
63
+
64
+ if (arguments.length <= 1) stream = "";
65
+
66
+ let txt = "",
67
+ i = 0;
68
+
69
+ // 补充已经有的进度
70
+ for (; i <= percentum && i <= 100; i += 5) {
71
+ txt += "█";
72
+ }
73
+
74
+ // 补充余下的空白
75
+ for (; i <= 100; i += 5) {
76
+ txt += "░";
77
+ }
78
+
79
+ linelog(percentum.toFixed(2) + "%[" + txt + "]" + stream);
80
80
  }
81
81
  exports.linelog = linelog;
82
82
  exports.deeplog = deeplog;
@@ -1,48 +1,48 @@
1
- /**
2
- * 删除文件或文件夹
3
- */
4
- export interface deleteDiskType {
5
- (diskPath: string): void
6
- }
7
-
8
- export let deleteDisk: deleteDiskType
9
-
10
- /**
11
- * 复制文件或文件夹
12
- */
13
- export interface copyDiskType {
14
- (sourcePath: string, targetPath: string, isForce?: boolean): void
15
- }
16
-
17
- export let copyDisk: copyDiskType
18
-
19
- /**
20
- * 移动文件或文件夹
21
- */
22
- export interface moveDiskType {
23
- (sourcePath: string, targetPath: string, isForce?: boolean): void
24
- }
25
-
26
- export let moveDisk: moveDiskType
27
-
28
- /**
29
- * 遍历当前文件或文件夹中所有文件
30
- */
31
- export interface listDiskType {
32
- (sourcePath: string, callback: (fileInfo: {
33
- name: string
34
- path: string
35
- folder: string
36
- }) => void): void
37
- }
38
-
39
- export let listDisk: listDiskType
40
-
41
- /**
42
- * 创建文件或文件夹的链接
43
- */
44
- export interface linkDiskType {
45
- (sourcePath: string, targetPath: string): void
46
- }
47
-
1
+ /**
2
+ * 删除文件或文件夹
3
+ */
4
+ export interface deleteDiskType {
5
+ (diskPath: string): void
6
+ }
7
+
8
+ export let deleteDisk: deleteDiskType
9
+
10
+ /**
11
+ * 复制文件或文件夹
12
+ */
13
+ export interface copyDiskType {
14
+ (sourcePath: string, targetPath: string, isForce?: boolean): void
15
+ }
16
+
17
+ export let copyDisk: copyDiskType
18
+
19
+ /**
20
+ * 移动文件或文件夹
21
+ */
22
+ export interface moveDiskType {
23
+ (sourcePath: string, targetPath: string, isForce?: boolean): void
24
+ }
25
+
26
+ export let moveDisk: moveDiskType
27
+
28
+ /**
29
+ * 遍历当前文件或文件夹中所有文件
30
+ */
31
+ export interface listDiskType {
32
+ (sourcePath: string, callback: (fileInfo: {
33
+ name: string
34
+ path: string
35
+ folder: string
36
+ }) => void): void
37
+ }
38
+
39
+ export let listDisk: listDiskType
40
+
41
+ /**
42
+ * 创建文件或文件夹的链接
43
+ */
44
+ export interface linkDiskType {
45
+ (sourcePath: string, targetPath: string): void
46
+ }
47
+
48
48
  export let linkDisk: linkDiskType
@@ -1,172 +1,172 @@
1
1
  /*!
2
- * disk of OIPage v1.7.0
2
+ * disk of OIPage v1.8.0-alpha.1
3
3
  * git+https://github.com/oi-contrib/OIPage.git
4
4
  */
5
5
 
6
- const { join } = require("path");
7
- const { existsSync, readdirSync, lstatSync, unlinkSync, rmdirSync, mkdirSync, copyFileSync, symlinkSync } = require("fs");
8
- const { execSync } = require("child_process");
9
-
10
- /**
11
- * 删除文件或文件夹
12
- * @param {string} diskPath
13
- */
14
- function deleteDisk(diskPath) {
15
- // 如果文件夹不存在,直接返回即可
16
- if (!existsSync(diskPath)) return;
17
-
18
- // 如果是文件,直接删除即可
19
- if (!lstatSync(diskPath).isDirectory()) {
20
- unlinkSync(diskPath);
21
- } else {
22
-
23
- // 读取子文件
24
- const subFiles = readdirSync(diskPath);
25
-
26
- subFiles.forEach(function (item) {
27
-
28
- // 调用这个方法,删除子文件或文件夹
29
- const curPath = join(diskPath, "./" + item);
30
- deleteDisk(curPath);
31
-
32
- });
33
-
34
- // 等子文件或文件夹删除完毕以后,删除本文件夹
35
- rmdirSync(diskPath);
36
- }
37
- }
38
-
39
- /**
40
- * 复制文件或文件夹
41
- * @param {string} sourcePath
42
- * @param {string} targetPath
43
- * @param {boolean} isForce 可选,是否强制执行
44
- */
45
- function copyDisk(sourcePath, targetPath, isForce) {
46
-
47
- // 如果源文件不存在
48
- if (!existsSync(sourcePath)) {
49
- console.log("\x1b[0m\x1b[31m" + sourcePath + "\x1b[0m");
50
- throw new Error("OIPage: The source path does not exist.");
51
- }
52
-
53
- // 如果目标文件已经存在
54
- if (existsSync(targetPath)) {
55
- if (isForce) {
56
- deleteDisk(targetPath);
57
- } else {
58
- console.log("\x1b[0m\x1b[31m" + targetPath + "\x1b[0m");
59
- throw new Error("OIPage: The target path already exists.");
60
- }
61
- }
62
-
63
- (function copyDiskFun(sourcePath, targetPath) {
64
- // 如果是文件,直接复制即可
65
- if (!lstatSync(sourcePath).isDirectory()) {
66
- copyFileSync(sourcePath, targetPath);
67
- } else {
68
-
69
- // 读取子文件
70
- const subFiles = readdirSync(sourcePath);
71
-
72
- // 如果文件夹不存在,创建
73
- if (!existsSync(targetPath)) {
74
- mkdirSync(targetPath, { recursive: true });
75
- }
76
-
77
- // 复制子文件或文件夹
78
- subFiles.forEach(function (item) {
79
- copyDiskFun(join(sourcePath, "./" + item), join(targetPath, "./" + item));
80
- });
81
-
82
- }
83
- })(sourcePath, targetPath);
84
- }
85
-
86
- /**
87
- * 移动文件或文件夹
88
- * @param {string} sourcePath
89
- * @param {string} targetPath
90
- * @param {boolean} isForce 可选,是否强制执行
91
- */
92
- function moveDisk(sourcePath, targetPath, isForce) {
93
-
94
- // 如果源文件不存在
95
- if (!existsSync(sourcePath)) {
96
- console.log("\x1b[0m\x1b[31m" + sourcePath + "\x1b[0m");
97
- throw new Error("OIPage: The source path does not exist.");
98
- }
99
-
100
- // 如果目标文件已经存在
101
- if (existsSync(targetPath)) {
102
- if (isForce) {
103
- deleteDisk(targetPath);
104
- } else {
105
- console.log("\x1b[0m\x1b[31m" + targetPath + "\x1b[0m");
106
- throw new Error("OIPage: The target path already exists.");
107
- }
108
- }
109
-
110
- // 如果是文件,直接剪切即可
111
- if (!lstatSync(sourcePath).isDirectory()) {
112
- copyFileSync(sourcePath, targetPath);
113
- unlinkSync(sourcePath);
114
- } else {
115
-
116
- // 读取子文件
117
- const subFiles = readdirSync(sourcePath);
118
-
119
- // 如果文件夹不存在,创建
120
- if (!existsSync(targetPath)) {
121
- mkdirSync(targetPath, { recursive: true });
122
- }
123
-
124
- // 移动子文件或文件夹
125
- subFiles.forEach(function (file) {
126
- moveDisk(join(sourcePath, "./" + file), join(targetPath, "./" + file));
127
- });
128
-
129
- // 移动完子文件或文件夹以后(移动完毕也意味着子文件或文件夹被删除了)
130
- rmdirSync(sourcePath);
131
- }
132
- }
133
-
134
- /**
135
- * 遍历当前文件或文件夹中所有文件
136
- * @param {string} sourcePath
137
- * @param {function} callback
138
- */
139
- function listDisk(sourcePath, callback) {
140
- // 文件夹
141
- if (lstatSync(sourcePath).isDirectory()) {
142
-
143
- // 读取子文件
144
- const subFiles = readdirSync(sourcePath);
145
- subFiles.forEach(function (file) {
146
- listDisk(join(sourcePath, "./" + file), callback);
147
- });
148
- }
149
-
150
- // 文件
151
- else {
152
- let folder = join(sourcePath, "../");
153
-
154
- callback({
155
- "name": sourcePath.replace(folder, ""),
156
- "path": sourcePath,
157
- "folder": folder
158
- });
159
- }
160
- }
161
-
162
- /**
163
- * 软链接文件或文件夹
164
- * @param {*} sourcePath
165
- * @param {*} targetPath
166
- */
167
- function linkDisk(sourcePath, targetPath) {
168
- const type = lstatSync(sourcePath).isDirectory() ? 'junction' : 'file';
169
- symlinkSync(sourcePath, targetPath, type);
6
+ const { join } = require("path");
7
+ const { existsSync, readdirSync, lstatSync, unlinkSync, rmdirSync, mkdirSync, copyFileSync, symlinkSync } = require("fs");
8
+ const { execSync } = require("child_process");
9
+
10
+ /**
11
+ * 删除文件或文件夹
12
+ * @param {string} diskPath
13
+ */
14
+ function deleteDisk(diskPath) {
15
+ // 如果文件夹不存在,直接返回即可
16
+ if (!existsSync(diskPath)) return;
17
+
18
+ // 如果是文件,直接删除即可
19
+ if (!lstatSync(diskPath).isDirectory()) {
20
+ unlinkSync(diskPath);
21
+ } else {
22
+
23
+ // 读取子文件
24
+ const subFiles = readdirSync(diskPath);
25
+
26
+ subFiles.forEach(function (item) {
27
+
28
+ // 调用这个方法,删除子文件或文件夹
29
+ const curPath = join(diskPath, "./" + item);
30
+ deleteDisk(curPath);
31
+
32
+ });
33
+
34
+ // 等子文件或文件夹删除完毕以后,删除本文件夹
35
+ rmdirSync(diskPath);
36
+ }
37
+ }
38
+
39
+ /**
40
+ * 复制文件或文件夹
41
+ * @param {string} sourcePath
42
+ * @param {string} targetPath
43
+ * @param {boolean} isForce 可选,是否强制执行
44
+ */
45
+ function copyDisk(sourcePath, targetPath, isForce) {
46
+
47
+ // 如果源文件不存在
48
+ if (!existsSync(sourcePath)) {
49
+ console.log("\x1b[0m\x1b[31m" + sourcePath + "\x1b[0m");
50
+ throw new Error("OIPage: The source path does not exist.");
51
+ }
52
+
53
+ // 如果目标文件已经存在
54
+ if (existsSync(targetPath)) {
55
+ if (isForce) {
56
+ deleteDisk(targetPath);
57
+ } else {
58
+ console.log("\x1b[0m\x1b[31m" + targetPath + "\x1b[0m");
59
+ throw new Error("OIPage: The target path already exists.");
60
+ }
61
+ }
62
+
63
+ (function copyDiskFun(sourcePath, targetPath) {
64
+ // 如果是文件,直接复制即可
65
+ if (!lstatSync(sourcePath).isDirectory()) {
66
+ copyFileSync(sourcePath, targetPath);
67
+ } else {
68
+
69
+ // 读取子文件
70
+ const subFiles = readdirSync(sourcePath);
71
+
72
+ // 如果文件夹不存在,创建
73
+ if (!existsSync(targetPath)) {
74
+ mkdirSync(targetPath, { recursive: true });
75
+ }
76
+
77
+ // 复制子文件或文件夹
78
+ subFiles.forEach(function (item) {
79
+ copyDiskFun(join(sourcePath, "./" + item), join(targetPath, "./" + item));
80
+ });
81
+
82
+ }
83
+ })(sourcePath, targetPath);
84
+ }
85
+
86
+ /**
87
+ * 移动文件或文件夹
88
+ * @param {string} sourcePath
89
+ * @param {string} targetPath
90
+ * @param {boolean} isForce 可选,是否强制执行
91
+ */
92
+ function moveDisk(sourcePath, targetPath, isForce) {
93
+
94
+ // 如果源文件不存在
95
+ if (!existsSync(sourcePath)) {
96
+ console.log("\x1b[0m\x1b[31m" + sourcePath + "\x1b[0m");
97
+ throw new Error("OIPage: The source path does not exist.");
98
+ }
99
+
100
+ // 如果目标文件已经存在
101
+ if (existsSync(targetPath)) {
102
+ if (isForce) {
103
+ deleteDisk(targetPath);
104
+ } else {
105
+ console.log("\x1b[0m\x1b[31m" + targetPath + "\x1b[0m");
106
+ throw new Error("OIPage: The target path already exists.");
107
+ }
108
+ }
109
+
110
+ // 如果是文件,直接剪切即可
111
+ if (!lstatSync(sourcePath).isDirectory()) {
112
+ copyFileSync(sourcePath, targetPath);
113
+ unlinkSync(sourcePath);
114
+ } else {
115
+
116
+ // 读取子文件
117
+ const subFiles = readdirSync(sourcePath);
118
+
119
+ // 如果文件夹不存在,创建
120
+ if (!existsSync(targetPath)) {
121
+ mkdirSync(targetPath, { recursive: true });
122
+ }
123
+
124
+ // 移动子文件或文件夹
125
+ subFiles.forEach(function (file) {
126
+ moveDisk(join(sourcePath, "./" + file), join(targetPath, "./" + file));
127
+ });
128
+
129
+ // 移动完子文件或文件夹以后(移动完毕也意味着子文件或文件夹被删除了)
130
+ rmdirSync(sourcePath);
131
+ }
132
+ }
133
+
134
+ /**
135
+ * 遍历当前文件或文件夹中所有文件
136
+ * @param {string} sourcePath
137
+ * @param {function} callback
138
+ */
139
+ function listDisk(sourcePath, callback) {
140
+ // 文件夹
141
+ if (lstatSync(sourcePath).isDirectory()) {
142
+
143
+ // 读取子文件
144
+ const subFiles = readdirSync(sourcePath);
145
+ subFiles.forEach(function (file) {
146
+ listDisk(join(sourcePath, "./" + file), callback);
147
+ });
148
+ }
149
+
150
+ // 文件
151
+ else {
152
+ let folder = join(sourcePath, "../");
153
+
154
+ callback({
155
+ "name": sourcePath.replace(folder, ""),
156
+ "path": sourcePath,
157
+ "folder": folder
158
+ });
159
+ }
160
+ }
161
+
162
+ /**
163
+ * 软链接文件或文件夹
164
+ * @param {*} sourcePath
165
+ * @param {*} targetPath
166
+ */
167
+ function linkDisk(sourcePath, targetPath) {
168
+ const type = lstatSync(sourcePath).isDirectory() ? 'junction' : 'file';
169
+ symlinkSync(sourcePath, targetPath, type);
170
170
  }
171
171
  exports.deleteDisk = deleteDisk;
172
172
  exports.copyDisk = copyDisk;
@@ -1,29 +1,29 @@
1
- /**
2
- * 数字格式化
3
- */
4
- export interface numberFormatType {
5
- (input: number | string): string
6
- }
7
-
8
- export let numberFormat: numberFormatType
9
-
10
- /**
11
- * 日期格式化
12
- */
13
- export interface dateFormatType {
14
- (input?: string | Date, option?: {
15
-
16
- /**
17
- * 输入格式
18
- */
19
- inputFormat?: string
20
-
21
- /**
22
- * 输出格式
23
- */
24
- format?: string
25
- }): string
26
- }
27
-
28
- export let dateFormat: dateFormatType
29
-
1
+ /**
2
+ * 数字格式化
3
+ */
4
+ export interface numberFormatType {
5
+ (input: number | string): string
6
+ }
7
+
8
+ export let numberFormat: numberFormatType
9
+
10
+ /**
11
+ * 日期格式化
12
+ */
13
+ export interface dateFormatType {
14
+ (input?: string | Date, option?: {
15
+
16
+ /**
17
+ * 输入格式
18
+ */
19
+ inputFormat?: string
20
+
21
+ /**
22
+ * 输出格式
23
+ */
24
+ format?: string
25
+ }): string
26
+ }
27
+
28
+ export let dateFormat: dateFormatType
29
+