mirror of
https://github.com/XTLS/Xray-docs-next.git
synced 2025-01-19 17:21:41 +03:00
Fix: theme local options
This commit is contained in:
parent
5d09bc4d76
commit
f1671b156f
@ -23,7 +23,6 @@ export default defineUserConfig<DefaultThemeOptions>({
|
||||
editLinks: true,
|
||||
editLinkText: "帮助我们改善此页面!",
|
||||
enableToggle: true,
|
||||
ToggleText: "切换主题",
|
||||
navbar: [
|
||||
{ text: "首页", link: "/" },
|
||||
{ text: "大史记", link: "/about/news.md" },
|
||||
@ -159,6 +158,11 @@ export default defineUserConfig<DefaultThemeOptions>({
|
||||
themePlugins: {
|
||||
git: process.env.NODE_ENV === "production",
|
||||
},
|
||||
locales: {
|
||||
"/": {
|
||||
ToggleText: "切换主题",
|
||||
},
|
||||
},
|
||||
},
|
||||
markdown: {
|
||||
toc: {
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from "vue";
|
||||
import { ThemeOptions } from "../index";
|
||||
declare const __LAYOUT__OPTIONS__: ThemeOptions;
|
||||
import { useThemeLocaleData } from "@vuepress/plugin-theme-data/lib/composables";
|
||||
import { ToggleOptions } from "../types";
|
||||
|
||||
export default defineComponent({
|
||||
data() {
|
||||
@ -21,8 +21,9 @@ export default defineComponent({
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.enable = __LAYOUT__OPTIONS__.enableToggle;
|
||||
this.text = __LAYOUT__OPTIONS__.ToggleText;
|
||||
const option = useThemeLocaleData<ToggleOptions>();
|
||||
this.enable = option.value.enableToggle;
|
||||
this.text = option.value.ToggleText;
|
||||
},
|
||||
methods: {
|
||||
toggleTheme() {
|
||||
|
@ -1,21 +1,13 @@
|
||||
import { path } from "@vuepress/utils";
|
||||
import { Theme } from "@vuepress/core";
|
||||
|
||||
export interface ThemeOptions {
|
||||
enableToggle?: boolean;
|
||||
ToggleText?: string;
|
||||
}
|
||||
|
||||
export const docsPlugin: Theme<ThemeOptions> = (options, app) => {
|
||||
export const docsPlugin: Theme = (options, app) => {
|
||||
return {
|
||||
name: "xray-docs-theme",
|
||||
extends: "@vuepress/theme-default",
|
||||
layouts: {
|
||||
Layout: path.resolve(__dirname, "layouts/Layout.vue"),
|
||||
},
|
||||
define: {
|
||||
__LAYOUT__OPTIONS__: options,
|
||||
},
|
||||
clientAppEnhanceFiles: path.resolve(__dirname, "clientAppEnhance.ts"),
|
||||
plugins: [["@vuepress/plugin-palette", { preset: "sass" }]],
|
||||
};
|
||||
|
@ -29,7 +29,3 @@ export default defineComponent({
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="sass">
|
||||
//@import "../styles/default/index.scss"
|
||||
</style>
|
||||
|
1
docs/.vuepress/theme/types/index.ts
Normal file
1
docs/.vuepress/theme/types/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from "./toggle";
|
4
docs/.vuepress/theme/types/toggle.ts
Normal file
4
docs/.vuepress/theme/types/toggle.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export interface ToggleOptions {
|
||||
enableToggle?: boolean;
|
||||
ToggleText?: string;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user