Skip to content

Commit

Permalink
!14 v3.8.1
Browse files Browse the repository at this point in the history
Merge pull request !14 from ktianc/master
  • Loading branch information
vvandk authored and gitee-org committed Mar 8, 2024
2 parents b08cd1c + 2c39c91 commit 4d240c2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ Kinit 是一套全部开源的快速开发平台,毫无保留给个人及企

<div align="center">
<p align="center">
<img src="https://ktianc.oss-cn-beijing.aliyuncs.com/kinit/public/images/0eb1de8eabf2f18bfa1c0d6c0151589.jpg" height="500" alt="logo"/>
<img src="https://ktianc.oss-cn-beijing.aliyuncs.com/resource/images/20240308/1709886536Tf0dm2ao.jpg" height="500" alt="logo"/>
</p>
</div>






## 在线体验

PC端演示地址:https://kinit.ktianc.top
Expand Down
2 changes: 1 addition & 1 deletion kinit-api/application/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"""
系统版本
"""
VERSION = "3.8.0"
VERSION = "3.8.1"

"""安全警告: 不要在生产中打开调试运行!"""
DEBUG = False
Expand Down
12 changes: 10 additions & 2 deletions kinit-api/apps/vadmin/workplace/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ async def get_team():
@app.get("/shortcuts", summary="获取快捷操作")
async def get_shortcuts():
data = [
{
"name": "Gitee 项目仓库",
"link": "https://gitee.com/ktianc/kinit"
},
{
"name": "GitHub 项目仓库",
"link": "https://github.com/vvandk/kinit"
},
{
"name": "前端文档",
"link": "https://element-plus-admin-doc.cn/"
Expand All @@ -136,8 +144,8 @@ async def get_shortcuts():
"link": "http://kinit.ktianc.top/api/redoc"
},
{
"name": "Windi CSS 文档",
"link": "https://cn.windicss.org/guide/"
"name": "UnoCSS 中文文档",
"link": "https://unocss.nodejs.cn/guide/"
},
{
"name": "Iconify 文档",
Expand Down
6 changes: 3 additions & 3 deletions kinit-api/utils/file/aliyun_oss.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def upload_image(self, path: str, file: UploadFile, max_size: int = 10) ->
# 验证图片类型
await self.validate_file(file, max_size, self.IMAGE_ACCEPT)
# 生成文件路径
path = self.generate_static_file_path(path, file.filename)
path = self.generate_relative_path(path, file.filename)
file_data = await file.read()
return await self.__upload_file_to_oss(path, file_data)

Expand All @@ -74,7 +74,7 @@ async def upload_video(self, path: str, file: UploadFile, max_size: int = 100) -
# 验证图片类型
await self.validate_file(file, max_size, self.VIDEO_ACCEPT)
# 生成文件路径
path = self.generate_static_file_path(path, file.filename)
path = self.generate_relative_path(path, file.filename)
file_data = await file.read()
return await self.__upload_file_to_oss(path, file_data)

Expand All @@ -86,7 +86,7 @@ async def upload_file(self, path: str, file: UploadFile) -> str:
:param file: 文件对象
:return: 上传后的文件oss链接
"""
path = self.generate_static_file_path(path, file.filename)
path = self.generate_relative_path(path, file.filename)
file_data = await file.read()
return await self.__upload_file_to_oss(path, file_data)

Expand Down
20 changes: 16 additions & 4 deletions kinit-api/utils/file/file_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@ def get_today_timestamp(cls) -> str:
return str(int((datetime.datetime.now().replace(hour=0, minute=0, second=0)).timestamp()))

@classmethod
def generate_static_file_path(cls, path: str, filename: str = None, suffix: str = None) -> str:
def generate_relative_path(cls, path: str, filename: str = None, suffix: str = None) -> str:
"""
生成 static 静态文件路径,生成规则:自定义目录/当天日期时间戳/随机文件名称
生成相对路径,生成规则:自定义目录/当天日期时间戳/随机文件名称
1. filename 参数或者 suffix 参数必须填写一个
2. filename 参数和 suffix 参数都存在则优先取 suffix 参数为后缀
:param path: static 指定目录类别
:param filename: 文件名称,只用户获取后缀,不做真实文件名称,避免文件重复问题
:param suffix: 文件后缀
:return:
"""
if not filename and not suffix:
raise ValueError("filename 参数或者 suffix 参数必须填写一个")
Expand All @@ -64,7 +63,20 @@ def generate_static_file_path(cls, path: str, filename: str = None, suffix: str
if path[-1] == "/":
path = path[:-1]
today = datetime.datetime.strftime(datetime.datetime.now(), "%Y%m%d")
return f"{STATIC_ROOT}/{path}/{today}/{cls.get_random_filename(suffix)}"
return f"{path}/{today}/{cls.get_random_filename(suffix)}"

@classmethod
def generate_static_file_path(cls, path: str, filename: str = None, suffix: str = None) -> str:
"""
生成 static 静态文件路径,生成规则:自定义目录/当天日期时间戳/随机文件名称
1. filename 参数或者 suffix 参数必须填写一个
2. filename 参数和 suffix 参数都存在则优先取 suffix 参数为后缀
:param path: static 指定目录类别
:param filename: 文件名称,只用户获取后缀,不做真实文件名称,避免文件重复问题
:param suffix: 文件后缀
:return:
"""
return f"{STATIC_ROOT}/{cls.generate_relative_path(path, filename, suffix)}"

@classmethod
def generate_temp_file_path(cls, filename: str = None, suffix: str = None) -> str:
Expand Down

0 comments on commit 4d240c2

Please sign in to comment.