packServer/extension/tools/make-icons.ps1
liufumingren bd2363bf00 chore: 初始化仓库(backend / frontend / extension 三块)
- backend/:Egg 3 纯 JSON 接口服务(MySQL 8 + Redis),全部走 header 令牌鉴权;
  已彻底去掉服务端渲染(删除 page 控制器 / app/view / nunjucks / session / CSRF),
  开发时把页面请求反代到前端 dev server,生产托管 frontend/dist(SPA 回退)。
  单测 91 个通过(不需要本机数据库)。
- frontend/:Vite + Vue3 + TypeScript 的 SPA(登录 / 注册 / 找回密码 / 扫码登录与确认 /
  首页统计 / 设备管理 / 扫码记录 / 个人中心 / 测试页),vue-tsc 类型检查与构建通过。
- extension/:MV3 浏览器扩展(零构建),注入第三方 WMS 页面识别运单号并打开溯源页。
- 忽略规则统一放根 .gitignore:node_modules、dist、logs / logs-*、run、typings、
  .env*、config.local.js(含本机数据库与 Redis 密码,绝不入库)。
2026-10-17 08:50:32 +08:00

71 lines
2.8 KiB
PowerShell

# Generate extension icons (16 / 32 / 48 / 128). Zero dependency: System.Drawing only.
#
# Usage (PowerShell 5.1):
# powershell -ExecutionPolicy Bypass -File tools\make-icons.ps1
#
# IMPORTANT - keep this file pure ASCII.
# PowerShell 5.1 on a zh-CN machine reads .ps1 files WITHOUT a BOM as GBK, so any UTF-8
# Chinese in here becomes mojibake; and mojibake inside a format string such as
# ("done: {0}" -f $x) can even break parsing: "Input string was not in a correct format".
#
# Artwork: rounded gradient tile (deep blue -> teal) + white barcode bars.
Add-Type -AssemblyName System.Drawing
$root = Split-Path -Parent $PSScriptRoot # extension/
$outDir = Join-Path $root 'icons'
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
function New-Icon([int]$size) {
$bmp = New-Object System.Drawing.Bitmap($size, $size, [System.Drawing.Imaging.PixelFormat]::Format32bppArgb)
$g = [System.Drawing.Graphics]::FromImage($bmp)
$g.SmoothingMode = [System.Drawing.Drawing2D.SmoothingMode]::AntiAlias
$g.Clear([System.Drawing.Color]::Transparent)
# ---- rounded rectangle background ----
$r = [Math]::Max(2, [int]($size * 0.22))
$d = $r * 2
$rect = New-Object System.Drawing.Rectangle(0, 0, $size, $size)
$path = New-Object System.Drawing.Drawing2D.GraphicsPath
$path.AddArc($rect.X, $rect.Y, $d, $d, 180, 90)
$path.AddArc($rect.Right - $d, $rect.Y, $d, $d, 270, 90)
$path.AddArc($rect.Right - $d, $rect.Bottom - $d, $d, $d, 0, 90)
$path.AddArc($rect.X, $rect.Bottom - $d, $d, $d, 90, 90)
$path.CloseAllFigures()
$c1 = [System.Drawing.Color]::FromArgb(255, 12, 74, 110)
$c2 = [System.Drawing.Color]::FromArgb(255, 14, 165, 164)
$brush = [System.Drawing.Drawing2D.LinearGradientBrush]::new($rect, $c1, $c2, [single]45)
$g.FillPath($brush, $path)
# ---- white barcode bars, alternating heights ----
$white = [System.Drawing.SolidBrush]::new([System.Drawing.Color]::FromArgb(255, 255, 255, 255))
$barW = [Math]::Max(1, [int]($size * 0.075))
$gap = [Math]::Max(1, [int]($size * 0.055))
$x = [int]($size * 0.20)
$top = [int]($size * 0.28)
$bot = [int]($size * 0.72)
$limit = $size * 0.82
$ratios = @(0.55, 1.0, 0.72, 1.0, 0.6, 0.88, 1.0, 0.66)
foreach ($ratio in $ratios) {
if ($x + $barW -gt $limit) { break }
$h = [int](($bot - $top) * $ratio)
$g.FillRectangle($white, $x, ($bot - $h), $barW, $h)
$x += $barW + $gap
}
$g.Dispose()
$brush.Dispose()
$white.Dispose()
$path.Dispose()
$file = Join-Path $outDir ("icon{0}.png" -f $size)
$bmp.Save($file, [System.Drawing.Imaging.ImageFormat]::Png)
$bmp.Dispose()
Write-Host (" {0,-16} {1}x{1}" -f (Split-Path -Leaf $file), $size)
}
Write-Host 'Building icons ->'
foreach ($s in 16, 32, 48, 128) { New-Icon $s }
Write-Host ('Done. Output: {0}' -f $outDir)