docs: 更新文档

This commit is contained in:
就眠儀式 2022-03-30 23:10:11 +08:00
parent 020a260279
commit b355c1939b
2 changed files with 26 additions and 6 deletions

View File

@ -210,7 +210,7 @@
</lay-config-provider> </lay-config-provider>
</template> </template>
<script> <script>
import { ref, watch } from "vue"; import { provide, ref, watch } from "vue";
import { useRouter, useRoute } from "vue-router"; import { useRouter, useRoute } from "vue-router";
import menu from "../view/utils/menus"; import menu from "../view/utils/menus";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -279,6 +279,9 @@ export default {
locale.value = lang; locale.value = lang;
}; };
provide("isDark",isDark);
provide("theme",theme);
return { return {
t, t,
menus, menus,

View File

@ -16,9 +16,10 @@
<router-link class="layui-inline site-down" to="/zh-CN/guide"> <router-link class="layui-inline site-down" to="/zh-CN/guide">
Get Started Get Started
</router-link> </router-link>
<router-link class="layui-inline site-down" to="/zh-CN/guide"> <a class="layui-inline site-down" href="javascript:void(0);" @click="changeTheme">
Switch Dark
</router-link> {{ isDark ? 'Turn Off' : 'Turn On'}}
</a>
</div> </div>
<div class="site-version"> <div class="site-version">
<span <span
@ -40,7 +41,7 @@
rel="nofollow" rel="nofollow"
class="site-star" class="site-star"
> >
<i class="layui-icon"></i> Star <cite id="getStars">716</cite> <i class="layui-icon"></i> Star <cite id="getStars">741</cite>
</a> </a>
<a <a
href="https://gitee.com/layui-vue" href="https://gitee.com/layui-vue"
@ -107,14 +108,30 @@
</template> </template>
<script> <script>
import { inject, provide } from 'vue';
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
export default { export default {
name: "index", name: "index",
setup() { setup() {
const { t } = useI18n(); const { t } = useI18n();
const isDark = inject("isDark");
const theme = inject("theme");
const changeTheme = () => {
isDark.value = !isDark.value;
if(theme.value === 'dark') {
theme.value = 'light';
} else {
theme.value = 'dark';
}
}
return { return {
t, t,
isDark,
theme,
changeTheme
}; };
}, },
}; };
@ -162,7 +179,7 @@ body {
padding: 0 20px 0 20px; padding: 0 20px 0 20px;
height: 40px; height: 40px;
line-height: 40px; line-height: 40px;
border-radius: 6px; border-radius: 4px;
background: #f1f1f1; background: #f1f1f1;
border: 1px solid #f1f1f1; border: 1px solid #f1f1f1;
font-size: 16px; font-size: 16px;