Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
marketing
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
marketing-web
marketing
Commits
1a4a6297
You need to sign in or sign up before continuing.
Commit
1a4a6297
authored
May 07, 2022
by
crushh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: 下载文件类型
parent
09016b4a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
23 deletions
+3
-23
index.js
src/utils/index.js
+0
-14
links.vue
src/views/game/common/links.vue
+3
-9
No files found.
src/utils/index.js
View file @
1a4a6297
...
...
@@ -219,20 +219,6 @@ export const base64ToBlob = code => {
return
new
Blob
([
uInt8Array
],
{
type
:
contentType
});
};
//下载
export
const
downloadFile
=
(
fileName
,
content
)
=>
{
let
aLink
=
document
.
createElement
(
'a'
);
let
blob
=
base64ToBlob
(
content
);
//new Blob([content]);
let
evt
=
document
.
createEvent
(
'HTMLEvents'
);
evt
.
initEvent
(
'click'
,
true
,
true
);
//initEvent 不加后两个参数在FF下会报错 事件类型,是否冒泡,是否阻止浏览器的默认行为
fileName
=
fileName
.
replaceAll
(
'.'
,
'-'
);
aLink
.
download
=
fileName
;
aLink
.
href
=
URL
.
createObjectURL
(
blob
);
// aLink.dispatchEvent(evt);
//aLink.click()
aLink
.
dispatchEvent
(
new
MouseEvent
(
'click'
,
{
bubbles
:
true
,
cancelable
:
true
,
view
:
window
}));
//兼容火狐
};
export
const
sleep
=
delay
=>
{
let
start
=
new
Date
().
getTime
();
while
(
new
Date
().
getTime
()
-
start
<
delay
)
{
...
...
src/views/game/common/links.vue
View file @
1a4a6297
...
...
@@ -50,7 +50,7 @@
</
template
>
<
script
>
import
VueQr
from
'vue-qr'
;
import
{
formatDateTimeByType
,
downloadFile
}
from
'@/utils/index.js'
;
import
{
formatDateTimeByType
}
from
'@/utils/index.js'
;
import
{
generateMiniProgramLink
}
from
'@/service/api/gameApi.js'
;
import
{
api
as
viewerApi
}
from
'v-viewer'
;
import
'viewerjs/dist/viewer.css'
;
...
...
@@ -132,11 +132,6 @@ export default {
close
()
{
this
.
$emit
(
'update:show'
,
false
);
},
downloadImg
()
{
const
qrWrap
=
document
.
getElementById
(
'qrWrap'
);
const
qrImg
=
qrWrap
&&
qrWrap
.
childNodes
[
0
].
src
;
downloadFile
(
this
.
gameTypeName
+
'-'
+
this
.
obj
.
gameName
+
'-服务号-'
+
formatDateTimeByType
(
this
.
obj
.
gameStartTime
,
'yyyy-MM-dd-HH-mm-ss'
)
||
'游戏链接'
,
qrImg
);
},
onView
(
isH5
)
{
let
qrImg
=
''
;
if
(
isH5
)
{
...
...
@@ -161,13 +156,12 @@ export default {
const
x
=
new
XMLHttpRequest
();
x
.
open
(
'GET'
,
url
,
true
);
x
.
responseType
=
'blob'
;
fileName
=
fileName
.
replaceAll
(
'.'
,
'-'
);
x
.
onload
=
function
(
e
)
{
const
blob
=
new
Blob
([
x
.
response
]
,
{
type
:
'image/png'
}
);
const
blob
=
new
Blob
([
x
.
response
]);
let
url
=
window
.
URL
.
createObjectURL
(
blob
);
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
url
;
a
.
download
=
fileName
;
a
.
download
=
fileName
+
'.png'
;
a
.
click
();
};
x
.
send
();
...
...
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