forked from ganlvtech/down_52pojie_cn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
253 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# 前端配置说明 | ||
|
||
本项目已经插件化,在 HTML 中插入下列代码,即可以使用如下代码,使用默认配置加载插件。 | ||
|
||
```html | ||
<div id="app"> | ||
<script> | ||
window.down52PojieCn = new Down52PojieCn(); | ||
</script> | ||
``` | ||
|
||
## 默认配置 | ||
|
||
上面代码等效于 | ||
|
||
```js | ||
window.down52PojieCn = new Down52PojieCn({ | ||
vueElement: '#app'; | ||
routerMode: 'hash', | ||
baseUrl: 'https://down.52pojie.cn', | ||
requestType: 'json', | ||
jsonUrl: '/list.json', | ||
cacheTime: 0 | ||
}); | ||
``` | ||
|
||
## 使用 jsonp 加载文件列表 | ||
|
||
```js | ||
window.down52PojieCn = new Down52PojieCn({ | ||
requestType: 'jsonp' | ||
}); | ||
``` | ||
|
||
等效于 | ||
|
||
```js | ||
window.down52PojieCn = new Down52PojieCn({ | ||
vueElement: '#app'; | ||
routerMode: 'hash', | ||
baseUrl: 'https://down.52pojie.cn', | ||
requestType: 'jsonp', | ||
jsonpUrl: '/list.js', | ||
jsonpCallback: '__jsonpCallbackDown52PojieCn', | ||
cacheTime: 0 | ||
}); | ||
``` | ||
|
||
对于已开启 ngx-fancyindex 的网站,可以将 `routerMode` 修改为 `'history'`。 | ||
|
||
`dist.zip` 中已经配置成 history + jsonp 模式了。 | ||
|
||
## 默认配置说明 | ||
|
||
* Vue Router 默认使用 hash 方式。 | ||
* 默认使用 ajax 请求 json 文件 | ||
* 默认从网站根目录加载 `list.json` | ||
* 默认不会使用缓存(缓存控制交给服务器管理) | ||
|
||
具体配置说明可以参考 `src/Down52PojieCn.js` 中的详细注释。 | ||
|
||
## 关于缓存 | ||
|
||
如果启用缓存(`cacheTime` 设为非 0 的数),用户访问页面时,会请求 `list.json`,请求后面会带一个时间戳参数(例如:`t=153xxxxxxx`),这个时间戳为向 `cacheTime` 取整后的数字。 | ||
|
||
## 文件路径 | ||
|
||
由于单页应用的特殊性,所有文件的路径必须从网站根目录开始写,比如可以写 `/list.json` 而不能写 `list.json` 或 `./list.json`。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# 配置说明 | ||
|
||
有 3 种部署方案, | ||
|
||
1. 为了优化网站 SEO,使用 [ngx-fancyindex](https://github.com/aperezdc/ngx-fancyindex) | ||
2. 不考虑 SEO 问题,希望 URL 看着比较美观 | ||
3. 单页应用 | ||
|
||
第 1 种:ngx-fancyindex 可以直接在 HTML 中生成文件列表,这对搜索引擎十分友好,但是对用户不好。 | ||
|
||
其余两种都不需要 ngx-fancyindex,这两种的区别在于使用了 Vue Router 的两种模式,`history` 或者 `hash`。 | ||
|
||
第 2 种:使用 history 模式,URL 是 `https://down.52pojie.cn/Tools/Debuggers/`,这种需要对 Nginx 进行一些配置。 | ||
|
||
第 3 种:使用 hash 模式,URL 是 `https://down.52pojie.cn/#/Tools/Debuggers/`,这种直接上传到服务器上即可,无需过多配置。 | ||
|
||
本程序可以不依赖 ngx-fancyindex,可以单独使用,可以作为静态页面使用,例如本项目的 [GitHub Pages](https://ganlvtech.github.io/down_52pojie_cn/)。 | ||
|
||
## 使用 ngx-fancyindex | ||
|
||
### 安装 ngx-fancyindex | ||
|
||
在服务器安装 ngx-fancyindex | ||
|
||
```bash | ||
sudo apt-get install nginx-extras | ||
``` | ||
|
||
### 下载并解压本仓库的文件 | ||
|
||
在 [本仓库 Release 页面](https://github.com/ganlvtech/down_52pojie_cn/releases) 下载 `dist.zip` 的压缩包,解压到网站根目录。 | ||
|
||
此时网站的目录结构应该是 | ||
|
||
```plain | ||
/ | ||
foo.zip | ||
bar.exe | ||
...... | ||
.fancyindex/ | ||
header.html | ||
footer.html | ||
js/ | ||
css/ | ||
``` | ||
|
||
### 修改 Nginx 配置文件 | ||
|
||
然后修改 `/etc/nginx/site-enables/your-site`,在其中增加 ngx-fancyindex 的配置。示例配置文件如下。 | ||
|
||
```nginx | ||
server { | ||
listen 80; | ||
listen 443 ssl; | ||
root /srv/www/down; | ||
index index.html index.htm; | ||
server_name down.localhost; | ||
location / { | ||
fancyindex on; | ||
fancyindex_header "/.fancyindex/header.html"; | ||
fancyindex_footer "/.fancyindex/footer.html"; | ||
} | ||
} | ||
``` | ||
|
||
> `ngx-fancyindex` 默认不会列举出以 `.` 开头的文件夹和文件。 | ||
这时执行 | ||
|
||
```bash | ||
sudo service nginx reload | ||
``` | ||
|
||
应该可以看到网站的主页已经变成了本项目的样子了,但是现在暂时还没有文件列表。生成文件列表请参考 [php 文件扫描程序说明文档](php/README.md)。 | ||
|
||
## 使用 history 模式 | ||
|
||
## 使用 hash 模式 |
Oops, something went wrong.