Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
zds-s committed Oct 21, 2024
2 parents d51106e + 7e51c6e commit 8356528
Show file tree
Hide file tree
Showing 26 changed files with 1,173 additions and 49 deletions.
8 changes: 4 additions & 4 deletions .vitepress/src/zh/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,19 @@ const sidebar:DefaultTheme.Sidebar = {
},
{
text: '插件',
link: '/zh/front/advanced/plugin'
link: '/zh/front/high/plugin'
},
{
text: 'Hooks',
link: '/zh/front/advanced/hooks'
link: '/zh/front/high/hooks'
},
{
text: '常用Store',
link: '/zh/front/advanced/store'
link: '/zh/front/high/store'
},
{
text: 'JSX和TSX开发',
link: '/zh/front/advanced/jsx'
link: '/zh/front/high/tsx'
}
],
},
Expand Down
21 changes: 20 additions & 1 deletion .vitepress/theme/components/layout.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
<script setup lang="ts" >
import { computed, nextTick, onBeforeUnmount, onMounted, ref, watch, getCurrentInstance } from 'vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import DefaultTheme from 'vitepress/theme'
import { ElConfigProvider } from 'element-plus'
import {useData, useRoute} from "vitepress";
import giscusTalk from "vitepress-plugin-comment-with-giscus";
const { Layout } = DefaultTheme;
const { frontmatter }: any = useData();
const route = useRoute();
// giscus配置
giscusTalk({
repo: 'mineadmin/mineadmin', //仓库
repoId: 'MDEwOlJlcG9zaXRvcnk0MjQ2MDA5', //仓库ID
category: 'Q&A', // 讨论分类
categoryId: 'DIC_kwDOAEDJ-c4CR7vK', //讨论分类ID
mapping: 'pathname',
inputPosition: 'bottom',
lang: 'zh-CN',
},
{
frontmatter, route
},
true
);
</script>

<template>
Expand Down
28 changes: 7 additions & 21 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/dark/css-vars.css'

// @ts-ignore
import Layout from './components/layout.vue'

import zh from 'element-plus/dist/locale/zh-cn.mjs'
Expand All @@ -24,8 +25,6 @@ import MaTable from '@mineadmin/table/dist/index.umd.js'
import MaSearch from '@mineadmin/search/dist/index.umd.js'
import MaForm from '@mineadmin/form/dist/index.umd.js'
import MaProTable from '@mineadmin/pro-table/dist/index.umd.js'
import giscusTalk from 'vitepress-plugin-comment-with-giscus';
import { useData, useRoute } from 'vitepress';

// maTable样式
import '@mineadmin/table/dist/style.css'
Expand All @@ -36,28 +35,14 @@ import '@mineadmin/pro-table/dist/style.css'
// ContextMenu 样式
import '@imengyu/vue3-context-menu/lib/vue3-context-menu.css'

import './styles/var.css'
import {baiduPlugin} from "./plugin/baidu";

export default {
setup(){
const { frontmatter } = useData();
const route = useRoute();
// giscus配置
giscusTalk({
repo: 'mineadmin/mineadmin', //仓库
repoId: 'MDEwOlJlcG9zaXRvcnk0MjQ2MDA5', //仓库ID
category: 'Q&A', // 讨论分类
categoryId: 'DIC_kwDOAEDJ-c4CR7vK', //讨论分类ID
mapping: 'pathname',
inputPosition: 'bottom',
lang: 'zh-CN',
},
{
frontmatter, route
},
true
);
},
enhanceApp(ctx: EnhanceAppContext) {

const { app } = ctx;
// @ts-ignore
app.use(ElementPlus, { locale: zh })
app.use(MaTable, { ssr: true })
app.use(MaSearch, { ssr: true })
Expand All @@ -70,6 +55,7 @@ export default {
},
app,
})
baiduPlugin()
},
extends: DefaultTheme,
Layout,
Expand Down
29 changes: 29 additions & 0 deletions .vitepress/theme/plugin/baidu.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { inBrowser } from 'vitepress';

const SITE = '3d22d14b100ebeac51fd547b478cd26a';

declare global {
interface Window {
_hmt: any;
}
}

function registerAnalytics() {
window._hmt = window._hmt || [];
const script = document.createElement('script');
script.innerHTML = `var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?${SITE}";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})()`;
document.querySelector('head')?.append(script);
}

export function baiduPlugin() {
// @ts-ignore
if (inBrowser && import.meta.env.PROD) {
registerAnalytics();
}
}
Loading

0 comments on commit 8356528

Please sign in to comment.