蓝牙调试页面初步完成
This commit is contained in:
47
tools/find_unused_images.js
Normal file
47
tools/find_unused_images.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const root = path.resolve(__dirname, '..');
|
||||
|
||||
function walk(dir) {
|
||||
const res = [];
|
||||
const items = fs.readdirSync(dir, { withFileTypes: true });
|
||||
for (const it of items) {
|
||||
const full = path.join(dir, it.name);
|
||||
if (it.isDirectory()) {
|
||||
// skip virtual env and node_modules
|
||||
if (['.venv', 'node_modules', '.git'].includes(it.name)) continue;
|
||||
res.push(...walk(full));
|
||||
} else {
|
||||
res.push(full);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function isImage(f) {
|
||||
return /\.(png|jpe?g|gif|svg|webp|ico)$/i.test(f);
|
||||
}
|
||||
function isTextFile(f) {
|
||||
return /\.(js|jsx|ts|tsx|json|html|htm|wxml|wxss|css|md|vue|py|java|xml|txt|scss|less|styl|mdx|yaml|yml)$/i.test(f);
|
||||
}
|
||||
|
||||
const all = walk(root);
|
||||
const images = all.filter(isImage);
|
||||
const textFiles = all.filter(isTextFile);
|
||||
|
||||
const unused = [];
|
||||
for (const img of images) {
|
||||
const name = path.basename(img);
|
||||
let found = false;
|
||||
for (const tf of textFiles) {
|
||||
try {
|
||||
const content = fs.readFileSync(tf, 'utf8');
|
||||
if (content.indexOf(name) !== -1) { found = true; break; }
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (!found) unused.push(img);
|
||||
}
|
||||
|
||||
console.log(JSON.stringify({ images: images, unused: unused }, null, 2));
|
||||
51
tools/move_unused_images.ps1
Normal file
51
tools/move_unused_images.ps1
Normal file
@@ -0,0 +1,51 @@
|
||||
$root = 'E:\ForkSync\Wx_BLWConfigTools_V02_Prod'
|
||||
$backup = Join-Path $root 'trash_images_backup'
|
||||
if (-not (Test-Path $backup)) { New-Item -Path $backup -ItemType Directory | Out-Null }
|
||||
$files = @(
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\icon\vacant.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\icon\住宿.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\icon\开门.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\icon\设备编号.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\icon\退房.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\icon\酒店.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\icon\重启.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\BasicsBg.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\cjkz.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\componentBg.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\logo.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\share.jpg',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\tabbar\about.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\tabbar\about_cur.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\tabbar\basics.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\tabbar\basics_cur.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\tabbar\component.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\tabbar\component_cur.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\tabbar\plugin.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\tabbar\plugin_cur.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\wave.gif',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\images\zanCode.jpg',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\img\back.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\img\ble.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\img\ecble.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\img\logo.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\img\s1.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\img\s2.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\img\s3.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\img\s4.png',
|
||||
'E:\ForkSync\Wx_BLWConfigTools_V02_Prod\img\s5.png'
|
||||
)
|
||||
$moved = @()
|
||||
foreach ($f in $files) {
|
||||
if (Test-Path -Path $f) {
|
||||
try {
|
||||
Move-Item -Path $f -Destination $backup -Force
|
||||
$moved += $f
|
||||
} catch {
|
||||
Write-Error "Failed to move $f : $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
Write-Output "Moved files:`n"
|
||||
$moved
|
||||
Write-Output "`nBackup dir contents:`n"
|
||||
Get-ChildItem -Path $backup -Recurse | ForEach-Object { $_.FullName }
|
||||
Reference in New Issue
Block a user