Skip to content

Commit

Permalink
Merge pull request #96 from helloxz/dev
Browse files Browse the repository at this point in the history
3.3.0
  • Loading branch information
helloxz authored Mar 26, 2023
2 parents 5d60295 + a5ce356 commit 0edf2f7
Show file tree
Hide file tree
Showing 11 changed files with 333 additions and 279 deletions.
4 changes: 2 additions & 2 deletions cli/Version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var VersionDate string

// 赋值全局变量
func init() {
Version = "3.2.0"
VersionDate = "20230109"
Version = "3.3.0"
VersionDate = "20230326"
}

// 命令行打印版本
Expand Down
2 changes: 1 addition & 1 deletion compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ OS=$1
ARCH=$2

#Zdir版本号
VERSION=3.2.0
VERSION=3.3.0

#编译linux
compile_linux() {
Expand Down
11 changes: 11 additions & 0 deletions controller/Dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ func Mkdir(c *gin.Context) {
//判断上级路径是否存在
full_path := public_dir + path

//需要验证用户传递的path参数是否合法
if !V_fpath(path) {
c.JSON(200, gin.H{
"code": -1000,
"msg": "参数不合法!",
"data": "",
})
c.Abort()
return
}

//如果路径不存在
if !V_dir(full_path) {
c.JSON(200, gin.H{
Expand Down
4 changes: 0 additions & 4 deletions controller/FileList.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ import (
"zdir/config"

"github.com/gin-gonic/gin"
"gopkg.in/ini.v1"
)

// 声明一个全局变量用来获取.ini配置
var cfg *ini.File

// 定义一个结构体,用来存放文件或文件夹信息
type info struct {
Name string
Expand Down
3 changes: 3 additions & 0 deletions controller/Functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"math/rand"
"net/url"
"strings"
"time"

"github.com/gin-gonic/gin"
)
Expand All @@ -20,6 +21,8 @@ func md5s(str string) string {

// 生成一个随机字符串
func RandStr(n int) string {
//如果seed固定,那么每次程序重启后重新生成随机数会重复上一次的随机数,所以这里设置一个随机seed
rand.Seed(time.Now().UnixNano())
var bytes []byte = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890")
result := make([]byte, n)
for i := 0; i < n; i++ {
Expand Down
31 changes: 25 additions & 6 deletions controller/Upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ package controller

import (
"os"
"regexp"
"zdir/config"

"github.com/gin-gonic/gin"
)

// 声明一个结构体,用于保存文件上传成功后的信息
type fileinfo struct {
Url string `json:"url"`
}

func Upload(c *gin.Context) {
//获取文件路径
path := c.PostForm("path")
Expand All @@ -23,9 +27,8 @@ func Upload(c *gin.Context) {
}
//如果上传路径不合法
//判断用户传递的路径是否合法
var validPath = regexp.MustCompile(`^(\.|\..).+`)
v_re := validPath.MatchString(path)
if v_re {
v_re := V_fpath(path)
if !v_re {
c.JSON(200, gin.H{
"code": -1000,
"msg": "文件夹名称不合法!",
Expand Down Expand Up @@ -59,14 +62,30 @@ func Upload(c *gin.Context) {

// 单文件
file, _ := c.FormFile("file")
file_name := file.Filename
//验证文件名是否合法
if !V_fname(file_name) {
c.JSON(200, gin.H{
"code": -1000,
"msg": "文件名不合法!",
"data": "",
})
return
}

dst := full_path + file.Filename
dst := full_path + file_name
// 上传文件至指定的完整文件路径
c.SaveUploadedFile(file, dst)

//拼接url
var finfo fileinfo
//获取公共存储的域名
storage_domain := config.Public_domain(c)
finfo.Url = storage_domain + path + file_name
//返回上传成功
c.JSON(200, gin.H{
"code": 200,
"msg": "success",
"data": "",
"data": finfo,
})
}
1 change: 0 additions & 1 deletion templates/assets/addmin.css

This file was deleted.

2 changes: 1 addition & 1 deletion templates/assets/admin.css

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions templates/assets/admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion templates/assets/index.css

Large diffs are not rendered by default.

536 changes: 281 additions & 255 deletions templates/assets/index.js

Large diffs are not rendered by default.

0 comments on commit 0edf2f7

Please sign in to comment.