官网改版上线:关于我们与联系我们页重构、首页AI主视觉v4、品牌标识与导航交互;同步测试与设计文档
这个提交包含在:
@@ -5,6 +5,7 @@
|
||||
2. 验证新版服务页摄影配图真实存在、尺寸满足首屏展示要求,并提供 WebP 兼容版本;
|
||||
3. 验证联系我们页矢量配图符合浅色专业风规范。
|
||||
"""
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
||||
@@ -12,54 +13,86 @@ from PIL import Image
|
||||
|
||||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
RASTER_ROOT = os.path.join(ROOT_DIR, 'public', 'assets', 'addons', 'official', 'images')
|
||||
SHOWCASE_ROOT = os.path.join(RASTER_ROOT, 'showcases')
|
||||
RASTER_ROOT = os.path.join(ROOT_DIR, "public", "assets", "addons", "official", "images")
|
||||
SHOWCASE_ROOT = os.path.join(RASTER_ROOT, "showcases")
|
||||
|
||||
SERVICE_HEROES = {
|
||||
'software': ('software/structure-v2.jpg', 1440, 960),
|
||||
'app': ('app/terminals.jpg', 1440, 960),
|
||||
'agent': ('agent/landscape-v2.jpg', 1920, 640),
|
||||
"software": ("software/structure-v2.jpg", 1440, 960),
|
||||
"app": ("app/terminals.jpg", 1440, 960),
|
||||
"agent": ("agent/landscape-v2.jpg", 1920, 640),
|
||||
"contact": ("contact/connection.jpg", 1440, 960),
|
||||
}
|
||||
|
||||
|
||||
class TestDedicatedPageIllustrations(unittest.TestCase):
|
||||
|
||||
def test_illustration_assets_exist(self):
|
||||
"""测试专属配图文件存在、格式有效且尺寸满足展示要求"""
|
||||
for key, (relative_path, minimum_width, minimum_height) in SERVICE_HEROES.items():
|
||||
for key, (
|
||||
relative_path,
|
||||
minimum_width,
|
||||
minimum_height,
|
||||
) in SERVICE_HEROES.items():
|
||||
with self.subTest(page=key):
|
||||
jpg_path = os.path.join(RASTER_ROOT, relative_path)
|
||||
webp_path = os.path.splitext(jpg_path)[0] + '.webp'
|
||||
self.assertTrue(os.path.isfile(jpg_path), f"缺少专属精美配图: {relative_path}")
|
||||
self.assertTrue(os.path.isfile(webp_path), f"缺少 WebP 兼容版本: {relative_path}")
|
||||
webp_path = os.path.splitext(jpg_path)[0] + ".webp"
|
||||
self.assertTrue(
|
||||
os.path.isfile(jpg_path), f"缺少专属精美配图: {relative_path}"
|
||||
)
|
||||
self.assertTrue(
|
||||
os.path.isfile(webp_path), f"缺少 WebP 兼容版本: {relative_path}"
|
||||
)
|
||||
with Image.open(jpg_path) as hero:
|
||||
width, height = hero.size
|
||||
self.assertGreaterEqual(width, minimum_width, f"{relative_path} 宽度不足首屏要求")
|
||||
self.assertGreaterEqual(height, minimum_height, f"{relative_path} 高度不足首屏要求")
|
||||
self.assertGreater(os.path.getsize(jpg_path), 50_000, f"{relative_path} 文件过小")
|
||||
self.assertGreaterEqual(
|
||||
width, minimum_width, f"{relative_path} 宽度不足首屏要求"
|
||||
)
|
||||
self.assertGreaterEqual(
|
||||
height, minimum_height, f"{relative_path} 高度不足首屏要求"
|
||||
)
|
||||
self.assertGreater(
|
||||
os.path.getsize(jpg_path), 50_000, f"{relative_path} 文件过小"
|
||||
)
|
||||
|
||||
contact_path = os.path.join(SHOWCASE_ROOT, 'contact_headquarters.svg')
|
||||
with open(contact_path, encoding='utf-8') as stream:
|
||||
contact_path = os.path.join(SHOWCASE_ROOT, "contact_headquarters.svg")
|
||||
with open(contact_path, encoding="utf-8") as stream:
|
||||
contact_content = stream.read()
|
||||
self.assertIn('<svg', contact_content, 'contact_headquarters.svg 必须是有效矢量 SVG')
|
||||
self.assertIn(
|
||||
"<svg", contact_content, "contact_headquarters.svg 必须是有效矢量 SVG"
|
||||
)
|
||||
|
||||
def test_pages_embed_dedicated_illustrations(self):
|
||||
"""测试各独立页面均正确嵌入对应的精美配图"""
|
||||
pages = {
|
||||
'software': ('official_product/service_software.html', 'images/software/structure-v2.jpg'),
|
||||
'app': ('official_product/service_app.html', 'images/app/terminals.jpg'),
|
||||
'agent': ('official_product/service_agent.html', 'images/agent/landscape-v2.jpg'),
|
||||
'contact_pc': ('official_online_message/list.html', 'contact_headquarters.svg'),
|
||||
'contact_m': ('official_online_message/list_e.html', 'contact_headquarters.svg'),
|
||||
"software": (
|
||||
"official_product/service_software.html",
|
||||
"images/software/structure-v2.jpg",
|
||||
),
|
||||
"app": ("official_product/service_app.html", "images/app/terminals.jpg"),
|
||||
"agent": (
|
||||
"official_product/service_agent.html",
|
||||
"images/agent/landscape-v2.jpg",
|
||||
),
|
||||
"contact_pc": (
|
||||
"official_online_message/list.html",
|
||||
"images/contact/connection.jpg",
|
||||
),
|
||||
"contact_m": (
|
||||
"official_online_message/list_e.html",
|
||||
"images/contact/connection.jpg",
|
||||
),
|
||||
}
|
||||
template_dir = os.path.join(ROOT_DIR, 'addons', 'official', 'view', 'web')
|
||||
template_dir = os.path.join(ROOT_DIR, "addons", "official", "view", "web")
|
||||
for key, (template_relative_path, image_name) in pages.items():
|
||||
with self.subTest(page=key):
|
||||
template_path = os.path.join(template_dir, template_relative_path)
|
||||
with open(template_path, encoding='utf-8') as stream:
|
||||
with open(template_path, encoding="utf-8") as stream:
|
||||
html = stream.read()
|
||||
self.assertIn(image_name, html, f"页面 {template_relative_path} 必须正确引用专属配图 {image_name}")
|
||||
self.assertIn(
|
||||
image_name,
|
||||
html,
|
||||
f"页面 {template_relative_path} 必须正确引用专属配图 {image_name}",
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
在新工单中引用
屏蔽一个用户