☁️ origin

This commit is contained in:
微凉
2021-01-12 14:58:33 +08:00
parent 858291876b
commit 434eb25408
4 changed files with 17 additions and 4 deletions

View File

@@ -3,7 +3,7 @@
</p> </p>
<p align="center"> <p align="center">
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/release/Xhofe/alist" alt="Release version"></a> <a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/release/Xhofe/alist" alt="Release version"></a>
<a href="https://github.com/Xhofe/alist/actions?query=workflow%3ABuild"><img src="https://github.com/Xhofe/alist/workflows/Build/badge.svg" alt="Build status"></a> <a href="https://github.com/Xhofe/alist/actions?query=workflow%3ABuild"><img src="https://github.com/Xhofe/alist/workflows/build/badge.svg" alt="Build status"></a>
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/downloads/Xhofe/alist/latest/total" alt="Downloads"></a> <a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/downloads/Xhofe/alist/latest/total" alt="Downloads"></a>
<a href="https://github.com/Xhofe/alist/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Xhofe/alist" alt="License"></a> <a href="https://github.com/Xhofe/alist/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Xhofe/alist" alt="License"></a>
<a href="https://pay.xhofe.top"> <a href="https://pay.xhofe.top">

View File

@@ -16,6 +16,7 @@ type GithubRelease struct {
} }
func CheckUpdate() { func CheckUpdate() {
log.Infof("检查更新...")
url:="https://api.github.com/repos/Xhofe/alist/releases/latest" url:="https://api.github.com/repos/Xhofe/alist/releases/latest"
resp,err:=http.Get(url) resp,err:=http.Get(url)
if err!=nil { if err!=nil {

View File

@@ -1,17 +1,23 @@
info: info:
title: AList #标题 title: AList #标题
site_url: http://localhost:5277 #前端地址
backend_url: http://localhost:5244 #后端地址
logo: "" #网站logo 如果填写,则会替换掉默认的 logo: "" #网站logo 如果填写,则会替换掉默认的
footer_text: Xhofe's Blog #网页底部文字 footer_text: Xhofe's Blog #网页底部文字
footer_url: https://www.nn.ci #网页底部文字链接 footer_url: https://www.nn.ci #网页底部文字链接
music_img: https://img.oez.cc/2020/12/19/0f8b57866bdb5.gif #预览音乐文件时的图片 music_img: https://img.oez.cc/2020/12/19/0f8b57866bdb5.gif #预览音乐文件时的图片
check_update: true #前端是否显示更新 check_update: true #前端是否显示更新
script: #自定义脚本,可以是脚本的链接,也可以直接是脚本内容,如document.querySelector('body').style="background-image:url('https://api.mtyqx.cn/api/random.php');background-attachment:fixed" script: #自定义脚本,可以是脚本的链接,也可以直接是脚本内容,如document.querySelector('body').style="background-image:url('https://api.mtyqx.cn/api/random.php');background-attachment:fixed"
autoplay: true #视频是否自动播放
preview:
url: https://view.alist.nn.ci/onlinePreview?url= #extensions中包含的后缀名预览的地址默认使用了kkFileView可以自行搭建
pre_process: [base64,encodeURIComponent] #对地址的处理支持base64,encodeURIComponent,encodeURI
extensions: [doc,docx,ppt,pptx,xls,xlsx,pdf] #使用上面的url预览的文件后缀
text: [txt,htm,html,xml,java,properties,sql,js,md,json,conf,ini,vue,php,py,bat,gitignore,yml,go,sh,c,cpp,h,hpp] #要预览的文本文件的后缀,可以自行添加
max_size: 5242880
server: server:
port: "5244" #程序监听端口 port: "5244" #程序监听端口
search: true #是否开启搜索接口,开启搜索之后密码和根目录都会失效,所以前端暂时不做搜索 search: true #是否开启搜索接口,开启搜索之后密码和根目录都会失效,所以前端暂时不做搜索
static: dist #前端文件目录 static: dist #前端文件目录
site_url: '*' #建议直接填*,若有信任域名要求,可填写其他,逗号分割
cache: cache:
enable: true #是否开启缓存 enable: true #是否开启缓存
expiration: 60 #缓存失效时间(单位:分钟) expiration: 60 #缓存失效时间(单位:分钟)

View File

@@ -9,9 +9,15 @@ import (
func CrosHandler() gin.HandlerFunc { func CrosHandler() gin.HandlerFunc {
return func(context *gin.Context) { return func(context *gin.Context) {
origin:=context.GetHeader("Origin")
// 同源
if origin == "" {
context.Next()
return
}
method := context.Request.Method method := context.Request.Method
// 设置跨域 // 设置跨域
context.Header("Access-Control-Allow-Origin",context.GetHeader("Origin")) context.Header("Access-Control-Allow-Origin",origin)
context.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE,UPDATE") context.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE,UPDATE")
context.Header("Access-Control-Allow-Headers", "Content-Length,session,Accept, Origin, Host, Connection, Accept-Encoding, Accept-Language, Keep-Alive, User-Agent, Cache-Control, Content-Type") context.Header("Access-Control-Allow-Headers", "Content-Length,session,Accept, Origin, Host, Connection, Accept-Encoding, Accept-Language, Keep-Alive, User-Agent, Cache-Control, Content-Type")
context.Header("Access-Control-Expose-Headers", "Content-Length,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified") context.Header("Access-Control-Expose-Headers", "Content-Length,Cache-Control,Content-Language,Content-Type,Expires,Last-Modified")