This commit is contained in:
辉鸭蛋
2024-10-23 23:23:04 +08:00
parent 3fbb6562fa
commit 1206df59a1
87 changed files with 251 additions and 4 deletions

30
.gitignore vendored Normal file
View File

@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
*.tsbuildinfo

View File

@@ -108,12 +108,19 @@ function generateDirectoryTree(dir, currentDepth = 0, parentFolders = []) {
info.tags = jsInfo.tags;
}
} else {
info.children = fs.readdirSync(dir).map(child => {
const childPath = path.join(dir, child);
return generateDirectoryTree(childPath, currentDepth + 1, [...parentFolders, info.name]);
});
info.children = fs.readdirSync(dir)
.filter(child => !['desktop.ini', 'icon.ico'].includes(child)) // 过滤掉 desktop.ini 和 icon.ico
.map(child => {
const childPath = path.join(dir, child);
return generateDirectoryTree(childPath, currentDepth + 1, [...parentFolders, info.name]);
});
}
} else {
// 如果是 desktop.ini 或 icon.ico 文件,直接返回 null
if (['desktop.ini', 'icon.ico'].includes(info.name)) {
return null;
}
const hash = calculateSHA1(dir);
info.hash = hash;
info.version = hash.substring(0, 7);

34
build/icon/1.filter.js Normal file
View File

@@ -0,0 +1,34 @@
const fs = require('fs');
const path = require('path');
// 读取JSON文件
const jsonPath = 'E:\\HuiTask\\更好的原神\\2.资料\\图标处理\\Material.json';
const jsonData = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
// 设置源文件夹和目标文件夹
const sourceDir = 'E:\\HuiTask\\更好的原神\\2.资料\\图标处理\\ItemIcon-tiny';
const targetDir = 'E:\\HuiTask\\更好的原神\\2.资料\\图标处理\\newPng';
// 确保目标文件夹存在
if (!fs.existsSync(targetDir)) {
fs.mkdirSync(targetDir, { recursive: true });
}
// 读取源文件夹中的所有文件
fs.readdirSync(sourceDir).forEach(file => {
const fileName = path.parse(file).name; // 获取文件名(不含扩展名)
// 在JSON数据中查找匹配项
const matchedItem = jsonData.find(item => item.Icon === fileName);
if (matchedItem) {
const sourcePath = path.join(sourceDir, file);
const targetPath = path.join(targetDir, `${matchedItem.Name}.png`);
// 复制并重命名文件
fs.copyFileSync(sourcePath, targetPath);
console.log(`已复制并重命名: ${file} -> ${matchedItem.Name}.png`);
}
});
console.log('处理完成');

43
build/icon/2.match.js Normal file
View File

@@ -0,0 +1,43 @@
const fs = require('fs');
const path = require('path');
// 定义路径
const pathingDir = 'D:\\HuiPrograming\\Projects\\CSharp\\MiHoYo\\bettergi-scripts-list\\repo\\pathing';
const pngDir = 'E:\\HuiTask\\更好的原神\\2.资料\\图标处理\\newPng';
const outputDir = 'E:\\HuiTask\\更好的原神\\2.资料\\图标处理\\matchedPng';
// 确保输出目录存在
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir);
}
// 读取 pathing 目录下的所有文件夹名称
fs.readdir(pathingDir, { withFileTypes: true }, (err, entries) => {
if (err) {
console.error('读取 pathing 目录时出错:', err);
return;
}
// 过滤出目录
const directories = entries.filter(entry => entry.isDirectory()).map(dir => dir.name);
// 遍历目录名称
directories.forEach(dirName => {
const pngPath = path.join(pngDir, `${dirName}.png`);
const outputPath = path.join(outputDir, `${dirName}.png`);
// 检查对应的 PNG 文件是否存在
if (fs.existsSync(pngPath)) {
// 复制文件
fs.copyFile(pngPath, outputPath, err => {
if (err) {
console.error(`复制 ${dirName}.png 时出错:`, err);
} else {
console.log(`成功复制 ${dirName}.png 到 matchedPng 文件夹`);
}
});
} else {
console.log(`未找到对应的 PNG 文件: ${dirName}.png`);
}
});
});

57
build/icon/3.icon.js Normal file
View File

@@ -0,0 +1,57 @@
const fs = require('fs');
const path = require('path');
const { exec } = require('child_process');
// 定义路径
const sourcePath = 'D:\\HuiPrograming\\Projects\\CSharp\\MiHoYo\\bettergi-scripts-list\\repo\\pathing';
const iconSourcePath = 'E:\\HuiTask\\更好的原神\\2.资料\\图标处理\\matchedIco';
const desktopIniPath = 'E:\\HuiTask\\更好的原神\\2.资料\\图标处理\\desktop.ini';
// 读取源目录
fs.readdir(sourcePath, { withFileTypes: true }, (err, entries) => {
if (err) {
console.error('读取源目录时出错:', err);
return;
}
// 遍历每个目录
entries.filter(entry => entry.isDirectory()).forEach(dir => {
const dirPath = path.join(sourcePath, dir.name);
const iconSourceFile = path.join(iconSourcePath, `${dir.name}.ico`);
const iconDestFile = path.join(dirPath, 'icon.ico');
const desktopIniDestFile = path.join(dirPath, 'desktop.ini');
// 检查图标源文件是否存在
if (!fs.existsSync(iconSourceFile)) {
console.log(`警告:${dir.name} 的图标文件不存在,跳过所有操作`);
return; // 跳过当前目录的所有后续操作
}
// 复制图标文件
fs.copyFile(iconSourceFile, iconDestFile, (err) => {
if (err) {
console.error(`复制图标文件到 ${dir.name} 时出错:`, err);
return; // 如果复制图标失败,跳过后续操作
}
console.log(`成功复制图标文件到 ${dir.name}`);
// 复制desktop.ini文件
fs.copyFile(desktopIniPath, desktopIniDestFile, (err) => {
if (err) {
console.error(`复制desktop.ini到 ${dir.name} 时出错:`, err);
return; // 如果复制desktop.ini失败跳过后续操作
}
console.log(`成功复制desktop.ini到 ${dir.name}`);
// 执行cmd命令
exec(`attrib +R "${dirPath}"`, (err, stdout, stderr) => {
if (err) {
console.error(`执行attrib命令时出错 ${dir.name}:`, err);
return;
}
console.log(`成功为 ${dir.name} 设置只读属性`);
});
});
});
});
});

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=icon.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB