子页面的js示例
```
<script>
// 接收父页面的主题模式
window.addEventListener('message', function(event) {
if (event.data.themeMode) {
var theme = event.data.themeMode;
// 测试是否正确接受到theme-mode的值
// console.log('Received theme mode from parent:', theme);
applyTheme(theme);
}
});
// 定义一个函数来应用主题
function applyTheme(theme) {
var body = document.body;
if (theme === 'dark') {
body.classList.add("dark-mode");
document.getElementById("darkModeToggle").checked = true;
} else {
body.classList.remove("dark-mode");
document.getElementById("darkModeToggle").checked = false;
}
}
</script>
```
| Name |
Last commit
|
Last Update |
|---|---|---|
| .. | ||
| About | Loading commit data... | |
| Channel | Loading commit data... | |
| Chat | Loading commit data... | |
| Chat2Link | Loading commit data... | |
| Detail | Loading commit data... | |
| Home | Loading commit data... | |
| Log | Loading commit data... | |
| Midjourney | Loading commit data... | |
| NotFound | Loading commit data... | |
| Pricing | Loading commit data... | |
| Redemption | Loading commit data... | |
| Setting | Loading commit data... | |
| Task | Loading commit data... | |
| Token | Loading commit data... | |
| TopUp | Loading commit data... | |
| User | Loading commit data... |