1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-02-02 18:20:26 +08:00

feat: 依赖升级,工程化定期改造 (#146)

This commit is contained in:
142vip.cn
2025-05-12 14:43:20 +08:00
committed by GitHub
parent f1a947458d
commit 237b3abded
29 changed files with 3563 additions and 3607 deletions

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -36,6 +36,6 @@
(getOptions || markmap.deriveOptions)(jsonOptions),
root2
);
})(() => window.markmap,null,{"content":"计算机网络","children":[{"content":"体系结构","children":[],"payload":{"tag":"h2","lines":"20,21"}},{"content":"物理层","children":[],"payload":{"tag":"h2","lines":"22,23"}},{"content":"数据链路层","children":[],"payload":{"tag":"h2","lines":"24,25"}},{"content":"网络层","children":[],"payload":{"tag":"h2","lines":"26,27"}},{"content":"传输层","children":[],"payload":{"tag":"h2","lines":"28,29"}},{"content":"应用层","children":[],"payload":{"tag":"h2","lines":"30,31"}},{"content":"一些总结","children":[],"payload":{"tag":"h2","lines":"32,33"}}],"payload":{"tag":"h1","lines":"6,7"}},null)</script>
})(() => window.markmap,null,{"content":"计算机网络","children":[{"content":"<pre data-lines=\"8,32\"><code class=\"language-mindmap\">root(计算机网络)\n (体系机构)\n (物理层)\n (数据链路层)\n (网络层)\n (传输层)\n (应用层)\n\n&lt;a href=\"../../mind-map/cn-map.html\" target=\"_blank\"&gt;在线预览&lt;/a&gt;\n\n## 体系结构\n\n## 物理层\n\n## 数据链路层\n\n## 网络层\n\n## 传输层\n\n## 应用层\n\n## 一些总结\n</code></pre>","children":[],"payload":{"tag":"pre","lines":"8,32"}}],"payload":{"tag":"h1","lines":"6,7"}},null)</script>
</body>
</html>

View File

@@ -1,7 +1,7 @@
---
title: 变更记录
permalink: /changelog.html
headerDepth: 1
levels: 1
sidebar: false
---

View File

