Files
xuanheng-website/_tools/fix-logo-attrs.js
T
dsh f81d41c5ca 初始化:炫恒网络官网(五个页面)
站点:纯静态 HTML + CSS + 原生 JS,零框架零构建
页面:首页 / 合作品牌 / 荣誉资质 / 客户案例 / 关于我们

内容:
- site/          站点本体(含已压缩 webp 图片,约 4.8 MB)
- deploy/        Docker Compose / Caddy / Apache 部署配置
- _tools/        开发自检脚本与部署脚本
- Dockerfile     自建 nginx 镜像方案
- README.md      项目文档

设计:品牌黄 #ffc107 + 白,深蓝仅用于页脚;菜单长期置顶;
      交互动效只加在关键词与区块级元素上。

素材说明:原始素材(背景图/老网站/方案/荣誉资质/合作品牌,约 290 MB)
         未纳入版本控制,站点使用的是 site/assets 内已处理压缩的图片。
2026-10-13 16:12:41 +08:00

37 lines
1.5 KiB
JavaScript

// 移除品牌 logo 的固定 width/height 属性:
// CSS 用「固定高度 + 宽度自动」来统一大小,写死属性尺寸只会造成冲突与变形。
const fs = require('fs');
const path = require('path');
const SITE = path.join(__dirname, '..', 'site');
for (const f of ['index.html', 'brands.html']) {
const p = path.join(SITE, f);
let s = fs.readFileSync(p, 'utf8');
const before = s;
let n = 0;
// <img src="assets/img/brands/xxx.webp" ... width="360" height="240">
s = s.replace(/(<img\s+src="assets\/img\/brands\/[^"]+"[^>]*?)\s+width="\d+"\s+height="\d+"/g,
(m, head) => { n++; return head; });
if (s !== before) { fs.writeFileSync(p, s, 'utf8'); console.log('updated ' + f + ' (' + n + ' 处)'); }
else console.log('no change ' + f);
}
// 复查
console.log('\n复查品牌 logo 的 img 标签:');
for (const f of ['index.html', 'brands.html']) {
const s = fs.readFileSync(path.join(SITE, f), 'utf8');
const tags = [...s.matchAll(/<img\s+src="assets\/img\/brands\/[^>]*>/g)].map(m => m[0]);
const withDim = tags.filter(t => /width=/.test(t));
console.log(' ' + f.padEnd(14) + tags.length + ' 个品牌 logo,仍带 width 属性的: ' + withDim.length);
if (tags[0]) console.log(' 示例: ' + tags[0]);
}
// 顺带确认 CSS 里的固定高度规则存在
const css = fs.readFileSync(path.join(SITE, 'assets', 'css', 'main.css'), 'utf8');
const rule = css.match(/\.marquee__item img\s*\{[^}]*\}/);
console.log('\nCSS 规则 .marquee__item img:');
console.log(rule ? rule[0] : ' 未找到!');