Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
car
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
SparkProjects
car
Commits
1046fea4
Commit
1046fea4
authored
Jun 03, 2025
by
haiyoucuv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
867d7740
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
736 additions
and
709 deletions
+736
-709
package-lock.json
extensions/duiba-publish/package-lock.json
+12
-5
package.json
extensions/duiba-publish/package.json
+1
-1
minImg.ts
extensions/duiba-publish/source/minImg.ts
+42
-29
yarn.lock
extensions/duiba-publish/yarn.lock
+681
-674
No files found.
extensions/duiba-publish/package-lock.json
View file @
1046fea4
...
...
@@ -9,7 +9,7 @@
"version"
:
"1.0.0"
,
"dependencies"
:
{
"@types/fs-extra"
:
"^5.0.4"
,
"@types/node"
:
"^1
4.5.2
"
,
"@types/node"
:
"^1
8.17.1
"
,
"ali-oss"
:
"^6.19.0"
,
"fs-extra"
:
"^10.0.0"
,
"jszip"
:
"^3.10.1"
,
...
...
@@ -27,10 +27,12 @@
}
},
"node_modules/@types/node"
:
{
"version"
:
"14.18.63"
,
"resolved"
:
"http://npm.dui88.com:80/@types%2fnode/-/node-14.18.63.tgz"
,
"integrity"
:
"sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ=="
,
"license"
:
"MIT"
"version"
:
"18.19.110"
,
"resolved"
:
"https://registry.npmjs.org/@types/node/-/node-18.19.110.tgz"
,
"integrity"
:
"sha512-WW2o4gTmREtSnqKty9nhqF/vA0GKd0V/rbC0OyjSk9Bz6bzlsXKT+i7WDdS/a0z74rfT2PO4dArVCSnapNLA5Q=="
,
"dependencies"
:
{
"undici-types"
:
"~5.26.4"
}
},
"node_modules/address"
:
{
"version"
:
"1.2.2"
,
...
...
@@ -946,6 +948,11 @@
"node"
:
">=14.17"
}
},
"node_modules/undici-types"
:
{
"version"
:
"5.26.5"
,
"resolved"
:
"https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz"
,
"integrity"
:
"sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
},
"node_modules/unescape"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"http://npm.dui88.com:80/unescape/-/unescape-1.0.1.tgz"
,
...
...
extensions/duiba-publish/package.json
View file @
1046fea4
...
...
@@ -13,7 +13,7 @@
},
"dependencies"
:
{
"@types/fs-extra"
:
"^5.0.4"
,
"@types/node"
:
"^1
4.5.2
"
,
"@types/node"
:
"^1
8.17.1
"
,
"ali-oss"
:
"^6.19.0"
,
"fs-extra"
:
"^10.0.0"
,
"jszip"
:
"^3.10.1"
,
...
...
extensions/duiba-publish/source/minImg.ts
View file @
1046fea4
...
...
@@ -53,6 +53,48 @@ export async function compressAllImage(paths = [], root) {
getImages
(
root
+
"/"
+
dir
,
imgs
);
});
// let completed = 0;
//
// const chunkSize = 20;
//
// const userHomeDir = Os.homedir();
// const cacheDir = path.join(userHomeDir, ".image_compress_cache");
//
// if (!fs.existsSync(cacheDir)) await fs.mkdir(cacheDir, { recursive: true });
//
// const now = Date.now();
// const tempDir = path.join(userHomeDir, `.image_compress_temp/${now}`);
//
// for (let i = 0; i < paths.length; i += chunkSize) {
// const chunk = paths.slice(i, i + chunkSize);
//
// const ps = chunk.map(async (imgPath, idx) => {
// const tempName = `${tempDir}/${i + idx}.png`;
//
// // 检查缓存
// const fileBuffer = await fs.readFile(imgPath);
// const md5Hash = crypto.createHash("md5").update(fileBuffer).digest("hex");
// const cachedFilePath = path.join(cacheDir, `${md5Hash}.png`);
//
// if (fs.existsSync(cachedFilePath)) {
// // 如果缓存文件存在,直接复制到目标路径
// await fs.copyFile(cachedFilePath, imgPath);
// } else {
// // 如果缓存文件不存在,执行压缩操作并缓存
// await fs.copyFile(imgPath, tempName);
// execSync(`"${pngquantPath}" ${compressOptions} "${tempName}"`);
// await fs.copyFile(tempName, imgPath);
// await fs.copyFile(tempName, cachedFilePath);
// }
//
// completed++;
// });
//
// await Promise.all(ps);
// }
//
// await fs.rm(tempDir, { recursive: true });
if
(
platform
==
"win32"
)
{
const
now
=
Date
.
now
();
...
...
@@ -104,33 +146,4 @@ export async function compressAllImage(paths = [], root) {
}
// const tasks = imgs.map((imgPath) => {
// return new Promise<void>((resolve) => {
// try {
// const command = `"${pngquantPath}" ${compressOptions} "${imgPath}"`;
//
// console.log(command);
//
// const originSize = fs.statSync(imgPath).size / 1000;
//
// exec(command, (error, stdout, stderr) => {
// if (error) {
// // console.error(error);
// } else {
// const size = fs.statSync(imgPath).size / 1000;
// // 计算压缩率
// const rate = ((originSize - size) / originSize) * 100;
// console.log(`%c压缩图片成功, ${originSize}k -> ${size}k 压缩率:${rate.toFixed(2)}%`, "color: green");
// }
// resolve();
// });
// } catch (e) {
// console.error(e);
// resolve();
// }
// });
// });
//
// await Promise.all(tasks);
}
extensions/duiba-publish/yarn.lock
View file @
1046fea4
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment