chore: 文档前添加 创建时间、修改时间、字数统计
This commit is contained in:
78
docs/.vitepress/theme/components/ArticleInfo.vue
Normal file
78
docs/.vitepress/theme/components/ArticleInfo.vue
Normal file
@@ -0,0 +1,78 @@
|
||||
<script setup lang="ts">
|
||||
import { useData } from 'vitepress'
|
||||
import { onMounted, onUpdated, ref } from 'vue';
|
||||
|
||||
const { frontmatter, page } = useData()
|
||||
|
||||
// 动态计算字数
|
||||
const wordCount = ref(0)
|
||||
|
||||
// 获取页面的纯文本内容并计算字数
|
||||
const getWordCount = () => {
|
||||
const content = document.querySelector('main')?.innerText || ''
|
||||
|
||||
// const words = content.replace(/\s+/g, ' ').trim().split(' ')
|
||||
// const words = content.match(/\S/g);
|
||||
// 使用正则匹配所有的字母、数字、中文字符和常见的标点符号
|
||||
// const words = content.match(/[\w\u4e00-\u9fa5]+/g) || []
|
||||
|
||||
// console.log('字数统计', words)
|
||||
// // 计算字数,去除空白符
|
||||
// return words ? words.length : 0;
|
||||
|
||||
// 使用正则表达式分别匹配中文和英文单词
|
||||
const chineseWords = content.match(/[\u4e00-\u9fa5]/g) || [] // 匹配所有中文字符
|
||||
const englishWords = content.match(/[a-zA-Z0-9]+/g) || [] // 匹配所有英文单词
|
||||
|
||||
// 中文字符数
|
||||
const chineseCount = chineseWords.length
|
||||
|
||||
// 英文单词数
|
||||
const englishCount = englishWords.length
|
||||
|
||||
// 输出调试信息
|
||||
// console.log('中文字符数:', chineseCount, chineseWords)
|
||||
// console.log('英文单词数:', englishCount, englishWords)
|
||||
|
||||
return chineseCount + englishCount // 总字数
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
console.log('ArticleInfo.vue onMounted')
|
||||
wordCount.value = getWordCount()
|
||||
})
|
||||
|
||||
onUpdated(() => {
|
||||
console.log('ArticleInfo.vue onMounted')
|
||||
wordCount.value = getWordCount()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="article-info">
|
||||
<p>
|
||||
字数统计:约 {{ wordCount }} 字
|
||||
</p>
|
||||
<p v-if="frontmatter.createTime" class="create-date">
|
||||
创建时间:{{ frontmatter.createTime }}
|
||||
</p>
|
||||
<p v-if="frontmatter.updateTime" class="update-date">
|
||||
最后更新:{{ frontmatter.updateTime }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.article-info {
|
||||
margin-bottom: 2rem;
|
||||
padding: 10px 15px;
|
||||
border-left: 4px solid #42b883;
|
||||
background-color: var(--vp-c-bg-soft);
|
||||
line-height: 1.8em;
|
||||
|
||||
font-size: small;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, 180px);
|
||||
}
|
||||
</style>
|
@@ -4,12 +4,14 @@ import type { Theme } from 'vitepress'
|
||||
import DefaultTheme from 'vitepress/theme'
|
||||
import './style.css'
|
||||
import './custom.css'
|
||||
import ArticleInfo from './components/ArticleInfo.vue'
|
||||
|
||||
export default {
|
||||
extends: DefaultTheme,
|
||||
Layout: () => {
|
||||
return h(DefaultTheme.Layout, null, {
|
||||
// https://vitepress.dev/guide/extending-default-theme#layout-slots
|
||||
'doc-before': () => h(ArticleInfo),
|
||||
})
|
||||
},
|
||||
enhanceApp({ app, router, siteData }) {
|
||||
|
@@ -1,3 +1,8 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# MySQL 8.x 数据库安装配置 (Ubuntu 系统)
|
||||
|
||||
待完善
|
||||
|
@@ -1,3 +1,8 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# MySQL 8.x 数据库安装配置 (Windows 系统)
|
||||
|
||||
待完善
|
||||
|
@@ -1,3 +1,8 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# redis 安装配置 (Ubuntu 系统)
|
||||
|
||||
待完善
|
||||
|
@@ -1,3 +1,8 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# redis 安装配置 (Windows 系统)
|
||||
|
||||
> redis 官方不提供 Windows 版本安装包,以下教程中所使用的安装来自开源社区
|
||||
|
@@ -0,0 +1,8 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# 配置 Java OpenJDK 17 (Ubuntu 系统)
|
||||
|
||||
待完善
|
@@ -1,3 +1,8 @@
|
||||
---
|
||||
# createTime: '2025-02-21'
|
||||
# updateTime: ''
|
||||
---
|
||||
|
||||
# How to ... ? 如何做系列教程
|
||||
|
||||
请在左侧选择教程。
|
||||
@@ -5,6 +10,6 @@
|
||||
<contents :sidebar-item="sidebar['/how-to/']" />
|
||||
|
||||
<script setup>
|
||||
import contents from '/components/contents.vue'
|
||||
import { sidebar } from '/sidebar.mts';
|
||||
import contents from '../components/contents.vue'
|
||||
import { sidebar } from '../sidebar.mts';
|
||||
</script>
|
||||
|
@@ -1,3 +1,8 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# Node.js & npm 安装配置 (Ubuntu 系统)
|
||||
|
||||
待完善
|
||||
|
@@ -1,3 +1,8 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# Node.js & npm 安装配置 (Windows 系统)
|
||||
|
||||
> redis 官方不提供 Windows 版本安装包,以下教程中所使用的安装来自开源社区
|
||||
|
22
docs/how-to/system/linux/intro.md
Normal file
22
docs/how-to/system/linux/intro.md
Normal file
@@ -0,0 +1,22 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# Linux 介绍
|
||||
|
||||
待完善
|
||||
|
||||
## 常见发行版
|
||||
|
||||
### Ubuntu
|
||||
|
||||
待完善
|
||||
|
||||
### CentOS
|
||||
|
||||
待完善
|
||||
|
||||
### and more ...
|
||||
|
||||
待完善
|
@@ -0,0 +1,14 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# 配置 Ubuntu Server 24.04 LTS 网络信息
|
||||
|
||||
待完善
|
||||
|
||||
DHCP
|
||||
|
||||
静态IP (固定IP)
|
||||
|
||||
WiFi 配置
|
@@ -1,3 +1,8 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# 安装 Ubuntu 24.04 Desktop 操作系统
|
||||
|
||||
待完善
|
@@ -1,3 +1,8 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
||||
# 安装 Ubuntu 24.04 Server 操作系统
|
||||
|
||||
待完善
|
5
docs/how-to/system/macos/install-macos.md
Normal file
5
docs/how-to/system/macos/install-macos.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
5
docs/how-to/system/windows/install-windows-server.md
Normal file
5
docs/how-to/system/windows/install-windows-server.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
5
docs/how-to/system/windows/install-windows.md
Normal file
5
docs/how-to/system/windows/install-windows.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
createTime: '2025-02-21'
|
||||
updateTime: ''
|
||||
---
|
||||
|
@@ -36,14 +36,30 @@ export const sidebar: DefaultTheme.Sidebar = {
|
||||
items: [
|
||||
{
|
||||
text: `${serial('linux')}安装操作系统`,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: `${serial('linux.system')}Ubuntu 24.04 Desktop 安装`,
|
||||
link: 'system/linux/install-ubuntu-desktop',
|
||||
text: `${serial('linux.system')}Linux 发行版简介`,
|
||||
link: 'system/linux/intro',
|
||||
},
|
||||
{
|
||||
text: `${serial('linux.system')}Ubuntu 24.04 Server 安装`,
|
||||
link: 'system/linux/install-ubuntu-server',
|
||||
text: `${serial('linux.system')}Ubuntu Desktop 24.04 安装配置`,
|
||||
link: 'system/linux/ubuntu/install-ubuntu-desktop',
|
||||
},
|
||||
{
|
||||
text: `${serial('linux.system')}Ubuntu Server 24.04 安装配置`,
|
||||
// link: 'system/linux/install-ubuntu-desktop',
|
||||
collapsed: true,
|
||||
items: [
|
||||
{
|
||||
text: `${serial('linux.system.ubuntu_server')}安装`,
|
||||
link: 'system/linux/ubuntu/install-ubuntu-server',
|
||||
},
|
||||
{
|
||||
text: `${serial('linux.system.ubuntu_server')}网络配置`,
|
||||
// link: 'system/linux/install-ubuntu-desktop',
|
||||
},
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
@@ -73,8 +89,8 @@ export const sidebar: DefaultTheme.Sidebar = {
|
||||
text: `${serial('linux')}安装开发工具`,
|
||||
items: [
|
||||
{
|
||||
text: `${serial('linux.develop')}MySQL 8.x 安装 & 配置 (Ubuntu)`,
|
||||
link: 'database/mysql/install-on-ubuntu',
|
||||
text: `${serial('linux.develop')}Java OpenJDK 17 安装 & 配置 (Ubuntu)`,
|
||||
link: 'environment/java/configure-openjdk-on-ubuntu',
|
||||
},
|
||||
]
|
||||
},
|
||||
|
Reference in New Issue
Block a user