Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(site): refactor the implementation mode of switch dark theme #2995

Merged
merged 5 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/sites/src/assets/custom-markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,26 @@ body .markdown-body {
--color-attention-subtle: #fff8c5;
--color-danger-fg: #cf222e;
}
.markdown-body code {
text-shadow: none !important;
}

.dark.dark .markdown-body {
background-color: #000;
}

.dark.dark .markdown-body pre {
background-color: #1a1a1a;
}

.dark.dark .markdown-body code {
color: var(--tv-color-text);

.token.operator {
background-color: transparent;
}

.hljs-string {
color: #6f42c1;
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 0 additions & 24 deletions examples/sites/src/assets/markdown.less

This file was deleted.

3 changes: 1 addition & 2 deletions examples/sites/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'prismjs/themes/prism.css'
import 'uno.css'

// highlight默认样式
import 'highlight.js/styles/default.css'
// import 'highlight.js/styles/default.css'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这行代码注释的原因是什么,如果没有了就直接删除

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已删除


// 只使用markdown的亮色主题
import 'github-markdown-css/github-markdown.css'
Expand All @@ -17,7 +17,6 @@ import './style.css'
// 覆盖默认的github markdown样式
import './assets/custom-markdown.css'
import './assets/custom-block.less'
import './assets/markdown.less'
import './assets/md-preview.less'

import { i18n } from './i18n/index'
Expand Down
15 changes: 11 additions & 4 deletions examples/sites/src/views/components-doc/components/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,6 @@ onBeforeUnmount(() => {
}
}

:global(.dark .pc-demo-container.pc-demo-container) {
background-color: #1a1a1a;
border: none;
}
.pc-demo-container {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -400,3 +396,14 @@ onBeforeUnmount(() => {
padding: 20px 5px;
}
</style>

<style lang="less">
.dark .pc-demo-container.pc-demo-container {
background-color: #1a1a1a;
border: none;
}

.dark .demo-content.demo-content .demo-desc {
color: #b3b3b3;
}
</style>
17 changes: 0 additions & 17 deletions examples/sites/src/views/docs/docs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,6 @@ onMounted(() => {
}
}

.dark .docs-container .markdown-body {
background-color: #000;
}

.dark .docs-container .markdown-body pre {
background-color: #1a1a1a;
}

.dark .docs-container .markdown-body code {
text-shadow: none;
color: var(--tv-color-text);

.token.operator {
background-color: transparent;
}
}

.docs-page-anchor {
.tiny-anchor__affix {
overflow-y: auto;
Expand Down
8 changes: 0 additions & 8 deletions examples/sites/src/views/layout/layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<div class="main-layout ti-hp100 ti-f-c ti-f-box-stretch">
<div class="content-layout ti-fi-1" :has-sider="!isFrame">
<div id="layoutSider" class="layout-sider" :class="{ 'saas-border': templateModeState.isSaas }" v-if="!isFrame">
<div style="padding: 10px 0; text-align: center">
<tiny-button :reset-time="0" type="info" @click="toggleDark()">{{ isDark ? 'dark' : 'light' }}</tiny-button>
</div>
<tiny-tree-menu

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

移除了切换主题按钮的代码,这意味着用户将无法通过UI切换主题。确保这是预期的行为,并且在文档中有说明如何手动切换主题。

ref="treeMenuRef"
class="main-menu"
Expand Down Expand Up @@ -68,7 +65,6 @@ import { getWord, i18nByKey, appData, appFn, useApiMode, useTemplateMode } from
import useTheme from '@/tools/useTheme'
import FloatSettings from '@/views/components-doc/components/float-settings.vue'
import VersionTip from '@/views/components-doc/components/version-tip.vue'
import { useDark, useToggle } from '@vueuse/core'

export default defineComponent({
name: 'LayoutVue',
Expand Down Expand Up @@ -107,8 +103,6 @@ export default defineComponent({
const getTo = (route, key) => `${import.meta.env.VITE_CONTEXT}${allPath}${lang}/${theme}/${route}${key}`

const isThemeSaas = import.meta.env.VITE_TINY_THEME === 'saas'
const isDark = useDark()
const toggleDark = useToggle(isDark)

const changeLanguage = () => {
appFn.toggleLang()
Expand Down Expand Up @@ -197,8 +191,6 @@ export default defineComponent({
getWord,
i18nByKey,
isThemeSaas,
isDark,
toggleDark,
isShowFilter
}
}
Expand Down
Loading