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
882b7a87
Commit
882b7a87
authored
May 07, 2022
by
crushh
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'bugfix/下载' into dev
parents
f2a1227e
1a4a6297
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 @
882b7a87
...
...
@@ -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 @
882b7a87
...
...
@@ -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