doc: update site

pull/6358/head
tangjinzhou 2023-03-14 13:38:47 +08:00
parent 11c52d487d
commit f3935ebb4f
14 changed files with 55 additions and 56 deletions

View File

@ -1,31 +1,6 @@
<template> <template>
<div> <a-tooltip>
<a-radio v-model:checked="checked1" :disabled="disabled">Disabled</a-radio> <template #title>prompt text</template>
<a-radio v-model:checked="checked2" :disabled="disabled">Disabled</a-radio> Tooltip will show when mouse enter.
<br /> </a-tooltip>
<div style="margin-top: 16px">
<a-button type="primary" @click="toggleDisabled">Toggle disabled</a-button>
</div>
</div>
</template> </template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
export default defineComponent({
setup() {
const disabled = ref<boolean>(true);
const checked1 = ref<boolean>(false);
const checked2 = ref<boolean>(false);
const toggleDisabled = () => {
disabled.value = !disabled.value;
};
return {
disabled,
checked1,
checked2,
toggleDisabled,
};
},
});
</script>

View File

@ -1,6 +1,8 @@
<template> <template>
<a-config-provider :locale="locale"> <a-config-provider :locale="locale" :theme="themeConfig">
<SiteToken>
<router-view /> <router-view />
</SiteToken>
</a-config-provider> </a-config-provider>
</template> </template>
@ -10,12 +12,13 @@ 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';
import useSiteToken from './hooks/useSiteToken';
import { GLOBAL_CONFIG } from './SymbolKey'; import { GLOBAL_CONFIG } from './SymbolKey';
import enUS from '../../components/locale/en_US'; import enUS from '../../components/locale/en_US';
import zhCN from '../../components/locale/zh_CN'; import zhCN from '../../components/locale/zh_CN';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn'; import 'dayjs/locale/zh-cn';
import { theme as antdTheme } from 'ant-design-vue';
import SiteToken from './SiteToken.vue';
function isZhCN(name: string) { function isZhCN(name: string) {
return /-cn\/?$/.test(name); return /-cn\/?$/.test(name);
} }
@ -26,14 +29,32 @@ export interface GlobalConfig {
responsive: Ref<null | 'narrow' | 'crowded'>; responsive: Ref<null | 'narrow' | 'crowded'>;
blocked: Ref<boolean>; blocked: Ref<boolean>;
} }
export type ThemeName = 'light' | 'dark' | 'compact';
const getAlgorithm = (themes: ThemeName[] = []) =>
themes.map(theme => {
if (theme === 'dark') {
return antdTheme.darkAlgorithm;
}
if (theme === 'compact') {
return antdTheme.compactAlgorithm;
}
return antdTheme.defaultAlgorithm;
});
export default defineComponent({ export default defineComponent({
components: {
SiteToken,
},
setup() { setup() {
useSiteToken();
const route = useRoute(); const route = useRoute();
const i18n = useI18n(); const i18n = useI18n();
const colSize = useMediaQuery(); const colSize = useMediaQuery();
const isMobile = computed(() => colSize.value === 'sm' || colSize.value === 'xs'); const isMobile = computed(() => colSize.value === 'sm' || colSize.value === 'xs');
const theme = ref(localStorage.getItem('theme') || 'default'); const theme = ref<ThemeName>((localStorage.getItem('theme') as ThemeName) || 'light');
const themeConfig = computed(() => {
return { algorithm: getAlgorithm([theme.value]) };
});
// useSiteToken();
const responsive = computed(() => { const responsive = computed(() => {
if (colSize.value === 'xs') { if (colSize.value === 'xs') {
return 'crowded'; return 'crowded';
@ -49,7 +70,7 @@ export default defineComponent({
isZhCN: computed(() => i18n.locale.value === 'zh-CN'), isZhCN: computed(() => i18n.locale.value === 'zh-CN'),
blocked: ref(false), blocked: ref(false),
}; };
const changeTheme = (t: string) => { const changeTheme = (t: ThemeName) => {
theme.value = t; theme.value = t;
localStorage.setItem('theme', t); localStorage.setItem('theme', t);
}; };
@ -100,7 +121,7 @@ export default defineComponent({
}, },
{ immediate: true }, { immediate: true },
); );
return { globalConfig, locale }; return { globalConfig, locale, themeConfig };
}, },
}); });
</script> </script>

7
site/src/SiteToken.vue Normal file
View File

@ -0,0 +1,7 @@
<template>
<slot></slot>
</template>
<script lang="ts" setup>
import useSiteToken from './hooks/useSiteToken';
useSiteToken();
</script>

View File

@ -209,7 +209,7 @@ export default defineComponent({
title, title,
}); });
}); });
const theme = computed(() => inject('themeMode', { theme: ref('default') }).theme.value); const theme = computed(() => inject('themeMode', { theme: ref('light') }).theme.value);
return { return {
docHtml, docHtml,
iframeDemo, iframeDemo,

View File

@ -10,11 +10,11 @@ import getValueByPath from '../utils/getValueByPath';
const { darkAlgorithm: defaultDark, compactAlgorithm, defaultAlgorithm } = antTheme; const { darkAlgorithm: defaultDark, compactAlgorithm, defaultAlgorithm } = antTheme;
export type ThemeCode = 'default' | 'dark' | 'compact'; export type ThemeCode = 'light' | 'dark' | 'compact';
export const themeMap: Record<ThemeCode, DerivativeFunc<any, any>> = { export const themeMap: Record<ThemeCode, DerivativeFunc<any, any>> = {
dark: defaultDark, dark: defaultDark,
compact: compactAlgorithm, compact: compactAlgorithm,
default: defaultAlgorithm, light: defaultAlgorithm,
}; };
export type SetThemeState = (theme: Theme, modifiedPath: string[], updated?: boolean) => void; export type SetThemeState = (theme: Theme, modifiedPath: string[], updated?: boolean) => void;

View File

@ -141,10 +141,10 @@ const Previewer = defineComponent({
); );
const shownThemes = ref<string[]>( const shownThemes = ref<string[]>(
showTheme.value && !theme.value ? ['default', 'dark'] : [themes.value[0].key], showTheme.value && !theme.value ? ['light', 'dark'] : [themes.value[0].key],
); );
const enabledThemes = ref<string[]>( const enabledThemes = ref<string[]>(
showTheme.value && !theme.value ? ['default', 'dark'] : [themes.value[0].key], showTheme.value && !theme.value ? ['light', 'dark'] : [themes.value[0].key],
); );
watchEffect(() => { watchEffect(() => {

View File

@ -506,7 +506,7 @@ const MapTokenCollapse = defineComponent({
const grouped: Record<string, string[]> = {}; const grouped: Record<string, string[]> = {};
if (groupFn.value) { if (groupFn.value) {
group.value.mapToken?.forEach(token => { group.value.mapToken?.forEach(token => {
const key = groupFn.value(token) ?? 'default'; const key = groupFn.value(token) ?? 'light';
grouped[key] = [...(grouped[key] ?? []), token]; grouped[key] = [...(grouped[key] ?? []), token];
}); });
} }

View File

@ -54,7 +54,7 @@ const useSiteToken = () => {
--site-text-color-secondary: ${tokenValue.colorTextSecondary}; --site-text-color-secondary: ${tokenValue.colorTextSecondary};
--site-border-color-split: ${tokenValue.colorSplit}; --site-border-color-split: ${tokenValue.colorSplit};
--border-radius-base: ${tokenValue.borderRadius}; --border-radius-base: ${tokenValue.borderRadius};
--font-size-base: ${tokenValue.fontSize}; --font-size-base: ${tokenValue.fontSize}px;
--font-size-max: ${Math.max(tokenValue.fontSize - 1, 12)}px; --font-size-max: ${Math.max(tokenValue.fontSize - 1, 12)}px;
--font-family: ${tokenValue.fontFamily}; --font-family: ${tokenValue.fontFamily};
--code-family: ${tokenValue.codeFamily}; --code-family: ${tokenValue.codeFamily};
@ -81,6 +81,7 @@ const useSiteToken = () => {
--animation-duration-base: ${tokenValue.motionDurationSlow}; --animation-duration-base: ${tokenValue.motionDurationSlow};
--ease-in-out: ${tokenValue.motionEaseInOut}; --ease-in-out: ${tokenValue.motionEaseInOut};
--shadow-1-down: ${tokenValue.boxShadowCard}; --shadow-1-down: ${tokenValue.boxShadowCard};
--box-shadow: ${tokenValue.boxShadow};
} }
`; `;
if (styleDom && !document.body.contains(styleDom)) { if (styleDom && !document.body.contains(styleDom)) {

View File

@ -20,8 +20,6 @@ export default defineComponent({
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@import './index.less';
#logo { #logo {
height: var(--header-height); height: var(--header-height);
padding-left: 40px; padding-left: 40px;

View File

@ -125,8 +125,6 @@ export default defineComponent({
}); });
</script> </script>
<style lang="less"> <style lang="less">
@import './index.less';
#nav { #nav {
height: 100%; height: 100%;
font-size: 14px; font-size: 14px;

View File

@ -5,7 +5,7 @@
z-index: 10; z-index: 10;
max-width: 100%; max-width: 100%;
background: var(--component-background); background: var(--component-background);
box-shadow: 0 2px 8px rgba(240, 241, 242, 65); box-shadow: var(--box-shadow);
.menu-row { .menu-row {
display: flex; display: flex;

View File

@ -17,7 +17,7 @@
<CloseOutlined class="close-icon" @click="visibleAdblockBanner = false" /> <CloseOutlined class="close-icon" @click="visibleAdblockBanner = false" />
</div> </div>
<div v-if="visibleAlertBanner && isZhCN" class="alert-banner"> <div v-if="visibleAlertBanner && isZhCN" class="alert-banner">
Surely Form 1.0 发布快速搭建在线问卷无缝嵌入各种系统限时限量加群记得扫码哦 Surely Form 2.0 发布快速搭建在线问卷无缝嵌入各种系统
<a href="https://form.antdv.com">立即体验</a> <a href="https://form.antdv.com">立即体验</a>
<CloseOutlined class="close-icon" @click="visibleAlertBanner = false" /> <CloseOutlined class="close-icon" @click="visibleAlertBanner = false" />
@ -128,10 +128,10 @@ export default defineComponent({
watch(globalConfig?.blocked, val => { watch(globalConfig?.blocked, val => {
visibleAdblockBanner.value = val; visibleAdblockBanner.value = val;
}); });
const visibleAlertBanner = ref(!localStorage.getItem('surelyform')); const visibleAlertBanner = ref(!localStorage.getItem('surelyform2'));
watch(visibleAlertBanner, () => { watch(visibleAlertBanner, () => {
if (!visibleAlertBanner.value) { if (!visibleAlertBanner.value) {
localStorage.setItem('surelyform', version); localStorage.setItem('surelyform2', version);
} }
}); });
return { return {
@ -162,10 +162,9 @@ export default defineComponent({
line-height: 28px; line-height: 28px;
color: #8590a6; color: #8590a6;
text-align: center; text-align: center;
background-color: #ebebeb; background-color: #141414;
} }
.alert-banner { .alert-banner {
background-color: var(--ant-primary-color);
color: #fff; color: #fff;
padding: 5px; padding: 5px;
} }

View File

@ -139,7 +139,7 @@ export default defineComponent({
}); });
const themeMode = inject('themeMode', { const themeMode = inject('themeMode', {
theme: ref('default'), theme: ref('light'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
changeTheme: (_key: any) => void 0, changeTheme: (_key: any) => void 0,
}); });

View File

@ -1,6 +1,6 @@
export default { export default {
'app.theme.switch.default': 'Default theme', 'app.theme.switch.default': 'Light',
'app.theme.switch.dark': 'Dark theme', 'app.theme.switch.dark': 'Dark',
'app.theme.switch.compact': 'Compact theme', 'app.theme.switch.compact': 'Compact theme',
'app.header.search': 'Search...', 'app.header.search': 'Search...',
'app.header.menu.documentation': 'Docs', 'app.header.menu.documentation': 'Docs',