vue2server7 2.3.3 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/test/6.js +60 -0
- package/test/doc/.vitepress/config.mts +28 -0
- package/test/doc/api-examples.md +49 -0
- package/test/doc/index.md +25 -0
- package/test/doc/markdown-examples.md +85 -0
- package/test/doc/package.json +7 -0
- package/test/NotepadNext-v0.13-win64.zip +0 -0
package/package.json
CHANGED
package/test/6.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const app = express();
|
|
6
|
+
const PORT = 3000;
|
|
7
|
+
|
|
8
|
+
// 设置 public 为静态目录
|
|
9
|
+
const publicDir = path.join(__dirname, 'public');
|
|
10
|
+
app.use('/static', express.static(publicDir));
|
|
11
|
+
|
|
12
|
+
// 首页:列出 public 文件夹里的所有文件
|
|
13
|
+
app.get('/', (req, res) => {
|
|
14
|
+
fs.readdir(publicDir, (err, files) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
return res.status(500).send('读取文件夹失败');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let fileListHtml = `
|
|
20
|
+
<h1>文件列表</h1>
|
|
21
|
+
<ul>
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
files.forEach(file => {
|
|
25
|
+
fileListHtml += `
|
|
26
|
+
<li>
|
|
27
|
+
${file} -
|
|
28
|
+
<a href="/download/${file}">下载</a>
|
|
29
|
+
</li>
|
|
30
|
+
`;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
fileListHtml += `
|
|
34
|
+
</ul>
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
res.send(fileListHtml);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// 下载接口
|
|
42
|
+
app.get('/download/:filename', (req, res) => {
|
|
43
|
+
const filename = req.params.filename;
|
|
44
|
+
const filePath = path.join(publicDir, filename);
|
|
45
|
+
|
|
46
|
+
// 防止路径穿越攻击
|
|
47
|
+
if (!filePath.startsWith(publicDir)) {
|
|
48
|
+
return res.status(400).send('非法访问');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
res.download(filePath, filename, (err) => {
|
|
52
|
+
if (err) {
|
|
53
|
+
res.status(404).send('文件不存在');
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
app.listen(PORT, () => {
|
|
59
|
+
console.log(`服务器已启动: http://localhost:${PORT}`);
|
|
60
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineConfig } from 'vitepress'
|
|
2
|
+
|
|
3
|
+
// https://vitepress.dev/reference/site-config
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
title: "My Awesome Project",
|
|
6
|
+
description: "A VitePress Site",
|
|
7
|
+
themeConfig: {
|
|
8
|
+
// https://vitepress.dev/reference/default-theme-config
|
|
9
|
+
nav: [
|
|
10
|
+
{ text: 'Home', link: '/' },
|
|
11
|
+
{ text: 'Examples', link: '/markdown-examples' }
|
|
12
|
+
],
|
|
13
|
+
|
|
14
|
+
sidebar: [
|
|
15
|
+
{
|
|
16
|
+
text: 'Examples',
|
|
17
|
+
items: [
|
|
18
|
+
{ text: 'Markdown Examples', link: '/markdown-examples' },
|
|
19
|
+
{ text: 'Runtime API Examples', link: '/api-examples' }
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
|
|
24
|
+
socialLinks: [
|
|
25
|
+
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
outline: deep
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Runtime API Examples
|
|
6
|
+
|
|
7
|
+
This page demonstrates usage of some of the runtime APIs provided by VitePress.
|
|
8
|
+
|
|
9
|
+
The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:
|
|
10
|
+
|
|
11
|
+
```md
|
|
12
|
+
<script setup>
|
|
13
|
+
import { useData } from 'vitepress'
|
|
14
|
+
|
|
15
|
+
const { theme, page, frontmatter } = useData()
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
## Results
|
|
19
|
+
|
|
20
|
+
### Theme Data
|
|
21
|
+
<pre>{{ theme }}</pre>
|
|
22
|
+
|
|
23
|
+
### Page Data
|
|
24
|
+
<pre>{{ page }}</pre>
|
|
25
|
+
|
|
26
|
+
### Page Frontmatter
|
|
27
|
+
<pre>{{ frontmatter }}</pre>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
<script setup>
|
|
31
|
+
import { useData } from 'vitepress'
|
|
32
|
+
|
|
33
|
+
const { site, theme, page, frontmatter } = useData()
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
## Results
|
|
37
|
+
|
|
38
|
+
### Theme Data
|
|
39
|
+
<pre>{{ theme }}</pre>
|
|
40
|
+
|
|
41
|
+
### Page Data
|
|
42
|
+
<pre>{{ page }}</pre>
|
|
43
|
+
|
|
44
|
+
### Page Frontmatter
|
|
45
|
+
<pre>{{ frontmatter }}</pre>
|
|
46
|
+
|
|
47
|
+
## More
|
|
48
|
+
|
|
49
|
+
Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
# https://vitepress.dev/reference/default-theme-home-page
|
|
3
|
+
layout: home
|
|
4
|
+
|
|
5
|
+
hero:
|
|
6
|
+
name: "My Awesome Project"
|
|
7
|
+
text: "A VitePress Site"
|
|
8
|
+
tagline: My great project tagline
|
|
9
|
+
actions:
|
|
10
|
+
- theme: brand
|
|
11
|
+
text: Markdown Examples
|
|
12
|
+
link: /markdown-examples
|
|
13
|
+
- theme: alt
|
|
14
|
+
text: API Examples
|
|
15
|
+
link: /api-examples
|
|
16
|
+
|
|
17
|
+
features:
|
|
18
|
+
- title: Feature A
|
|
19
|
+
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
|
20
|
+
- title: Feature B
|
|
21
|
+
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
|
22
|
+
- title: Feature C
|
|
23
|
+
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
|
24
|
+
---
|
|
25
|
+
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Markdown Extension Examples
|
|
2
|
+
|
|
3
|
+
This page demonstrates some of the built-in markdown extensions provided by VitePress.
|
|
4
|
+
|
|
5
|
+
## Syntax Highlighting
|
|
6
|
+
|
|
7
|
+
VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:
|
|
8
|
+
|
|
9
|
+
**Input**
|
|
10
|
+
|
|
11
|
+
````md
|
|
12
|
+
```js{4}
|
|
13
|
+
export default {
|
|
14
|
+
data () {
|
|
15
|
+
return {
|
|
16
|
+
msg: 'Highlighted!'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
````
|
|
22
|
+
|
|
23
|
+
**Output**
|
|
24
|
+
|
|
25
|
+
```js{4}
|
|
26
|
+
export default {
|
|
27
|
+
data () {
|
|
28
|
+
return {
|
|
29
|
+
msg: 'Highlighted!'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Custom Containers
|
|
36
|
+
|
|
37
|
+
**Input**
|
|
38
|
+
|
|
39
|
+
```md
|
|
40
|
+
::: info
|
|
41
|
+
This is an info box.
|
|
42
|
+
:::
|
|
43
|
+
|
|
44
|
+
::: tip
|
|
45
|
+
This is a tip.
|
|
46
|
+
:::
|
|
47
|
+
|
|
48
|
+
::: warning
|
|
49
|
+
This is a warning.
|
|
50
|
+
:::
|
|
51
|
+
|
|
52
|
+
::: danger
|
|
53
|
+
This is a dangerous warning.
|
|
54
|
+
:::
|
|
55
|
+
|
|
56
|
+
::: details
|
|
57
|
+
This is a details block.
|
|
58
|
+
:::
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Output**
|
|
62
|
+
|
|
63
|
+
::: info
|
|
64
|
+
This is an info box.
|
|
65
|
+
:::
|
|
66
|
+
|
|
67
|
+
::: tip
|
|
68
|
+
This is a tip.
|
|
69
|
+
:::
|
|
70
|
+
|
|
71
|
+
::: warning
|
|
72
|
+
This is a warning.
|
|
73
|
+
:::
|
|
74
|
+
|
|
75
|
+
::: danger
|
|
76
|
+
This is a dangerous warning.
|
|
77
|
+
:::
|
|
78
|
+
|
|
79
|
+
::: details
|
|
80
|
+
This is a details block.
|
|
81
|
+
:::
|
|
82
|
+
|
|
83
|
+
## More
|
|
84
|
+
|
|
85
|
+
Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).
|
|
Binary file
|