feat: add DMG background with Gatekeeper installation guide
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env python3
|
||||
"""生成 DMG 背景图,包含安装指引"""
|
||||
|
||||
import subprocess
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
# 动态获取中文字体路径
|
||||
result = subprocess.run(
|
||||
["fc-match", "-f", "%{file}", "PingFang SC"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
font_path = result.stdout.strip() if result.returncode == 0 else None
|
||||
|
||||
# DMG 窗口尺寸
|
||||
W, H = 1320, 800
|
||||
|
||||
# 颜色
|
||||
BG_COLOR = (245, 245, 247)
|
||||
TEXT_COLOR = (29, 29, 31)
|
||||
ACCENT_COLOR = (0, 122, 255)
|
||||
ARROW_COLOR = (150, 150, 155)
|
||||
|
||||
img = Image.new("RGB", (W, H), BG_COLOR)
|
||||
draw = ImageDraw.Draw(img)
|
||||
|
||||
# 加载字体
|
||||
if font_path:
|
||||
font_title = ImageFont.truetype(font_path, 48, index=0)
|
||||
font_body = ImageFont.truetype(font_path, 32, index=2)
|
||||
font_small = ImageFont.truetype(font_path, 24, index=2)
|
||||
else:
|
||||
font_title = ImageFont.load_default()
|
||||
font_body = font_title
|
||||
font_small = font_title
|
||||
|
||||
# 标题
|
||||
draw.text((W//2, 60), "美家卡智影", fill=TEXT_COLOR, font=font_title, anchor="mm")
|
||||
|
||||
# 拖拽指引
|
||||
draw.text((W//2, 720), "将左侧图标拖拽到右侧 Applications 文件夹", fill=TEXT_COLOR, font=font_body, anchor="mm")
|
||||
|
||||
# 安装说明框
|
||||
box_x, box_y = 260, 500
|
||||
box_w, box_h = 800, 160
|
||||
draw.rounded_rectangle([box_x, box_y, box_x + box_w, box_y + box_h], radius=20, fill=(255, 255, 255), outline=ARROW_COLOR, width=2)
|
||||
|
||||
# 说明文字
|
||||
draw.text((W//2, box_y + 40), "⚠️ 首次安装提示", fill=ACCENT_COLOR, font=font_body, anchor="mm")
|
||||
draw.text((W//2, box_y + 95), '由于未注册 Apple 开发者,首次打开时请右键点击应用,选择"打开"', fill=TEXT_COLOR, font=font_small, anchor="mm")
|
||||
|
||||
# 保存
|
||||
img_1x = img.resize((660, 400), Image.LANCZOS)
|
||||
img_1x.save("tauri-app/src-tauri/dmg-background.png", "PNG")
|
||||
print("Generated tauri-app/src-tauri/dmg-background.png")
|
||||
@@ -70,7 +70,22 @@
|
||||
],
|
||||
"macOS": {
|
||||
"minimumSystemVersion": "13.0",
|
||||
"infoPlist": "Info.plist"
|
||||
"infoPlist": "Info.plist",
|
||||
"dmg": {
|
||||
"background": "dmg-background.png",
|
||||
"windowSize": {
|
||||
"width": 660,
|
||||
"height": 400
|
||||
},
|
||||
"appPosition": {
|
||||
"x": 180,
|
||||
"y": 170
|
||||
},
|
||||
"applicationFolderPosition": {
|
||||
"x": 480,
|
||||
"y": 170
|
||||
}
|
||||
}
|
||||
},
|
||||
"windows": {
|
||||
"nsis": {
|
||||
|
||||
Reference in New Issue
Block a user