docs: clean up GlobalConfig type definition by moving it to a separate type file

main
tangjinzhou 2025-11-17 23:50:44 +08:00
parent bbb7670df1
commit 252a0e2563
3 changed files with 11 additions and 9 deletions

View File

@ -10,7 +10,6 @@
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, provide, watch, ref } from 'vue'; import { computed, defineComponent, provide, watch, ref } from 'vue';
import type { Ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import useMediaQuery from './hooks/useMediaQuery'; import useMediaQuery from './hooks/useMediaQuery';
@ -21,16 +20,11 @@ import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn'; import 'dayjs/locale/zh-cn';
import { theme as antdTheme } from 'ant-design-vue'; import { theme as antdTheme } from 'ant-design-vue';
import SiteToken from './SiteToken.vue'; import SiteToken from './SiteToken.vue';
import type { GlobalConfig } from './type';
function isZhCN(name: string) { function isZhCN(name: string) {
return /-cn\/?$/.test(name); return /-cn\/?$/.test(name);
} }
export interface GlobalConfig {
isMobile: Ref<boolean>;
lang: Ref<'zh-CN' | 'en-US'>;
isZhCN: Ref<boolean>;
responsive: Ref<null | 'narrow' | 'crowded'>;
blocked: Ref<boolean>;
}
export type ThemeName = '' | 'light' | 'dark' | 'compact'; export type ThemeName = '' | 'light' | 'dark' | 'compact';
const getAlgorithm = (themes: ThemeName[] = []) => const getAlgorithm = (themes: ThemeName[] = []) =>
themes themes

View File

@ -108,7 +108,6 @@
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import type { GlobalConfig } from '../App.vue';
import { GLOBAL_CONFIG } from '../SymbolKey'; import { GLOBAL_CONFIG } from '../SymbolKey';
import { defineComponent, inject, computed, ref, provide, watch } from 'vue'; import { defineComponent, inject, computed, ref, provide, watch } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -129,6 +128,7 @@ import CompactIcon from './icons/Compact';
import surelyVueVue from '../components/surelyVue.vue'; import surelyVueVue from '../components/surelyVue.vue';
import WWAdsVue from '../components/rice/WWAds.vue'; import WWAdsVue from '../components/rice/WWAds.vue';
import { useWindowScroll } from '@vueuse/core'; import { useWindowScroll } from '@vueuse/core';
import type { GlobalConfig } from '../type';
const rControl = /[\u0000-\u001f]/g; const rControl = /[\u0000-\u001f]/g;
const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g; const rSpecial = /[\s~`!@#$%^&*()\-_+=[\]{}|\\;:"'<>,.?/]+/g;

8
site/src/type.ts Normal file
View File

@ -0,0 +1,8 @@
import type { Ref } from 'vue';
export interface GlobalConfig {
isMobile: Ref<boolean>;
lang: Ref<'zh-CN' | 'en-US'>;
isZhCN: Ref<boolean>;
responsive: Ref<null | 'narrow' | 'crowded'>;
blocked: Ref<boolean>;
}