笔记笔记
  • Home
  • AI&ML
  • Example
  • Zoo
  • 关于
⌘ K
Light mode
目录
灵感
统一资源标识符
画图工具
收藏的正则表达式
灰度站点
LaTeX
DNS
HTTP 协议状态码
收集财报
下载 WWDC 字幕
暂存
工具
工具
Shell 软件
Git
ImageMagick
MyCLI
MySQL
桌面软件
Chrome
DataGrip
IntelliJ IDEA 技巧
PxCook
Wireshark
最后更新时间:
Copyright © 2023-2026 | Powered by dumi | GuoDapeng | 冀ICP备20004032号-2 | 冀公网安备 冀公网安备13020302001452号

TABLE OF CONTENTS

灰度站点

.dumirc.ts 配置 headScripts 和 styles。

ts
import { defineConfig } from 'dumi';
export default defineConfig({
headScripts: ['/memorial/memorial.js'],
styles: ['/memorial/memorial.css'],
});

public/memorial/memorial.css 配置灰度样式。

css
/* 纪念日黑白模式样式*/
.memorial-mode {
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
}

public/memorial/memorial.js 配置灰度脚本。

js
// 检查当前日期,如果是纪念日则启用黑白模式
function checkMemorialDay() {
const today = new Date();
const currentMonth = today.getMonth() + 1; // 月份从0开始
const currentDay = today.getDate();
// 定义纪念日数组 [月份, 日期]
const memorialDays = [
[4, 4], // 清明
[4, 5], // 清明
[4, 6], // 清明
[9, 18], // 九一八
[9, 30], // 中国烈士纪念日
[12, 13], // 南京大屠杀死难者国家公祭日
];
const isMemorialDay = memorialDays.some(
(day) => day[0] === currentMonth && day[1] === currentDay,
);
if (isMemorialDay) {
document.body.classList.add('memorial-mode');
}
}
document.addEventListener('DOMContentLoaded', function () {
// 页面加载时检查
checkMemorialDay();
});