oipage 1.5.0-alpha.3 → 1.5.0
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/CHANGELOG +5 -2
- package/bin/disk.js +2 -3
- package/nodejs/animation/index.js +1 -1
- package/nodejs/cmdlog/index.js +1 -1
- package/nodejs/disk/index.d.ts +23 -1
- package/nodejs/disk/index.js +80 -2
- package/nodejs/format/index.js +1 -1
- package/nodejs/json/index.js +1 -1
- package/nodejs/logform/index.js +1 -1
- package/nodejs/reader/index.js +1 -1
- package/nodejs/throttle/index.js +1 -1
- package/package.json +1 -1
- package/web/XMLHttpRequest/index.js +1 -1
- package/web/animation/index.js +1 -1
- package/web/format/index.js +1 -1
- package/web/json/index.js +1 -1
- package/web/onReady/index.js +1 -1
- package/web/performChunk/index.js +1 -1
- package/web/reader/index.js +1 -1
- package/web/style/index.js +1 -1
- package/web/throttle/index.js +1 -1
package/CHANGELOG
CHANGED
|
@@ -98,7 +98,7 @@ v1.4.1:
|
|
|
98
98
|
- 修复bug
|
|
99
99
|
1、修复开发服务器大文件丢失文件大小问题
|
|
100
100
|
v1.5.0:
|
|
101
|
-
date:
|
|
101
|
+
date:2025-11-13
|
|
102
102
|
changes:
|
|
103
103
|
- 修复bug
|
|
104
104
|
1、修复404网站在手机浏览器显示高问题
|
|
@@ -111,4 +111,7 @@ v1.5.0:
|
|
|
111
111
|
1、开发服务器 / 应用市场
|
|
112
112
|
* 聊天工具
|
|
113
113
|
* 图片编辑器
|
|
114
|
-
* 图片转PDF
|
|
114
|
+
* 图片转PDF
|
|
115
|
+
2、API功能(Node.js)
|
|
116
|
+
* disk 磁盘相关操作
|
|
117
|
+
(包括:moveDisk、listDisk)
|
package/bin/disk.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { deleteDisk, copyDisk } = require("../nodejs/disk");
|
|
1
|
+
const { deleteDisk, copyDisk, moveDisk } = require("../nodejs/disk");
|
|
2
2
|
|
|
3
3
|
module.exports = function (config) {
|
|
4
4
|
let isForce = false;
|
|
@@ -20,8 +20,7 @@ module.exports = function (config) {
|
|
|
20
20
|
|
|
21
21
|
// 移动文件或文件夹
|
|
22
22
|
else if (config.value[i].name === "--move") {
|
|
23
|
-
|
|
24
|
-
deleteDisk(config.value[i].value[0]);
|
|
23
|
+
moveDisk(config.value[i].value[0], config.value[i].value[1], isForce);
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
// 复制文件或文件夹
|
package/nodejs/cmdlog/index.js
CHANGED
package/nodejs/disk/index.d.ts
CHANGED
|
@@ -14,4 +14,26 @@ export interface copyDiskType {
|
|
|
14
14
|
(sourcePath: string, targetPath: string, isForce?: boolean): void
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export let copyDisk: copyDiskType
|
|
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
|
package/nodejs/disk/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* disk of OIPage v1.5.0
|
|
2
|
+
* disk of OIPage v1.5.0
|
|
3
3
|
* git+https://github.com/oi-contrib/OIPage.git
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -49,7 +49,7 @@ function copyDisk(sourcePath, targetPath, isForce) {
|
|
|
49
49
|
throw new Error("OIPage: The source path does not exist.");
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
//
|
|
52
|
+
// 如果目标文件已经存在
|
|
53
53
|
if (existsSync(targetPath)) {
|
|
54
54
|
if (isForce) {
|
|
55
55
|
deleteDisk(targetPath);
|
|
@@ -80,6 +80,84 @@ function copyDisk(sourcePath, targetPath, isForce) {
|
|
|
80
80
|
|
|
81
81
|
}
|
|
82
82
|
})(sourcePath, targetPath);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 移动文件或文件夹
|
|
87
|
+
* @param {string} sourcePath
|
|
88
|
+
* @param {string} targetPath
|
|
89
|
+
* @param {boolean} isForce 可选,是否强制执行
|
|
90
|
+
*/
|
|
91
|
+
function moveDisk(sourcePath, targetPath, isForce) {
|
|
92
|
+
|
|
93
|
+
// 如果源文件不存在
|
|
94
|
+
if (!existsSync(sourcePath)) {
|
|
95
|
+
console.log("\x1b[0m\x1b[31m" + sourcePath + "\x1b[0m");
|
|
96
|
+
throw new Error("OIPage: The source path does not exist.");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 如果目标文件已经存在
|
|
100
|
+
if (existsSync(targetPath)) {
|
|
101
|
+
if (isForce) {
|
|
102
|
+
deleteDisk(targetPath);
|
|
103
|
+
} else {
|
|
104
|
+
console.log("\x1b[0m\x1b[31m" + targetPath + "\x1b[0m");
|
|
105
|
+
throw new Error("OIPage: The target path already exists.");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 如果是文件,直接剪切即可
|
|
110
|
+
if (!lstatSync(sourcePath).isDirectory()) {
|
|
111
|
+
copyFileSync(sourcePath, targetPath);
|
|
112
|
+
unlinkSync(sourcePath);
|
|
113
|
+
} else {
|
|
114
|
+
|
|
115
|
+
// 读取子文件
|
|
116
|
+
const subFiles = readdirSync(sourcePath);
|
|
117
|
+
|
|
118
|
+
// 如果文件夹不存在,创建
|
|
119
|
+
if (!existsSync(targetPath)) {
|
|
120
|
+
mkdirSync(targetPath, { recursive: true });
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 移动子文件或文件夹
|
|
124
|
+
subFiles.forEach(function (file) {
|
|
125
|
+
moveDisk(join(sourcePath, "./" + file), join(targetPath, "./" + file));
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// 移动完子文件或文件夹以后(移动完毕也意味着子文件或文件夹被删除了)
|
|
129
|
+
rmdirSync(sourcePath);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 遍历当前文件或文件夹中所有文件
|
|
135
|
+
* @param {string} sourcePath
|
|
136
|
+
* @param {function} callback
|
|
137
|
+
*/
|
|
138
|
+
function listDisk(sourcePath, callback) {
|
|
139
|
+
// 文件夹
|
|
140
|
+
if (lstatSync(sourcePath).isDirectory()) {
|
|
141
|
+
|
|
142
|
+
// 读取子文件
|
|
143
|
+
const subFiles = readdirSync(sourcePath);
|
|
144
|
+
subFiles.forEach(function (file) {
|
|
145
|
+
listDisk(join(sourcePath, "./" + file), callback);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 文件
|
|
150
|
+
else {
|
|
151
|
+
let folder = join(sourcePath, "../");
|
|
152
|
+
|
|
153
|
+
callback({
|
|
154
|
+
"name": sourcePath.replace(folder, ""),
|
|
155
|
+
"path": sourcePath,
|
|
156
|
+
"folder": folder
|
|
157
|
+
});
|
|
158
|
+
}
|
|
83
159
|
}
|
|
84
160
|
exports.deleteDisk = deleteDisk;
|
|
85
161
|
exports.copyDisk = copyDisk;
|
|
162
|
+
exports.moveDisk = moveDisk;
|
|
163
|
+
exports.listDisk = listDisk;
|
package/nodejs/format/index.js
CHANGED
package/nodejs/json/index.js
CHANGED
package/nodejs/logform/index.js
CHANGED
package/nodejs/reader/index.js
CHANGED
package/nodejs/throttle/index.js
CHANGED
package/package.json
CHANGED
package/web/animation/index.js
CHANGED
package/web/format/index.js
CHANGED
package/web/json/index.js
CHANGED
package/web/onReady/index.js
CHANGED
package/web/reader/index.js
CHANGED
package/web/style/index.js
CHANGED
package/web/throttle/index.js
CHANGED