Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
najiu-admin-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
najiu-frontend
najiu-admin-template
Commits
db3092db
Commit
db3092db
authored
Nov 13, 2020
by
vben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add file download demo
parent
1d45617e
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
0 deletions
+54
-0
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
registerGlobComp.ts
src/components/registerGlobComp.ts
+2
-0
feat.ts
src/router/menus/modules/demo/feat.ts
+10
-0
feat.ts
src/router/routes/modules/demo/feat.ts
+8
-0
FileDownload.ts
src/utils/file/FileDownload.ts
+1
-0
index.vue
src/views/demo/feat/download/index.vue
+32
-0
No files found.
CHANGELOG.zh_CN.md
View file @
db3092db
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
-
菜单新增 tag 显示,支持 4 中类型颜色及 dot 圆点显示
-
菜单新增 tag 显示,支持 4 中类型颜色及 dot 圆点显示
-
新增菜单及顶栏颜色选择配色
-
新增菜单及顶栏颜色选择配色
-
增加示例结果页
-
增加示例结果页
-
新增文件下载示例
### ⚡ Wip
### ⚡ Wip
...
...
src/components/registerGlobComp.ts
View file @
db3092db
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
// Optional
// Optional
Select
,
Select
,
Alert
,
Checkbox
,
Checkbox
,
DatePicker
,
DatePicker
,
Radio
,
Radio
,
...
@@ -48,6 +49,7 @@ export function registerGlobComp() {
...
@@ -48,6 +49,7 @@ export function registerGlobComp() {
// If you don’t need it, you can delete it
// If you don’t need it, you can delete it
getApp
()
getApp
()
.
use
(
Select
)
.
use
(
Select
)
.
use
(
Alert
)
.
use
(
Checkbox
)
.
use
(
Checkbox
)
.
use
(
DatePicker
)
.
use
(
DatePicker
)
.
use
(
Radio
)
.
use
(
Radio
)
...
...
src/router/menus/modules/demo/feat.ts
View file @
db3092db
...
@@ -4,6 +4,9 @@ const menu: MenuModule = {
...
@@ -4,6 +4,9 @@ const menu: MenuModule = {
menu
:
{
menu
:
{
name
:
'
功能
'
,
name
:
'
功能
'
,
path
:
'
/feat
'
,
path
:
'
/feat
'
,
tag
:
{
dot
:
true
,
},
children
:
[
children
:
[
{
{
path
:
'
icon
'
,
path
:
'
icon
'
,
...
@@ -17,6 +20,13 @@ const menu: MenuModule = {
...
@@ -17,6 +20,13 @@ const menu: MenuModule = {
path
:
'
context-menu
'
,
path
:
'
context-menu
'
,
name
:
'
右键菜单
'
,
name
:
'
右键菜单
'
,
},
},
{
path
:
'
download
'
,
name
:
'
文件下载
'
,
tag
:
{
content
:
'
new
'
,
},
},
{
{
path
:
'
click-out-side
'
,
path
:
'
click-out-side
'
,
name
:
'
ClickOutSide
'
,
name
:
'
ClickOutSide
'
,
...
...
src/router/routes/modules/demo/feat.ts
View file @
db3092db
...
@@ -40,6 +40,14 @@ const feat: AppRouteModule = {
...
@@ -40,6 +40,14 @@ const feat: AppRouteModule = {
title
:
'
右键菜单
'
,
title
:
'
右键菜单
'
,
},
},
},
},
{
path
:
'
/download
'
,
name
:
'
DownLoadDemo
'
,
component
:
()
=>
import
(
'
/@/views/demo/feat/download/index.vue
'
),
meta
:
{
title
:
'
文件下载
'
,
},
},
{
{
path
:
'
/click-out-side
'
,
path
:
'
/click-out-side
'
,
name
:
'
ClickOutSideDemo
'
,
name
:
'
ClickOutSideDemo
'
,
...
...
src/utils/file/FileDownload.ts
View file @
db3092db
...
@@ -25,6 +25,7 @@ export function downloadByData(data: BlobPart, filename: string, mime?: string,
...
@@ -25,6 +25,7 @@ export function downloadByData(data: BlobPart, filename: string, mime?: string,
window
.
URL
.
revokeObjectURL
(
blobURL
);
window
.
URL
.
revokeObjectURL
(
blobURL
);
}
}
}
}
/**
/**
* 根据文件地址下载文件
* 根据文件地址下载文件
* @param {*} sUrl
* @param {*} sUrl
...
...
src/views/demo/feat/download/index.vue
0 → 100644
View file @
db3092db
<
template
>
<div
class=
"m-5 demo-box"
>
<a-alert
message=
"根据后台接口文件流下载"
/>
<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>
</div>
</
template
>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'
vue
'
;
import
{
downloadByUrl
,
downloadByData
}
from
'
/@/utils/file/FileDownload
'
;
export
default
defineComponent
({
setup
()
{
function
handleDownByData
()
{
downloadByData
(
'
text content
'
,
'
testName.txt
'
);
}
function
handleDownloadByUrl
()
{
downloadByUrl
({
url
:
'
https://codeload.github.com/anncwb/vue-vben-admin-doc/zip/master
'
,
target
:
'
_self
'
,
});
}
return
{
handleDownloadByUrl
,
handleDownByData
,
};
},
});
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment