Commit 1e5faf87 authored by haiyoucuv's avatar haiyoucuv

init

parent 891aeb28
...@@ -37,6 +37,9 @@ export async function compressAllImage( ...@@ -37,6 +37,9 @@ export async function compressAllImage(
let completed = 0; let completed = 0;
const chunkSize = 20;
const totalBatches = Math.ceil(paths.length / chunkSize);
if (platform == "win32") { if (platform == "win32") {
const now = Date.now(); const now = Date.now();
...@@ -46,29 +49,34 @@ export async function compressAllImage( ...@@ -46,29 +49,34 @@ export async function compressAllImage(
if (!fsSync.existsSync("C:\\Temp\\duiba")) await fs.mkdir("C:\\Temp\\duiba"); if (!fsSync.existsSync("C:\\Temp\\duiba")) await fs.mkdir("C:\\Temp\\duiba");
if (!fsSync.existsSync(tempDir)) await fs.mkdir(tempDir); if (!fsSync.existsSync(tempDir)) await fs.mkdir(tempDir);
const ps = paths.map(async (imgPath, idx) => { for (let i = 0; i < paths.length; i += chunkSize) {
const tempName = `${tempDir}/${idx}.png`; const currentBatch = Math.floor(i / chunkSize) + 1;
await fs.copyFile(imgPath, tempName); // console.log(`正在处理第 ${currentBatch}/${totalBatches} 批图片压缩...\n`);
execSync(`"${pngquantPath}" ${compressOptions} "${tempName}"`);
await fs.copyFile(tempName, imgPath); const chunk = paths.slice(i, i + chunkSize);
completed++;
onProgress(completed, paths.length); const ps = chunk.map(async (imgPath, idx) => {
}); const tempName = `${tempDir}/${i + idx}.png`;
await fs.copyFile(imgPath, tempName);
execSync(`"${pngquantPath}" ${compressOptions} "${tempName}"`);
await fs.copyFile(tempName, imgPath);
completed++;
onProgress(completed, paths.length);
});
await Promise.all(ps); await Promise.all(ps);
}
await fs.rm(tempDir, {recursive: true}); await fs.rm(tempDir, {recursive: true});
} else { } else {
const chunkSize = 20;
const totalBatches = Math.ceil(paths.length / chunkSize);
// 批次执行 // 批次执行
for (let i = 0; i < paths.length; i += chunkSize) { for (let i = 0; i < paths.length; i += chunkSize) {
const currentBatch = Math.floor(i / chunkSize) + 1; const currentBatch = Math.floor(i / chunkSize) + 1;
console.log(`正在处理第 ${currentBatch}/${totalBatches} 批图片压缩...`); // console.log(`正在处理第 ${currentBatch}/${totalBatches} 批图片压缩...\n`);
const chunk = paths.slice(i, i + chunkSize); const chunk = paths.slice(i, i + chunkSize);
let command = ""; let command = "";
chunk.forEach((imgPath) => { chunk.forEach((imgPath) => {
......
...@@ -5,6 +5,7 @@ import * as path from "path"; ...@@ -5,6 +5,7 @@ import * as path from "path";
import {findFiles} from "../commom/helper.ts"; import {findFiles} from "../commom/helper.ts";
import {compressAllImage} from "../AssetsMin/ImageCompress.ts"; import {compressAllImage} from "../AssetsMin/ImageCompress.ts";
import {compressAllSvga} from "../AssetsMin/SvgaCompress.ts"; import {compressAllSvga} from "../AssetsMin/SvgaCompress.ts";
import ProgressBar from "progress";
interface IDuibaPublishOptions { interface IDuibaPublishOptions {
buildVersion: string | number, buildVersion: string | number,
...@@ -37,10 +38,18 @@ export default function DuibaPublish(options: IDuibaPublishOptions) { ...@@ -37,10 +38,18 @@ export default function DuibaPublish(options: IDuibaPublishOptions) {
console.log(chalk.green("开始压缩图片了")); console.log(chalk.green("开始压缩图片了"));
const imgPaths = findFiles(path.resolve("dist"), /\.png$/); const imgPaths = findFiles(path.resolve("dist"), /\.png$/);
process.stdout.write(chalk.green(`\r压缩图片进度:${0}/${imgPaths.length}`)); const bar = new ProgressBar(`压缩图片进度 [:bar] :current/${imgPaths.length} :percent :elapseds`, {
complete: "●",
incomplete: "○",
width: 20,
total: imgPaths.length,
callback: () => {
console.log("%cAll complete.", "color: green");
}
})
await compressAllImage(imgPaths, (cur, total) => { await compressAllImage(imgPaths, (cur, total) => {
// process.stdout.write("\r"); bar.tick();
process.stdout.write(chalk.green(`\r压缩图片进度:${cur}/${total}`));
}); });
console.log(chalk.green("\n压缩图片结束了\n")); console.log(chalk.green("\n压缩图片结束了\n"));
......
...@@ -33,17 +33,17 @@ ...@@ -33,17 +33,17 @@
// alert("【警告】检测到活动url中没有appID参数\n缺少该参数会导致埋点、分享、app信息获取错误。") // alert("【警告】检测到活动url中没有appID参数\n缺少该参数会导致埋点、分享、app信息获取错误。")
} }
</script> </script>
<script type="module" crossorigin src="https://yun.duiba.com.cn/db_games/spark/v3/1747036116277/assets/index-B1Qjd6_B.js"></script> <script type="module" crossorigin src="https://yun.duiba.com.cn/db_games/spark/v3/1747188967194/assets/index-BgzNJgbj.js"></script>
<link rel="modulepreload" crossorigin href="https://yun.duiba.com.cn/db_games/spark/v3/1747036116277/assets/vendor-Cz0uqDij.js"> <link rel="modulepreload" crossorigin href="https://yun.duiba.com.cn/db_games/spark/v3/1747188967194/assets/vendor-BQeg0qjm.js">
<link rel="stylesheet" crossorigin href="https://yun.duiba.com.cn/db_games/spark/v3/1747036116277/assets/vendor-BQh5NVNk.css"> <link rel="stylesheet" crossorigin href="https://yun.duiba.com.cn/db_games/spark/v3/1747188967194/assets/vendor-BQh5NVNk.css">
<link rel="stylesheet" crossorigin href="https://yun.duiba.com.cn/db_games/spark/v3/1747036116277/assets/index-Cqq-BG5O.css"> <link rel="stylesheet" crossorigin href="https://yun.duiba.com.cn/db_games/spark/v3/1747188967194/assets/index-CGOfNeU3.css">
<script type="module">import.meta.url;import("_").catch(()=>1);(async function*(){})().next();if(location.protocol!="file:"){window.__vite_is_modern_browser=true}</script> <script type="module">import.meta.url;import("_").catch(()=>1);(async function*(){})().next();if(location.protocol!="file:"){window.__vite_is_modern_browser=true}</script>
<script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script> <script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script> <script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script>
<script nomodule crossorigin id="vite-legacy-polyfill" src="https://yun.duiba.com.cn/db_games/spark/v3/1747036116277/assets/polyfills-legacy-CC61kNVN.js"></script> <script nomodule crossorigin id="vite-legacy-polyfill" src="https://yun.duiba.com.cn/db_games/spark/v3/1747188967194/assets/polyfills-legacy-arANKBzQ.js"></script>
<script nomodule crossorigin id="vite-legacy-entry" data-src="https://yun.duiba.com.cn/db_games/spark/v3/1747036116277/assets/index-legacy-n_kbpnjN.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script> <script nomodule crossorigin id="vite-legacy-entry" data-src="https://yun.duiba.com.cn/db_games/spark/v3/1747188967194/assets/index-legacy-Tn0Un0ZG.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
</body> </body>
</html> </html>
@import "./res.less"; @import "./res.less";
@import "tailwindcss"; //@import "tailwindcss";
* { * {
margin: 0; margin: 0;
......
...@@ -57,12 +57,12 @@ class Store { ...@@ -57,12 +57,12 @@ class Store {
} = {}; } = {};
async updateIndex() { async updateIndex() {
const { success, data, timeStamp } = await API.index(); // const { success, data, timeStamp } = await API.index();
if (!success) { // if (!success) {
return; // return;
} // }
this.indexData = data; // this.indexData = data;
this.indexData.timeStamp = timeStamp; // this.indexData.timeStamp = timeStamp;
} }
judgeActTime(brakeStart = true, brakeEnd = true) { judgeActTime(brakeStart = true, brakeEnd = true) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment