站点:纯静态 HTML + CSS + 原生 JS,零框架零构建
页面:首页 / 合作品牌 / 荣誉资质 / 客户案例 / 关于我们
内容:
- site/ 站点本体(含已压缩 webp 图片,约 4.8 MB)
- deploy/ Docker Compose / Caddy / Apache 部署配置
- _tools/ 开发自检脚本与部署脚本
- Dockerfile 自建 nginx 镜像方案
- README.md 项目文档
设计:品牌黄 #ffc107 + 白,深蓝仅用于页脚;菜单长期置顶;
交互动效只加在关键词与区块级元素上。
素材说明:原始素材(背景图/老网站/方案/荣誉资质/合作品牌,约 290 MB)
未纳入版本控制,站点使用的是 site/assets 内已处理压缩的图片。
57 lines
2.2 KiB
JavaScript
57 lines
2.2 KiB
JavaScript
// 色值对比度核算(WCAG)+ 页脚结构复查
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
function lum(hex) {
|
|
const c = hex.replace('#', '');
|
|
const v = [0, 2, 4].map(i => parseInt(c.substr(i, 2), 16) / 255)
|
|
.map(x => x <= 0.03928 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4));
|
|
return 0.2126 * v[0] + 0.7152 * v[1] + 0.0722 * v[2];
|
|
}
|
|
function ratio(a, b) {
|
|
const l1 = lum(a), l2 = lum(b);
|
|
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
}
|
|
|
|
const PAIRS = [
|
|
['标题 ink-900 / 白底', '#0b1526', '#ffffff', 7],
|
|
['正文 text-2 / 白底', '#45566e', '#ffffff', 4.5],
|
|
['次要 text-3 / 白底', '#78889b', '#ffffff', 3],
|
|
['深金 y-700 / 白底', '#8a5e00', '#ffffff', 4.5],
|
|
['深金 y-700 / 浅黄底', '#8a5e00', '#fff8df', 4.5],
|
|
['按钮文字 ink-900 / 主黄', '#0b1526', '#ffc107', 4.5],
|
|
['页脚正文 / 页脚底', '#9fb0c9', '#07101f', 4.5],
|
|
['页脚标题 / 页脚底', '#ffffff', '#07101f', 7],
|
|
['页脚次级 / 页脚底', '#8595ad', '#07101f', 3],
|
|
['页脚黄 / 页脚底', '#ffd23d', '#07101f', 4.5]
|
|
];
|
|
|
|
console.log('== 文字对比度(WCAG,越大越好)==');
|
|
let bad = 0;
|
|
for (const [label, fg, bg, need] of PAIRS) {
|
|
const r = ratio(fg, bg);
|
|
const pass = r >= need;
|
|
if (!pass) bad++;
|
|
console.log(' ' + (pass ? 'OK ' : 'LOW ') + label.padEnd(28) +
|
|
r.toFixed(2) + ':1 (需要 ≥' + need + ')');
|
|
}
|
|
|
|
console.log('\n== 页脚结构复查 ==');
|
|
const SITE = path.join(__dirname, '..', 'site');
|
|
for (const f of ['index.html', 'brands.html', 'honors.html', 'cases.html', 'about.html']) {
|
|
const s = fs.readFileSync(path.join(SITE, f), 'utf8');
|
|
const hasNote = /本站图文/.test(s);
|
|
const footOpen = (s.match(/<footer/g) || []).length;
|
|
const footClose = (s.match(/<\/footer>/g) || []).length;
|
|
const bottom = (s.match(/footer__bottom/g) || []).length;
|
|
const ok = !hasNote && footOpen === 1 && footClose === 1 && bottom === 1;
|
|
console.log(' ' + (ok ? 'OK ' : 'FAIL') + f.padEnd(14) +
|
|
'footer标签 ' + footOpen + '/' + footClose +
|
|
' footer__bottom ' + bottom +
|
|
(hasNote ? ' !! 仍有"本站图文"字样' : ''));
|
|
if (!ok) bad++;
|
|
}
|
|
|
|
console.log('\n' + (bad ? bad + ' 项需要关注' : '全部通过'));
|
|
process.exit(bad ? 1 : 0);
|