Skip to content

Commit 59b55d9

Browse files
authored
Merge pull request #39 from godwei123/develop
feat & fix bug
2 parents 8ec05ce + 7a55f95 commit 59b55d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+800
-204
lines changed

.idea/.gitignore

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/.vitepress/config.ts

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import nav from "./nav";
22
import sidebar from "./sidebar";
33

44
import { defineConfig } from "vitepress";
5+
import { resolve } from "node:url";
56

67
export default defineConfig({
78
title: "JavaScriptGuide",
@@ -47,4 +48,11 @@ export default defineConfig({
4748
markdown: {
4849
lineNumbers: false,
4950
},
51+
vite: {
52+
resolve: {
53+
alias: {
54+
"~": resolve(__dirname, "../packages"),
55+
},
56+
},
57+
},
5058
});

docs/.vitepress/nav/index.ts

+20-16
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,32 @@ const nav: DefaultTheme.NavItem[] = [
66
link: "/javascript/introduction",
77
},
88
{
9-
text: "前端",
10-
items: [
11-
{
12-
text: "html & css",
13-
link: "/basic/html/introduction",
14-
},
15-
{
16-
text: "浏览器 & 网络",
17-
link: "/basic/browser/introduction",
18-
},
19-
{
20-
text: "Coding",
21-
link: "/basic/code/introduction",
22-
},
23-
],
9+
text: "CSS",
10+
link: "/css/introduction",
11+
},
12+
// {
13+
// text: "前端",
14+
// items: [
15+
// {
16+
// text: "html",
17+
// link: "/basic/html/introduction",
18+
// },
19+
// ],
20+
// },
21+
{
22+
text: "network",
23+
link: "/basic/browser/introduction",
24+
},
25+
{
26+
text: "coding",
27+
link: "/basic/code/introduction",
2428
},
2529
{
2630
text: "blog",
2731
link: "/blog/introduction",
2832
},
2933
{
30-
text: "About",
34+
text: "about",
3135
link: "/about",
3236
},
3337
];

docs/.vitepress/scripts/sidebar.ts

+47-40
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,65 @@
11
import fg from "fast-glob";
22

3-
const javaScriptIntroduction = { text: "Introduction", link: "/javascript/introduction" };
4-
const javaScriptOptions: Record<string, string> = {
5-
type: "类型和语法",
6-
"array-string": "Array & String",
7-
object: "Object",
8-
"type-conversion": "类型转换",
9-
prototype: "原型和原型链",
10-
this: "this",
11-
closure: "闭包",
12-
"throttle-debounce": "节流和防抖",
13-
async: "同步和异步",
14-
regexp: "正则",
15-
"ES5+": "ES6+",
16-
"proxy-reflect": "代理和反射",
17-
"broadcast-channel": "Broadcast Channel API",
18-
"web-speech-api": "Web Speech API",
19-
observer: "Observer API",
20-
other: "其他",
21-
eventloop: "Event Loop",
22-
};
23-
24-
const blogIntroduction = { text: "Introduction", link: "/blog/introduction" };
25-
const cssIntroduction = { text: "Introduction", link: "/basic/css/introduction" };
3+
const javaScriptIntroduction = { text: "Introduction", link: "/javascript/introduction", order: 0 };
4+
const blogIntroduction = { text: "Introduction", link: "/blog/introduction", order: 0 };
5+
const cssIntroduction = { text: "Introduction", link: "/css/introduction", order: 0 };
266

27-
const CSSOptions = {
28-
"@font-face": "@font-face",
29-
center: "居中",
30-
flex: "flex布局",
31-
layout: "常见布局",
32-
grid: "grid布局",
33-
"text-hidden-overflow": "文本溢出",
34-
bfc: "BFC",
35-
position: "层叠与定位",
36-
"pseudo-classes-element": "伪类与伪元素",
37-
selectors: "CSS选择器",
7+
const javaScriptOptions: Record<string, { text: string; order: number }> = {
8+
type: { text: "类型和语法", order: 1 },
9+
"array-string": { text: "Array & String", order: 2 },
10+
object: { text: "Object", order: 3 },
11+
"type-conversion": { text: "类型转换", order: 4 },
12+
prototype: { text: "原型和原型链", order: 5 },
13+
this: { text: "this", order: 6 },
14+
closure: { text: "闭包", order: 7 },
15+
"throttle-debounce": { text: "节流和防抖", order: 8 },
16+
async: { text: "同步和异步", order: 9 },
17+
regexp: { text: "正则", order: 10 },
18+
"ES5+": { text: "ES6+", order: 11 },
19+
"proxy-reflect": { text: "代理和反射", order: 12 },
20+
"broadcast-channel": { text: "Broadcast Channel API", order: 13 },
21+
"web-speech-api": { text: "Web Speech API", order: 14 },
22+
observer: { text: "Observer API", order: 15 },
23+
other: { text: "其他", order: 16 },
24+
eventloop: { text: "Event Loop", order: 17 },
3825
};
3926

27+
const CSSOptions: Record<string, { text: string; order: number }> = {
28+
center: { text: "居中", order: 1 },
29+
flex: { text: "flex布局", order: 2 },
30+
layout: { text: "常见布局", order: 3 },
31+
grid: { text: "grid布局", order: 4 },
32+
"@font-face": { text: "@font-face", order: 5 },
33+
"text-hidden-overflow": { text: "文本溢出", order: 6 },
34+
bfc: { text: "BFC", order: 7 },
35+
position: { text: "层叠与定位", order: 8 },
36+
"pseudo-classes-element": { text: "伪类与伪元素", order: 9 },
37+
selectors: { text: "CSS选择器", order: 10 },
38+
};
4039
/**
4140
* @description: 生成侧边栏
4241
*/
4342
const generateSidebar = (
4443
cwd: string,
45-
introduction: Record<string, string>,
46-
options: Record<string, string>,
44+
introduction: { text: string; link: string; order: number },
45+
options: Record<string, { text: string; order: number }>,
4746
prefix: string
4847
) => {
4948
const files = fg.sync(["./*.md"], { cwd: cwd, ignore: ["./introduction.md"] });
5049
const result = files.map((file) => {
5150
const path = file.replace(/(\/index)?\.md$/, "");
52-
const text = path.replace(/\/$/, "").split("/").pop();
53-
return { text: options[text] || text, link: `/${prefix}/${path}` };
51+
const key = path.replace(/\/$/, "").split("/").pop();
52+
if (options[key]) {
53+
return {
54+
text: options[key].text,
55+
link: `/${prefix}/${path}`,
56+
order: options[key].order,
57+
};
58+
} else {
59+
console.warn(`warning: [sidebar.ts/${prefix}] ${key} not in options`);
60+
}
5461
});
55-
return [introduction, ...result];
62+
return [introduction, ...result].sort((a, b) => a.order - b.order);
5663
};
5764

5865
export const generateJavaScriptSidebar = () => {
@@ -72,5 +79,5 @@ export const generateBlogSidebar = () => {
7279

7380
export const generateCSSSidebar = () => {
7481
console.log("css sidebar generate");
75-
return generateSidebar("./docs/basic/css", cssIntroduction, CSSOptions, "css");
82+
return generateSidebar("./docs/css", cssIntroduction, CSSOptions, "css");
7683
};

docs/.vitepress/serviceWorker.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
setTimeout(() => {
2+
console.log("Hello from the service worker");
3+
}, 1000);

docs/.vitepress/sidebar/index.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import { sidebarBaseBrowserAndNetwork, sidebarBaseHTMLAndCSS, sidebarCode } from "./sidebarBase";
22
import { DefaultTheme } from "vitepress";
3-
import { generateJavaScriptSidebar, generateBlogSidebar } from "../scripts/sidebar";
3+
import {
4+
generateJavaScriptSidebar,
5+
generateBlogSidebar,
6+
generateCSSSidebar,
7+
} from "../scripts/sidebar";
48

59
const sidebar: DefaultTheme.SidebarMulti = {
610
"/javascript": generateJavaScriptSidebar(),
711
"/basic/html": sidebarBaseHTMLAndCSS,
8-
"/basic/css": sidebarBaseHTMLAndCSS,
12+
"/css": generateCSSSidebar(),
913
"/basic/network": sidebarBaseBrowserAndNetwork,
1014
"/basic/browser": sidebarBaseBrowserAndNetwork,
1115
"/basic/code": sidebarCode,
12-
"/blog": generateBlogSidebar(),
16+
// "/blog": generateBlogSidebar(),
1317
};
1418
export default sidebar;

docs/.vitepress/sidebar/sidebarBase.ts

-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { DefaultTheme } from "vitepress";
2-
import { generateCSSSidebar } from "../scripts/sidebar";
32

43
export const sidebarBaseHTMLAndCSS: DefaultTheme.SidebarItem[] = [
54
{
@@ -10,10 +9,6 @@ export const sidebarBaseHTMLAndCSS: DefaultTheme.SidebarItem[] = [
109
{ text: "HTML属性", link: "/basic/html/attribute" },
1110
],
1211
},
13-
{
14-
text: "CSS",
15-
items: generateCSSSidebar(),
16-
},
1712
];
1813
export const sidebarBaseBrowserAndNetwork: DefaultTheme.SidebarItem[] = [
1914
{

docs/.vitepress/theme/custom.css

-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
--vp-home-hero-image-filter: blur(60px);
1616
}
1717

18-
html,
19-
body {
20-
/*font-size: 14px !important;*/
21-
}
22-
2318
.components-container {
2419
margin: 20px 0;
2520
}

docs/.vitepress/theme/index.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import Layout from "./Layout.vue";
77
export default {
88
...DefaultTheme,
99
Layout: Layout,
10-
enhanceApp(ctx) {
10+
enhanceApp(ctx: { app: any; router: any }) {
1111
// console.log(ctx);
1212
const { app, router } = ctx;
13-
router.onBeforeRouteChange = (to: string) => {
14-
console.log("before", to);
15-
};
16-
router.onAfterRouteChanged = (to: string) => {
17-
console.log("after", to);
18-
};
13+
// router.onBeforeRouteChange = (to: string) => {
14+
// console.log("before", to);
15+
// };
16+
// router.onAfterRouteChanged = (to: string) => {
17+
// console.log("after", to);
18+
// };
1919
app.use(naive);
2020
},
2121
};

docs/about.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
layout: page
3+
footer: false
34
---
45

56
<script setup>
@@ -8,19 +9,18 @@ import {
89
VPTeamPageTitle,
910
VPTeamMembers,
1011
VPTeamPageSection
11-
} from 'vitepress/theme';
12-
import { ref } from "vue";
12+
} from 'vitepress/theme';
1313

1414
const members = [
1515
{
16-
avatar: 'avatar.png',
16+
avatar: 'IMG_2235.jpg',
1717
name: 'God wei',
1818
title: 'All I need is you!',
1919
desc: 'developer'
2020
}
2121
];
2222

23-
const version = ref('0.0.2');
23+
const version = '0.0.2';
2424
</script>
2525

2626
<VPTeamPage>
@@ -30,12 +30,9 @@ const version = ref('0.0.2');
3030
</template>
3131
<template #lead>
3232
<br>
33-
version: {{version}}
34-
<Badge type="warning" text="alpha"></Badge>
33+
version: {{version}}
3534
</template>
3635
</VPTeamPageTitle>
37-
<VPTeamMembers
38-
size="small"
39-
:members="members"
36+
<VPTeamMembers :members="members"
4037
/>
4138
</VPTeamPage>

docs/basic/browser/introduction.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
next: false
3+
prev: false
4+
---
5+
16
::: tip
27
浏览器缓存、存储、跨域、安全、渲染等内容。
38
:::

docs/basic/code/introduction.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Introduction
1+
---
2+
next: false
3+
prev: false
4+
---
25

36
:::tip
47
Javascript 常见的代码

docs/basic/css/introduction.md

-7
This file was deleted.

docs/basic/network/introduction.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
next: false
3+
prev: false
4+
---
5+
16
::: tip
27
计算机网络
38
:::

docs/blog/introduction.md

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
# Introduction
1+
---
2+
prev: false
3+
next: false
4+
aside: false
5+
footer: false
6+
---
27

3-
:::tip
4-
blog
8+
:::tip 博客目录
59
:::
10+
11+
<script setup>
12+
import BlogToc from "../../packages/pages/blog-toc.vue";
13+
</script>
14+
15+
<BlogToc />
File renamed without changes.
File renamed without changes.

docs/basic/css/BFC.md docs/css/bfc.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ CSS3 中的盒模型有以下两种:标准盒子模型、IE 盒子模型
66

77
盒模型都是由四个部分组成的,分别是 margin、border、padding 和 content.
88

9-
![标准盒子模型](../../public/20200715170108916.png)
9+
![标准盒子模型](../public/20200715170108916.png)
1010

11-
![IE盒子模型](../../public/20200715170121834.png)
11+
![IE盒子模型](../public/20200715170121834.png)
1212

1313
标准盒模型和 IE 盒模型的区别在于设置 width 和 height 时,所对应的范围不同:
1414

docs/basic/css/blend-mode.md docs/css/blend-mode.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# blend-mode
22

33
<script setup lang="ts">
4-
import BlendModeVisual from "../../../packages/pages/basic/blend-mode-visual.vue";
4+
import BlendModeVisual from "~/pages/basic/blend-mode-visual.vue";
55
</script>
66

77
<ClientOnly>
File renamed without changes.

docs/basic/css/center.md docs/css/center.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 居中
22

33
<script setup>
4-
import CenterVisual from "../../../packages/pages/basic/center-visual.vue";
4+
import CenterVisual from "~/pages/basic/center-visual.vue";
55
</script>
66

77
## 水平居中
File renamed without changes.

0 commit comments

Comments
 (0)