Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
a161bfa8
提交
a161bfa8
authored
11月 15, 2020
作者:
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: added base64 file stream download
上级
78d4d41c
全部展开
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
105 行增加
和
54 行删除
+105
-54
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+6
-0
index.less
src/components/Menu/src/index.less
+53
-46
index.less
src/design/var/index.less
+1
-1
index.vue
src/layouts/logo/index.vue
+8
-0
colorSetting.ts
src/settings/colorSetting.ts
+2
-1
FileDownload.ts
src/utils/file/FileDownload.ts
+10
-3
stream.ts
src/utils/file/stream.ts
+15
-0
imgBase64.ts
src/views/demo/feat/download/imgBase64.ts
+0
-0
index.vue
src/views/demo/feat/download/index.vue
+10
-3
没有找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
a161bfa8
## Wip
### ✨ Features
-
新增 base64 文件流下载
## 2.0.0-rc.10 (2020-11-13)
### ✨ Refactor
...
...
src/components/Menu/src/index.less
浏览文件 @
a161bfa8
...
...
@@ -49,56 +49,10 @@
}
}
// collapsed show title end
.ant-menu-item,
.ant-menu-submenu-title {
> .basic-menu__name {
width: 100%;
.basic-menu__tag {
float: right;
margin-top: @app-menu-item-height / 2;
transform: translate(0%, -50%);
}
}
}
.ant-menu-item {
transition: unset;
}
&__tag {
display: inline-block;
padding: 2px 4px;
margin-right: 4px;
font-size: 12px;
line-height: 14px;
color: #fff;
border-radius: 2px;
&.dot {
width: 8px;
height: 8px;
padding: 0;
border-radius: 50%;
}
&.primary {
background: @primary-color;
}
&.error {
background: @error-color;
}
&.success {
background: @success-color;
}
&.warn {
background: @warning-color;
}
}
// scrollbar -s tart
&__content {
/* 滚动槽 */
...
...
@@ -245,6 +199,11 @@
margin: 0;
line-height: @app-menu-item-height;
}
.ant-menu-item.basic-menu-item__level1 {
height: @app-menu-item-height;
line-height: @app-menu-item-height;
}
}
// 层级样式
...
...
@@ -381,3 +340,51 @@
}
}
}
// collapsed show title end
.ant-menu-item,
.ant-menu-submenu-title {
> .basic-menu__name {
width: 100%;
.basic-menu__tag {
float: right;
margin-top: @app-menu-item-height / 2;
transform: translate(0%, -50%);
}
}
}
.basic-menu__tag {
display: inline-block;
padding: 2px 4px;
margin-right: 4px;
font-size: 12px;
line-height: 14px;
color: #fff;
border-radius: 2px;
&.dot {
width: 8px;
height: 8px;
padding: 0;
margin-top: 21px !important;
margin-bottom: 2px;
border-radius: 50%;
}
&.primary {
background: @primary-color;
}
&.error {
background: @error-color;
}
&.success {
background: @success-color;
}
&.warn {
background: @warning-color;
}
}
src/design/var/index.less
浏览文件 @
a161bfa8
...
...
@@ -6,7 +6,7 @@
@multiple-height: 30px;
// headers
@header-height: 4
6
px;
@header-height: 4
8
px;
// logo width
@logo-width: 36px;
...
...
src/layouts/logo/index.vue
浏览文件 @
a161bfa8
...
...
@@ -93,5 +93,13 @@
opacity
:
1
;
}
);
}
//
&
.dark
.logo-title
{
//
font-weight
:
400
;
//
}
&
.light
.logo-title
{
color
:
@
primary-color
;
}
}
</
style
>
src/settings/colorSetting.ts
浏览文件 @
a161bfa8
...
...
@@ -8,7 +8,7 @@ export const HEADER_PRESET_BG_COLOR_LIST: string[] = [
'#409eff'
,
'#4e73df'
,
'#e74c3c'
,
'#
f39c12
'
,
'#
24292e
'
,
'#394664'
,
'#001529'
,
];
...
...
@@ -17,6 +17,7 @@ export const HEADER_PRESET_BG_COLOR_LIST: string[] = [
export
const
SIDE_BAR_BG_COLOR_LIST
:
string
[]
=
[
'#273352'
,
'#ffffff'
,
'#191a23'
,
'#001529'
,
'#304156'
,
'#28333E'
,
...
...
src/utils/file/FileDownload.ts
浏览文件 @
a161bfa8
import
{
dataURLtoBlob
}
from
'./stream'
;
export
function
downloadByBase64
(
buf
:
string
,
filename
:
string
,
mime
?:
string
,
bom
?:
BlobPart
)
{
const
base64Buf
=
dataURLtoBlob
(
buf
);
downloadByData
(
base64Buf
,
filename
,
mime
,
bom
);
}
/**
*
根据后台接口文件流下载
*
Download according to the background interface file stream
* @param {*} data
* @param {*} filename
* @param {*} mime
...
...
@@ -27,7 +34,7 @@ export function downloadByData(data: BlobPart, filename: string, mime?: string,
}
/**
*
根据文件地址下载文件
*
Download file according to file address
* @param {*} sUrl
*/
export
function
downloadByUrl
({
...
...
@@ -43,7 +50,7 @@ export function downloadByUrl({
const
isSafari
=
window
.
navigator
.
userAgent
.
toLowerCase
().
indexOf
(
'safari'
)
>
-
1
;
if
(
/
(
iP
)
/g
.
test
(
window
.
navigator
.
userAgent
))
{
console
.
error
(
'
您的浏览器不支持下载
!'
);
console
.
error
(
'
Your browser does not support download
!'
);
return
false
;
}
if
(
isChrome
||
isSafari
)
{
...
...
src/utils/file/stream.ts
0 → 100644
浏览文件 @
a161bfa8
/**
* @description: base64 to blob
*/
export
function
dataURLtoBlob
(
base64Buf
:
string
):
Blob
{
const
arr
=
base64Buf
.
split
(
','
);
const
typeItem
=
arr
[
0
];
const
mime
=
typeItem
.
match
(
/:
(
.*
?)
;/
)
!
[
1
];
const
bstr
=
atob
(
arr
[
1
]);
let
n
=
bstr
.
length
;
const
u8arr
=
new
Uint8Array
(
n
);
while
(
n
--
)
{
u8arr
[
n
]
=
bstr
.
charCodeAt
(
n
);
}
return
new
Blob
([
u8arr
],
{
type
:
mime
});
}
src/views/demo/feat/download/imgBase64.ts
0 → 100644
浏览文件 @
a161bfa8
差异被折叠。
点击展开。
src/views/demo/feat/download/index.vue
浏览文件 @
a161bfa8
...
...
@@ -4,14 +4,16 @@
<a-button
type=
"primary"
class=
"my-4"
@
click=
"handleDownByData"
>
文件流下载
</a-button>
<a-alert
message=
"根据文件地址下载文件"
/>
<a-button
type=
"primary"
class=
"my-4"
@
click=
"handleDownloadByUrl"
>
文件地址下载
</a-button>
<a-alert
message=
"base64流下载"
/>
<a-button
type=
"primary"
class=
"my-4"
@
click=
"handleDownloadByBase64"
>
base64流下载
</a-button>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'vue'
;
import
{
downloadByUrl
,
downloadByData
}
from
'/@/utils/file/FileDownload'
;
import
{
downloadByUrl
,
downloadByData
,
downloadByBase64
}
from
'/@/utils/file/FileDownload'
;
import
imgBase64
from
'./imgBase64'
;
export
default
defineComponent
({
setup
()
{
function
handleDownByData
()
{
...
...
@@ -23,9 +25,14 @@
target
:
'_self'
,
});
}
function
handleDownloadByBase64
()
{
downloadByBase64
(
imgBase64
,
'logo.png'
);
}
return
{
handleDownloadByUrl
,
handleDownByData
,
handleDownloadByBase64
,
};
},
});
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论