以下代码添加到主题 js 文件内:

function switchMode() {
    if (document.getElementById("style-dark")) {
        var link = document.getElementById("style-dark");
        link.href = "https://ieu.xyz/usr/themes/ieu/jscss/style-white.css";
        link.id = "style-white";
        document.cookie = "stylemode=white;" + "path=/;" + "max-age=21600"
    } else if (document.getElementById("style-white")) {
        var link = document.getElementById("style-white");
        link.href = "https://ieu.xyz/usr/themes/ieu/jscss/style-dark.css";
        link.id = "style-dark";
        document.cookie = "stylemode=dark;" + "path=/;" + "max-age=21600"
    }
};

以下代码添加到主题 function.php 文件内:

function themeConfig($form) {
    $siteskin = new Typecho_Widget_Helper_Form_Element_Radio('siteskin', 
    array('white' => _t('白天模式'),
    'dark' => _t('深夜模式'),
    'auto' => _t('自动')),
    'white', _t('主题模式'),);
    $form->addInput($siteskin);
    $skinoptions = new Typecho_Widget_Helper_Form_Element_Checkbox('skinoptions', 
    array('free' => _t('允许访客切换模式')),
    NULL, _t('主题模式选项'),);
    $form->addInput($skinoptions->multiMode());
}

function skinUrl($path,$ext,$skinid = NULL) {
    $options = Helper::options();
    if (!empty($options->skinoptions) && in_array('free', $options->skinoptions) && isset($_COOKIE["stylemode"]) && $_COOKIE["stylemode"] == "dark") {
        if ($skinid=='id') {echo 'style-dark';} 
        else {$options->themeUrl($path.'style-dark'.$ext);}
    } elseif (!empty($options->skinoptions) && in_array('free', $options->skinoptions) && isset($_COOKIE["stylemode"]) && $_COOKIE["stylemode"] == "white") {
        if ($skinid=='id') {echo 'style-white';} 
        else {$options->themeUrl($path.'style-white'.$ext);}
    } elseif ($options->siteskin == 'auto' && (date('G') < 6 || date('G') >= 22)) {
        if ($skinid=='id') {echo 'style-dark';}
        else {$options->themeUrl($path.'style-dark'.$ext);}
    } elseif ($options->siteskin == 'dark') {
        if ($skinid=='id') {echo 'style-dark';}
        else {$options->themeUrl($path.'style-dark'.$ext);}
    } else {
        if ($skinid=='id') {echo 'style-white';}
        else {$options->themeUrl($path.'style-white'.$ext);}
    }
}

以下代码添加到 heeder.php 文件内:

<link rel="stylesheet" href="<?php skinUrl('jscss/','.css'); ?>" 
id="<?php skinUrl('','','id'); ?>" />

以下代码添加到 footer.php 文件内:

<div class="change" onclick="switchMode()"></div>