web release

This commit is contained in:
Developer
2026-04-03 03:31:24 +08:00
parent cba04235c8
commit 14caf84236
21 changed files with 120 additions and 0 deletions

View File

@@ -7,6 +7,26 @@ All notable changes to this project will be documented in this file.
## [1.4.1] - 2026-04-03 ## [1.4.1] - 2026-04-03
### 新增 ### 新增
-**项目默认图标裁剪**
- 使用 Python PIL 库裁剪图片为正方形
- 生成了多种尺寸的应用图标1024x1024, 512x512, 256x256 等)
- 默认图标尺寸512x512
- 涉及文件:
- `assets/app_icon_default.png` - 项目默认图标512x512
- `assets/app_icon_square.png` - 正方形原图1271x1271
- `assets/app_icon_*.png` - 各种尺寸图标
- `crop_image.py` - 图片裁剪脚本
-**Web 图标替换**
- 替换了所有 web 平台的图标为新图片
- 包括favicon.png (32x32)、PWA 图标 (192x192, 512x512)
- 包含 maskable 图标版本
- 涉及文件:
- `web/favicon.png` - 网站图标
- `web/icons/Icon-192.png` - PWA 图标
- `web/icons/Icon-512.png` - PWA 图标
- `web/icons/Icon-maskable-192.png` - PWA 可遮罩图标
- `web/icons/Icon-maskable-512.png` - PWA 可遮罩图标
- `replace_web_icons.py` - Web 图标替换脚本
-**从 pubspec.yaml 动态获取版本号** -**从 pubspec.yaml 动态获取版本号**
- 使用 package_info_plus 插件动态获取应用版本号和版本代码 - 使用 package_info_plus 插件动态获取应用版本号和版本代码
- 在 AppConfig 中添加 init() 初始化方法和 appVersion、appVersionCode getter - 在 AppConfig 中添加 init() 初始化方法和 appVersion、appVersionCode getter

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

BIN
assets/app_icon_128x128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
assets/app_icon_144x144.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
assets/app_icon_192x192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
assets/app_icon_216x216.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

BIN
assets/app_icon_256x256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

BIN
assets/app_icon_48x48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
assets/app_icon_512x512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

BIN
assets/app_icon_64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

BIN
assets/app_icon_72x72.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
assets/app_icon_96x96.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
assets/app_icon_default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

BIN
assets/app_icon_square.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

59
crop_image.py Normal file
View File

@@ -0,0 +1,59 @@
from PIL import Image
import os
# 图片路径
input_path = r"e:\project\flutter\f3\flutter_application_2\assets\IMG_20260402_172628.png"
output_dir = r"e:\project\flutter\f3\flutter_application_2\assets"
# 打开图片
img = Image.open(input_path)
print(f"原始图片尺寸: {img.size}")
print(f"原始图片模式: {img.mode}")
# 定义需要的尺寸(应用图标和启动图常见尺寸)
sizes = [
(1024, 1024), # iOS/macOS 主图标
(512, 512), # 大图标
(256, 256), # 中图标
(128, 128), # 小图标
(64, 64), # 更小图标
(192, 192), # Android mipmap-xxhdpi
(144, 144), # Android mipmap-xxxhdpi (96x1.5)
(96, 96), # Android mipmap-xhdpi
(72, 72), # Android mipmap-hdpi
(48, 48), # Android mipmap-mdpi
(216, 216), # HarmonyOS icon_xlarge
(144, 144), # HarmonyOS icon_large
(96, 96), # HarmonyOS icon
(72, 72), # HarmonyOS icon_small
]
# 裁剪为正方形(居中裁剪)
width, height = img.size
min_size = min(width, height)
left = (width - min_size) // 2
top = (height - min_size) // 2
right = left + min_size
bottom = top + min_size
square_img = img.crop((left, top, right, bottom))
print(f"裁剪后正方形尺寸: {square_img.size}")
# 保存正方形原图
square_path = os.path.join(output_dir, "app_icon_square.png")
square_img.save(square_path, "PNG")
print(f"保存正方形原图: {square_path}")
# 生成各种尺寸
for size in sizes:
resized = square_img.resize(size, Image.Resampling.LANCZOS)
output_path = os.path.join(output_dir, f"app_icon_{size[0]}x{size[1]}.png")
resized.save(output_path, "PNG")
print(f"保存: {output_path}")
# 保存为项目默认图标
default_icon_path = os.path.join(output_dir, "app_icon_default.png")
default_size = (512, 512)
default_img = square_img.resize(default_size, Image.Resampling.LANCZOS)
default_img.save(default_icon_path, "PNG")
print(f"\n保存项目默认图标: {default_icon_path}")
print("完成!")

41
replace_web_icons.py Normal file
View File

@@ -0,0 +1,41 @@
from PIL import Image
import os
# 源图片路径
source_path = r"e:\project\flutter\f3\flutter_application_2\assets\app_icon_square.png"
web_dir = r"e:\project\flutter\f3\flutter_application_2\web"
# 打开源图片
img = Image.open(source_path)
print(f"源图片尺寸: {img.size}")
# 替换的图标列表
icons = [
# (文件名, 尺寸, 是否是maskable)
("favicon.png", (32, 32), False),
("icons/Icon-192.png", (192, 192), False),
("icons/Icon-512.png", (512, 512), False),
("icons/Icon-maskable-192.png", (192, 192), True),
("icons/Icon-maskable-512.png", (512, 512), True),
]
for filename, size, is_maskable in icons:
output_path = os.path.join(web_dir, filename)
# 调整尺寸
resized = img.resize(size, Image.Resampling.LANCZOS)
# 如果是 maskable 图标,可以添加一些边距(可选)
if is_maskable:
# 创建一个更大的画布,添加边距
margin = int(size[0] * 0.1) # 10% 边距
new_size = (size[0] + margin * 2, size[1] + margin * 2)
background = Image.new("RGBA", new_size, (0, 0, 0, 0))
background.paste(resized, (margin, margin))
resized = background.resize(size, Image.Resampling.LANCZOS)
# 保存
resized.save(output_path, "PNG")
print(f"替换: {output_path} ({size})")
print("\n所有 web 图标替换完成!")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 B

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 286 KiB