@@ -56,7 +56,6 @@ typedef struct{
`InitStack(&S)`: 初始化一个空栈`S`,栈顶指针初始化为-1
```cpp
void InitStack(&S){
// 栈顶指针-1
s.top=-1;
@@ -69,7 +68,6 @@ void InitStack(&S){
`StackEmpty(S)`: 判断一个栈是否为空,即:栈顶指针是否为-1如果栈空则返回`true`,否则返回`false`
```cpp
bool StackEmpty(S){
if(S.top==-1){
// 栈空
@@ -87,7 +85,6 @@ bool StackEmpty(S){
`Push(&S,x)`: 进栈,若栈未满,`x`进栈操作,插入到栈内成为`新的栈顶元素`
```cpp
bool Push(SqStack &S,ElemType x){
if(S.top==MaxSize-1){
// 栈满返回false元素无法进行进栈操作
@@ -113,7 +110,6 @@ bool Push(SqStack &S,ElemType x){
`Pop(&S,&x)`: 出栈,若栈非空,出栈操作,**弹出栈顶元素**,用指针`x`进行返回。
```cpp
bool Pop(SqStack &S,ElemType &x){
if(S.top==-1){
// 栈空无栈顶元素可出栈返回false
@@ -139,7 +135,6 @@ bool Pop(SqStack &S,ElemType &x){
`GetTop(S,&x)`: 读栈顶元素,若栈`S`非空用x返回栈顶元素。
```cpp
bool GetTop(SqStack S,ElemType &x){
if(S.top==-1){

View File

@@ -23,7 +23,6 @@ head:
栈的链式存储类型:
```cpp
// 链栈类型定义【基础】
typedef struct LinkNode{
ElemType data; // 栈元素结点数据域
@@ -59,7 +58,6 @@ typedef struct LinkStack
- 如果链栈存在,进行单链表的结点插入操作,移动指针,结点元素赋值,再将结点压入链栈中,移动链栈栈顶指针,最后链栈元素总数+1返回true
```cpp
/*
* @Description: 基于单链表链栈的进栈操作
* @Version: Beta1.0
@@ -96,7 +94,6 @@ bool linkStackPushNode(LinkStack* linkStack,int e){
- 如果链栈满足出栈条件则通过栈顶指针获取到链栈栈底结点将其数据域赋值给变量e移动栈顶指针指向待出栈元素的后继结点同时释放待出栈元素的内存空间链栈元素总数-1 出栈成功返回true.
```cpp
/*
* @Description: 基于单链表链栈的出栈操作
* @Version: Beta1.0

View File

@@ -247,7 +247,6 @@ bool EnLoopQueue(SqQueue &Q, ElemType x){
### 出队操作
```cpp
/*
* @Description: 循环队列元素出队
* @Version: Beta1.0

View File

@@ -70,7 +70,6 @@ typedef struct{
### 队列初始化
```cpp
/*
* @Description: 链式队列初始化
* @Version: Beta1.0
@@ -96,7 +95,6 @@ voide InitLinkQueue(LinkQueue &Q){
### 判断队空
```cpp
/*
* @Description: 判断链式队列是否为空
* @Version: Beta1.0
@@ -148,7 +146,6 @@ void EnLinkQueue(LinkQueue &Q, ElemType x){
### 出队
```cpp
/*
* @Description: 链式队列出队操作
* @Version: Beta1.0

View File

@@ -38,7 +38,6 @@ root(栈VS队列补充)
经典的斐波拉切数列,可以用递归来实现:
```cpp
// 定义递归函数,实现斐波拉切数列
int Fibonacci(n){
@@ -57,7 +56,6 @@ int Fibonacci(n){
上面很基础的代码,是分`n=0``n=1`的情况,先进行过滤,其他情况下则进行递归,其实在日常开发中,经常会有简化的函数封装
```cpp
// 定义递归函数,实现斐波拉切数列
int Fibonacci(n){

View File

@@ -85,7 +85,6 @@ L.data=new ElemType[InitSize];
注意:先判空和临界值,提高算法健壮性
```cpp
/*
* @Description: 顺序表的插入操作
* @Version: Beta1.0
@@ -147,7 +146,6 @@ bool ListInsert(SqList &L, int i, ElemType e){
- 失败返回false
```cpp
/*
* @Description: 顺序表的删除操作
* @Version: Beta1.0

View File

@@ -48,7 +48,6 @@ root(单链表)
单链表中结点类型的描述:
```cpp
// 单链表结点类型定义
typeof struct LNode{
ElemType data; // 数据域
@@ -135,7 +134,6 @@ LinkList CreateListWithStartNode(LinkList &L){
> 新结点插入到当前链表的表尾上必须增加一个尾指针r,始终指向当前链表的尾结点;
```cpp
/*
* @Description: 单链表尾插法创建
* @Version: Beta1.0
@@ -190,7 +188,6 @@ LinkList CreateListWithEndNode(LinkList &L){
> 在单链表中从第一个结点出发顺指针next域逐个往下搜索、遍历直到找出第i个结点为止否则返回最后一个结点指针域NULL
```cpp
/*
* @Description: 单链表按序号查找
* @Version: Beta1.0
@@ -305,7 +302,6 @@ LNode *LocateElem(LinkList L,ElemType e){
> 在某结点的后面插入一个新的结点,单链表插入算法中,通常采用后插操作的
```cpp
// 结点s插入到结点p的前面修改指针域顺序不能改变
s->next=p->next;
p->next=s;
@@ -328,7 +324,6 @@ s->data=temp;
- 第三步: 移动指针,删除结点元素;
```cpp
// 获取删除位置结点元素的前驱结点
p=GetElem(L,i-1);
@@ -440,7 +435,6 @@ typedef struct DNode{
> 在双链表中p所指的结点之后插入结点s
```cpp
// 第一步
s->next=p->next;
@@ -462,7 +456,6 @@ p->next=s
> 删除双链表中结点p的后继结点q
```cpp
// 第一步
p->next=q->next;
@@ -553,7 +546,6 @@ typedef struct DNode{
静态链表结构类型:
```cpp
// 定义静态链表的最大长度
# define MaxSize 50

View File

@@ -1,7 +1,7 @@
---
title: 计算机组成原理
permalink: /mark-map/ccp-map.html
headerDepth: 3
levels: 3
---
# 计算机组成原理

View File

@@ -1,7 +1,7 @@
---
title: 计算机网络
permalink: /mark-map/cn-map.html
headerDepth: 3
levels: 3
---
# 计算机网络
@@ -14,7 +14,6 @@ root(计算机网络)
(网络层)
(传输层)
(应用层)
```
<a href="../../mind-map/cn-map.html" target="_blank">在线预览</a>

View File

@@ -1,7 +1,7 @@
---
title: 数据结构
permalink: /mark-map/ds-map.html
headerDepth: 3
levels: 3
---
# 数据结构

View File

@@ -1,7 +1,7 @@
---
title: 操作系统
permalink: /mark-map/os-map.html
headerDepth: 3
levels: 3
---
# 操作系统

View File

@@ -1,7 +1,7 @@
---
title: 快速开始
permalink: /quick-start.html
headerDepth: 2
levels: 2
sidebar: false
---

View File

@@ -1,11 +1,11 @@
const fs = require('node:fs')
const { VipNodeJS } = require('@142vip/utils')
/**
* 根据sideBar来快速初始化目录文档
*
*/
const fs = require('node:fs')
const path = require('node:path')
const sideBarData = {
text: '查找',
prefix: '查找',
@@ -44,8 +44,8 @@ const { prefix, children } = sideBarData;
/**
* 第一步: 创建目录
*/
const dir = path.join(__dirname, prefix)
const isExist = fs.existsSync(dir)
const dir = VipNodeJS.pathJoin(__dirname, prefix)
const isExist = VipNodeJS.existPath(dir)
if (!isExist) {
await fs.mkdirSync(dir)
@@ -56,10 +56,11 @@ const { prefix, children } = sideBarData;
*/
for (const { text, link } of children) {
const filePath = path.join(dir, link)
const isExistFile = fs.existsSync(filePath)
const filePath = VipNodeJS.pathJoin(dir, link)
const isExistFile = VipNodeJS.existPath(filePath)
// 创建
if (!isExistFile) {
await fs.writeFileSync(filePath, `# ${text} \n\n努力赶稿中,等等我呀...`)
await VipNodeJS.writeFileByUTF8(filePath, `# ${text} \n\n努力赶稿中,等等我呀...`)
}
}
})()

View File

@@ -1,5 +1,4 @@
import { markdownImagePlugin } from '@vuepress/plugin-markdown-image'
import { hopeTheme, navbar, sidebar } from 'vuepress-theme-hope'
import { defineVipNavbarConfig, defineVipSidebarConfig } from '@142vip/vuepress'
import { cppSidebar } from './ccp/cpp.sidebar'
import { cnSidebar } from './cn/cn.sidebar'
import { dsSidebar } from './ds/ds.sidebar'
@@ -7,9 +6,9 @@ import { MarkMapSidebar } from './mark-map/mark-map.sidebar'
import { osSidebar } from './os/os.sidebar'
/**
* 导航栏配置
* 导航栏
*/
export const navbarConfig = navbar([
export const navbarConfig = defineVipNavbarConfig([
{ text: '🌐 首页', link: '/' },
{ text: '📙 数据结构', link: '/ds/' },
{ text: '📕 操作系统', link: '/os/' },
@@ -39,9 +38,9 @@ export const navbarConfig = navbar([
])
/**
* 侧边导航栏设置
* 侧边
*/
export const sidebarConfig = sidebar({
export const sidebarConfig = defineVipSidebarConfig({
'/ds': dsSidebar,
'/os': osSidebar,
'/ccp': cppSidebar,
@@ -51,152 +50,153 @@ export const sidebarConfig = sidebar({
/**
* hope主题配置
* - 备份
* 参考https://theme-hope.vuejs.press/zh/config/
*/
export const themeConfig = {
theme: hopeTheme({
// locales: langConfig,
// locales: i18n,
// 在深色模式和浅色模式之间切换
darkmode: 'toggle',
// 支持全屏
// fullscreen: true,
// 纯净模式
// pure: true,
print: false, // 打印按钮
hostname: 'https://408.142vip.cn',
// author: AUTHOR_INFO,
favicon: '/408_favicon.ico',
logo: '/408_logo.png',
logoDark: '/408_logo.png',
navbar: navbarConfig,
// 导航栏布局
navbarLayout: {
start: ['Brand'],
center: ['Links'],
end: ['Language', 'Outlook', 'Repo', 'Search'],
},
sidebar: sidebarConfig,
// 主题布局选项
repo: 'https://github.com/142vip/408CSFamily',
// 博客配置
// blog: {
// name: '凡是过往',
// avatar: '',
// description: '',
// intro: '',
// roundAvatar: true,
// timeline: "时间轴的顶部文字",
// // articleInfo:"",
// // sidebarDisplay:"always",
// medias: {
// "BiliBili": "https://space.bilibili.com/350937042?spm_id_from=333.1007.0.0"
// }
// },
// 设置页脚
displayFooter: true,
// footer: FOOTER_HTML_INFO,
// copyright: false,
// copyright,
// 主题色选择器
themeColor: true,
// 是否显示外部链接图标
externalLinkIcon: false,
plugins: {
readingTime: {
wordPerMinute: 100,
},
copyright: false,
// 开启博客功能
blog: false,
// 图片增强参考https://ecosystem.vuejs.press/zh/plugins/markdown/markdown-image.html
markdownImage: markdownImagePlugin({
// 启用 figure
figure: true,
// 启用图片懒加载
lazyload: true,
// 启用图片标记
mark: true,
// 启用图片大小
size: true,
}),
// 代码块
mdEnhance: {
// codetabs: true,
tasklist: true, // 支持任务列表
playground: {
presets: ['ts', 'vue'],
},
// 是否启用幻灯片
// revealjs: ['highlight', 'math', 'search', 'notes', 'zoom'],
stylize: [
{
matcher: 'Recommended',
replacer: ({ tag }) => {
if (tag === 'em') {
return {
tag: 'Badge',
attrs: { type: 'tip' },
content: 'Recommended',
}
}
},
},
],
sub: true,
sup: true,
// tabs: true,
vPre: true,
vuePlayground: true,
// 文件导入
include: true,
// mermaid
mermaid: true,
// 自定义对齐
align: true,
},
// 不自动生成README目录
catalog: false,
// 参考https://theme-hope.vuejs.press/zh/guide/markdown/components.html
components: {
components: [
'Badge',
'BiliBili',
'CodePen',
'PDF',
'StackBlitz',
'VidStack',
'Share',
'XiGua',
],
},
// searchPro: {
// // 参考https://plugin-search-pro.vuejs.press/zh/config.html#locales
// locales: {
// '/': searchProCNLocals,
// },
// },
// 参考https://theme-hope.vuejs.press/zh/config/plugins/others.html#markdowntab
markdownTab: true,
nprogress: true,
// 代码高亮https://theme-hope.vuejs.press/zh/guide/feature/code-block.html
shiki: {
langs: ['ts', 'js', 'json', 'vue', 'json5', 'bash', 'diff', 'c', 'c++', 'dockerfile', 'nginx', 'proto', 'java', 'javascript', 'typescript'],
// 你想要使用的主题
themes: {
light: 'one-light',
dark: 'one-dark-pro',
},
},
copyCode: {
showInMobile: true,
},
feed: {
json: true,
},
},
}),
}
// export const themeConfig = {
// theme: hopeTheme({
// // locales: langConfig,
// // locales: i18n,
// // 在深色模式和浅色模式之间切换
// darkmode: 'toggle',
// // 支持全屏
// // fullscreen: true,
// // 纯净模式
// // pure: true,
// print: false, // 打印按钮
// hostname: 'https://408.142vip.cn',
// // author: AUTHOR_INFO,
// favicon: '/408_favicon.ico',
// logo: '/408_logo.png',
// logoDark: '/408_logo.png',
// navbar: navbarConfig,
// // 导航栏布局
// navbarLayout: {
// start: ['Brand'],
// center: ['Links'],
// end: ['Language', 'Outlook', 'Repo', 'Search'],
// },
// sidebar: sidebarConfig,
//
// // 主题布局选项
// repo: 'https://github.com/142vip/408CSFamily',
//
// // 博客配置
// // blog: {
// // name: '凡是过往',
// // avatar: '',
// // description: '',
// // intro: '',
// // roundAvatar: true,
// // timeline: "时间轴的顶部文字",
// // // articleInfo:"",
// // // sidebarDisplay:"always",
// // medias: {
// // "BiliBili": "https://space.bilibili.com/350937042?spm_id_from=333.1007.0.0"
// // }
// // },
// // 设置页脚
// displayFooter: true,
// // footer: FOOTER_HTML_INFO,
// // copyright: false,
// // copyright,
// // 主题色选择器
// themeColor: true,
// // 是否显示外部链接图标
// externalLinkIcon: false,
//
// plugins: {
// readingTime: {
// wordPerMinute: 100,
// },
// copyright: false,
// // 开启博客功能
// blog: false,
// // 图片增强参考https://ecosystem.vuejs.press/zh/plugins/markdown/markdown-image.html
// markdownImage: markdownImagePlugin({
// // 启用 figure
// figure: true,
// // 启用图片懒加载
// lazyload: true,
// // 启用图片标记
// mark: true,
// // 启用图片大小
// size: true,
// }),
// // 代码块
// mdEnhance: {
// // codetabs: true,
// tasklist: true, // 支持任务列表
// playground: {
// presets: ['ts', 'vue'],
// },
// // 是否启用幻灯片
// // revealjs: ['highlight', 'math', 'search', 'notes', 'zoom'],
// stylize: [
// {
// matcher: 'Recommended',
// replacer: ({ tag }) => {
// if (tag === 'em') {
// return {
// tag: 'Badge',
// attrs: { type: 'tip' },
// content: 'Recommended',
// }
// }
// },
// },
// ],
// sub: true,
// sup: true,
// // tabs: true,
// vPre: true,
// vuePlayground: true,
// // 文件导入
// include: true,
// // mermaid
// mermaid: true,
// // 自定义对齐
// align: true,
// },
// // 不自动生成README目录
// catalog: false,
// // 参考https://theme-hope.vuejs.press/zh/guide/markdown/components.html
// components: {
// components: [
// 'Badge',
// 'BiliBili',
// 'CodePen',
// 'PDF',
// 'StackBlitz',
// 'VidStack',
// 'Share',
// 'XiGua',
// ],
// },
// // searchPro: {
// // // 参考https://plugin-search-pro.vuejs.press/zh/config.html#locales
// // locales: {
// // '/': searchProCNLocals,
// // },
// // },
// // 参考https://theme-hope.vuejs.press/zh/config/plugins/others.html#markdowntab
// markdownTab: true,
// nprogress: true,
// // 代码高亮https://theme-hope.vuejs.press/zh/guide/feature/code-block.html
// shiki: {
// langs: ['ts', 'js', 'json', 'vue', 'json5', 'bash', 'diff', 'c', 'c++', 'dockerfile', 'nginx', 'proto', 'java', 'javascript', 'typescript'],
// // 你想要使用的主题
// themes: {
// light: 'one-light',
// dark: 'one-dark-pro',
// },
// },
// copyCode: {
// showInMobile: true,
// },
// feed: {
// json: true,
// },
// },
// }),
// }

View File

@@ -4,6 +4,5 @@ export default defineVipEslintConfig({
ignores: [
'**/CHANGELOG.md',
],
rules: {
},
rules: {},
})

View File

@@ -25,19 +25,20 @@
"dev": "pnpm build:mark-map && npx vuepress dev docs",
"build": "npx vuepress build docs --clean-temp --clean-cache",
"build:proxy": "NEED_PROXY=true npx vuepress build docs --clean-temp --clean-cache",
"build:mark-map": "./scripts/mark-map",
"release": "npx fa release --vip"
"build:mark-map": "npx node --loader ts-node/esm --no-warnings scripts/core/mark-map.ts",
"release": "npx fa release --vip --check-branch next --check-branch main"
},
"devDependencies": {
"@142vip/eslint-config": "0.0.1-alpha.3",
"@142vip/fairy-cli": "0.0.3-alpha.20",
"@142vip/utils": "0.0.1-alpha.28",
"@142vip/vuepress": "0.0.1-alpha.11",
"@vuepress/bundler-vite": "2.0.0-rc.20",
"@142vip/eslint-config": "0.0.1-alpha.4",
"@142vip/fairy-cli": "0.0.3-alpha.24",
"@142vip/utils": "0.0.1-alpha.36",
"@142vip/vuepress": "0.0.1-alpha.14",
"@vuepress/plugin-watermark": "2.0.0-rc.27",
"markmap-cli": "0.18.9",
"mermaid": "11.6.0",
"only-allow": "1.2.1",
"simple-git-hooks": "2.11.1",
"vuepress": "2.0.0-rc.20",
"ts-node": "10.9.2",
"xmind-embed-viewer": "1.2.0"
},
"simple-git-hooks": {

6427
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

3
scripts/build-image Executable file
View File

@@ -0,0 +1,3 @@
#!/bin/bash
npx node --loader ts-node/esm --no-warnings scripts/core/build-image.ts

View File

@@ -1,9 +1,10 @@
#!/bin/bash
##
## 依赖安装脚本
## 使用:
## ./scripts/ci
##
#
# 依赖安装脚本
# 使用:
# ./scripts/ci
#
NPM_REGISTRY="https://mirrors.tencent.com/npm/"
@@ -11,7 +12,7 @@ NPM_REGISTRY="https://mirrors.tencent.com/npm/"
echo "运行命令: export COREPACK_NPM_REGISTRY=$NPM_REGISTRY && corepack enable pnpm && pnpm i --registry $NPM_REGISTRY --frozen-lockfile $*"
# 导出corepack环境变量安装pnpm版本
export COREPACK_NPM_REGISTRY=$NPM_REGISTRY COREPACK_INTEGRITY_KEYS=0 && corepack enable pnpm
export COREPACK_NPM_REGISTRY=$NPM_REGISTRY COREPACK_INTEGRITY_KEYS=0 && corepack enable pnpm
# 安装项目依赖 -w -F @142vip/fairy-cli
# 安装项目依赖
pnpm i --registry $NPM_REGISTRY --frozen-lockfile "$@"

36
scripts/bundle → scripts/core/build-image.ts Executable file → Normal file
View File

@@ -1,27 +1,15 @@
#!/usr/bin/env node
import { OPEN_SOURCE_ADDRESS, OPEN_SOURCE_AUTHOR, VipDocker, VipGit, VipNodeJS, VipPackageJSON } from '@142vip/utils'
/**
* Docker镜像
* 使
* - ./scripts/bundle
* - ./scripts/bundle --proxy
*/
import { createRequire } from 'node:module'
import {
OPEN_SOURCE_ADDRESS,
VipDocker,
VipGit,
VipNodeJS,
} from '@142vip/utils'
(async () => {
async function buildImageMain(): Promise<void> {
try {
// 获取package.json文件
const pkg = createRequire(import.meta.url)('../package.json')
const { name, version, description } = VipPackageJSON.getPackageJSON<{ description: string }>()
// 镜像地址
const imageName = `${OPEN_SOURCE_ADDRESS.DOCKER_ALIYUNCS_VIP}/docs:${pkg.name}-${pkg.version}`
const imageName = `${OPEN_SOURCE_ADDRESS.DOCKER_ALIYUNCS_VIP}/docs:${name}-${version}`
// 最近一次提交信息
const shortGitHash = VipGit.getRecentCommitShortHash()
@@ -32,12 +20,12 @@ import {
buildArgs: [
// 参数中是否包含 --proxy
['NEED_PROXY', VipNodeJS.getProcessArgv().includes('--proxy')],
['APP_NAME', pkg.name],
['APP_VERSION', pkg.version],
['APP_DESCRIPTION', pkg.description],
['AUTHOR', pkg.authorInfo.name],
['EMAIL', pkg.authorInfo.email],
['HOME_PAGE', pkg.authorInfo.homePage],
['APP_NAME', name],
['APP_VERSION', version],
['APP_DESCRIPTION', description],
['AUTHOR', OPEN_SOURCE_AUTHOR.name],
['EMAIL', OPEN_SOURCE_AUTHOR.email],
['HOME_PAGE', OPEN_SOURCE_AUTHOR.homePage],
['GIT_HASH', shortGitHash],
],
memory: 20000,
@@ -49,4 +37,6 @@ import {
catch (e) {
console.log('异常信息:', e)
}
})()
}
void buildImageMain()

72
scripts/core/mark-map.ts Normal file
View File

@@ -0,0 +1,72 @@
import { VipExecutor, VipNodeJS } from '@142vip/utils'
const __dirname = VipNodeJS.getProcessCwd()
const markMapSourcePath = VipNodeJS.pathJoin(__dirname, 'docs/mark-map')
const markMapTargetPath = VipNodeJS.pathJoin(__dirname, 'docs/.vuepress/public/mind-map')
/**
* 扫描目录
*/
function scanDirectory(directory: string, fileType: string) {
const fileList = VipNodeJS.readdirSync(directory)
return fileList
.map((file) => {
const filePath = VipNodeJS.pathJoin(directory, file)
const fileExtension = VipNodeJS.pathExtname(file).toLowerCase()
if (fileExtension === `.${fileType.toLowerCase()}`) {
return filePath
}
return null
})
// 过滤空
.filter(c => c != null)
}
/**
* 将思维导图的md格式转化为html提供在线预览
* 链接https://www.npmjs.com/package/markmap-cli
*/
async function markMapMain(): Promise<void> {
/**
* 第一步: 清空站点思维导图文件存放目录
*/
const delHtmlDir = `rm -rf ${VipNodeJS.pathJoin(markMapTargetPath, '*')}`
/**
* 第二步: 将md文档转化为思维导图网页
*/
const mdList = scanDirectory(markMapSourcePath, 'md')
const mdToHtmlCmdStr = mdList.map(md => `npx markmap --no-open ${md}`).join(' && ')
/**
* 第三步: 根据文件类型将思维导图网页文件移动到站点指定目录
*/
const mdHtmlByFileType = VipNodeJS.pathJoin(markMapSourcePath, '*.html')
const moveHtmlCmdStr = `mv -f ${mdHtmlByFileType} ${markMapTargetPath}`
await VipExecutor.commandStandardExecutor([
delHtmlDir,
mdToHtmlCmdStr,
moveHtmlCmdStr,
])
// /**
// * 第四步: 对mind-map中的xmind文件重命名
// */
// console.log(markMapSourcePath, import.meta.url)
// const markMapData = createRequire(import.meta.url)('../../docs/mark-map/index.json')
// console.log(111, markMapData)
// for (const { originXmindFileName, targetXmindFileName } of markMapData) {
// const originPath = path.join(markMapTargetPath, originXmindFileName)
// const targetPath = path.join(markMapTargetPath, targetXmindFileName)
//
// // html文件
// await fs.renameSync(originPath, targetPath)
// }
}
void markMapMain()

View File

@@ -1,73 +1,3 @@
#!/usr/bin/env node
/**
* 将思维导图的md格式转化为html提供在线预览
* 链接https://www.npmjs.com/package/markmap-cli
*/
import * as fs from 'node:fs'
import * as path from 'node:path'
import { fileURLToPath } from 'node:url'
import {VipExecutor, VipNodeJS} from '@142vip/utils'
#!/bin/bash
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const markMapSourcePath = VipNodeJS.pathJoin(__dirname, '../', 'docs/mark-map')
const markMapTargetPath = VipNodeJS.pathJoin(__dirname, '../', 'docs/.vuepress/public/mind-map')
/**
* 扫描目录
*/
function scanDirectory(directory, fileType) {
const fileList = fs.readdirSync(directory)
return fileList
.map((file) => {
const filePath = VipNodeJS.pathJoin(directory, file)
const fileExtension = path.extname(file).toLowerCase()
if (fileExtension === `.${fileType.toLowerCase()}`) {
return filePath
}
return null
})
// 过滤空
.filter(c => c != null)
}
(async () => {
/**
* 第一步: 清空站点思维导图文件存放目录
*/
const delHtmlDir = `rm -rf ${VipNodeJS.pathJoin(markMapTargetPath, '*')}`
/**
* 第二步: 将md文档转化为思维导图网页
*/
const mdList = scanDirectory(markMapSourcePath, 'md')
const mdToHtmlCmdStr = mdList.map(md => `npx markmap --no-open ${md}`).join(' && ')
/**
* 第三步: 根据文件类型将思维导图网页文件移动到站点指定目录
*/
const mdHtmlByFileType = VipNodeJS.pathJoin(markMapSourcePath, '*.html')
const moveHtmlCmdStr = `mv -f ${mdHtmlByFileType} ${markMapTargetPath}`
await VipExecutor.commandStandardExecutor([
delHtmlDir,
mdToHtmlCmdStr,
moveHtmlCmdStr,
])
// /**
// * 第四步: 对mind-map中的xmind文件重命名
// */
// console.log(markMapSourcePath, import.meta.url)
// const markMapData = createRequire(import.meta.url)('../../docs/mark-map/index.json')
// console.log(111, markMapData)
// for (const { originXmindFileName, targetXmindFileName } of markMapData) {
// const originPath = path.join(markMapTargetPath, originXmindFileName)
// const targetPath = path.join(markMapTargetPath, targetXmindFileName)
//
// // html文件
// await fs.renameSync(originPath, targetPath)
// }
})()
npx node --loader ts-node/esm --no-warnings scripts/core/mark-map.ts

View File

@@ -1,36 +0,0 @@
#!/bin/bash
##
## 同步分支脚本
## 使用: ./scripts/sync
##
# 远程仓库名称
remoteList=("origin" "mmdapl" "chufan443" "lir0115")
# 获取当前分支名称
current_branch=$(git rev-parse --abbrev-ref HEAD)
# master分支同步
if [ "$current_branch" = "master" ]; then
# 合并next分支内容到master分之
git merge origin/next
# 推送到每个远程仓库
for repoName in "${remoteList[@]}"
do
echo "-->Pushing to $repoName in master branch..."
git push "$repoName" master "$@"
done
# next分支同步
elif [ "$current_branch" = "next" ]; then
for repoName in "${remoteList[@]}"
do
echo "-->Pushing to $repoName in next branch..."
git push "$repoName" next "$@"
done
else
echo "当前分支是:$current_branch 只允许在master和next分支上操作并推送到远程"
fi

View File

@@ -21,7 +21,7 @@
"strictNullChecks": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"declaration": true,
"declaration": false,
"inlineSourceMap": true,
"stripInternal": true,
"allowSyntheticDefaultImports": true,

View File

@@ -1,29 +1,22 @@
import { fileURLToPath } from 'node:url'
import {
getDocSiteBase,
OPEN_SOURCE_ADDRESS,
OPEN_SOURCE_AUTHOR,
} from '@142vip/utils'
import { getDocSiteBase, GitGeneralBranch, OPEN_SOURCE_ADDRESS, OPEN_SOURCE_AUTHOR, VipPackageJSON } from '@142vip/utils'
import {
defineVipVuepressConfig,
FamilyHeaders,
getCopyRightText,
getFooterHtml,
getThemeConfig,
getViteBundler,
getVipHopeTheme,
handleImportCodePath,
} from '@142vip/vuepress'
import viteBundler from '@vuepress/bundler-vite'
import { defineUserConfig } from '@vuepress/cli'
import { path } from '@vuepress/utils'
import { hopeTheme } from 'vuepress-theme-hope'
import { navbarConfig, sidebarConfig } from './docs/theme.config'
import pkg from './package.json'
const pkg = VipPackageJSON.getPackageJSON<{ description: string }>()
/**
* 用户自定义配置
* 注意:
* - 环境变量中的PROXY_DOMAIN字段用于区分是否nginx代理
*/
export default defineUserConfig({
export default defineVipVuepressConfig({
base: getDocSiteBase(pkg.name),
title: '计算机408全家桶',
description: '磨刀不误砍柴工,读完硕士再打工',
@@ -31,74 +24,62 @@ export default defineUserConfig({
source: '',
head: FamilyHeaders,
markdown: {
// todo 引入代码文件时的路径替换
importCode: {
handleImportPath: (str) => {
const __dirname = path.dirname(fileURLToPath(import.meta.url))
if (str.includes('@code')) {
return str.replace(/^@code/, path.resolve(__dirname, '../../code/'))
}
if (str.includes('@ds')) {
return str.replace(/^@ds/, path.resolve(__dirname, '../../code/ds/'))
}
if (str.includes('~')) {
return str.replace(/^~/, path.resolve(__dirname, '../../'))
}
return str
},
handleImportPath: handleImportCodePath([
['@code', 'code'],
['@ds', 'code/ds'],
['~', ''],
]),
},
headers: {
level: [2, 3, 4],
},
},
// 主题配置
theme: hopeTheme({
...getThemeConfig({
// 导航栏
navbar: navbarConfig,
// 侧边栏
sidebar: sidebarConfig,
navbarLayout: {
start: ['Brand'],
center: ['Links'],
end: ['Language', 'Outlook', 'Repo', 'Search'],
},
favicon: '/408_favicon.ico',
logo: '/408_logo.png',
logoDark: '/408_logo.png',
hostname: 'https://408.142vip.cn',
// 页脚
footer: getFooterHtml({
name: pkg.name,
version: pkg.version,
}),
// 版权
copyright: getCopyRightText(OPEN_SOURCE_AUTHOR.name),
// 仓库
repo: '142vip/408CSFamily',
repoLabel: 'GitHub',
theme: getVipHopeTheme({
// 导航栏
navbar: navbarConfig,
// 侧边栏
sidebar: sidebarConfig,
navbarLayout: {
start: ['Brand'],
center: ['Links'],
end: ['Language', 'Outlook', 'Repo', 'Search'],
},
logo: '/logo.png',
logoDark: '/logo.png',
// todo 拓展OPEN_SOURCE_AUTHOR
hostname: 'https://408.142vip.cn',
// 页脚
footer: getFooterHtml({
name: pkg.name,
version: pkg.version,
}),
// 版权
copyright: getCopyRightText(OPEN_SOURCE_AUTHOR.name),
// 仓库
repo: '142vip/408CSFamily',
repoLabel: 'GitHub',
// 作者信息
author: OPEN_SOURCE_AUTHOR,
// 作者信息
author: OPEN_SOURCE_AUTHOR,
// 文档路径,开启编辑功能
docsDir: 'docs',
docsBranch: 'next',
// 主题布局选项
docsRepo: OPEN_SOURCE_ADDRESS.GITHUB_REPO_408,
// 文档路径,开启编辑功能
docsDir: 'docs',
docsBranch: GitGeneralBranch.NEXT,
// 主题布局选项
docsRepo: OPEN_SOURCE_ADDRESS.GITHUB_REPO_408,
// 插件
plugins: {
// 水印
watermark: {
enabled: false,
watermarkOptions: {
content: OPEN_SOURCE_AUTHOR.name,
},
// 插件
plugins: {
// 水印
watermark: {
enabled: false,
watermarkOptions: {
content: OPEN_SOURCE_AUTHOR.name,
},
},
}),
},
}),
bundler: viteBundler(getViteBundler()),
shouldPrefetch: false,
})