Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JM_4-1
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
template admin
JM_4-1
Commits
33b16a6f
Commit
33b16a6f
authored
Jul 22, 2021
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: iframe err
parent
8e918acb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
75 deletions
+29
-75
sub-template.component.ts
src/app/common/sub-template/sub-template.component.ts
+15
-64
form.component.html
src/app/form/form.component.html
+14
-11
No files found.
src/app/common/sub-template/sub-template.component.ts
View file @
33b16a6f
...
...
@@ -11,17 +11,7 @@ import { NzMessageService, UploadXHRArgs, UploadFile } from 'ng-zorro-antd';
export
class
SubTemplateComponent
implements
OnDestroy
,
OnChanges
{
uploading
=
false
;
progress
=
0
;
@
Input
()
btnName
=
'
配置龙骨动画
'
;
@
Input
()
animaNames
=
[];
@
Input
()
skeJsonData
=
{};
@
Input
()
texJsonData
=
{};
@
Input
()
texPngData
=
{};
@
Output
()
save
=
new
EventEmitter
();
...
...
@@ -60,7 +50,7 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
@
ViewChild
(
'
iframe
'
,
{
static
:
true
})
iframe
:
ElementRef
;
isShowTemplate
=
false
;
constructor
(
private
appRef
:
ApplicationRef
,
private
nzMessageService
:
NzMessageService
,
private
sanitizer
:
DomSanitizer
)
{
constructor
(
private
el
:
ElementRef
,
private
appRef
:
ApplicationRef
,
private
nzMessageService
:
NzMessageService
,
private
sanitizer
:
DomSanitizer
)
{
this
.
uploadUrl
=
(
<
any
>
window
).
courseware
.
uploadUrl
();
this
.
uploadData
=
(
<
any
>
window
).
courseware
.
uploadData
();
...
...
@@ -72,10 +62,6 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
};
this
.
initListener
();
this
.
setUploadUrl
();
}
...
...
@@ -121,6 +107,11 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
}
this
.
refreshSafeUrl
();
this
.
initListener
();
this
.
setUploadUrl
();
}
...
...
@@ -184,11 +175,12 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
initListener
()
{
console
.
log
(
this
.
el
.
nativeElement
);
const
iframeContent
=
this
.
el
.
nativeElement
.
querySelector
(
'
#iframe
'
).
contentWindow
;
window
.
addEventListener
(
'
message
'
,
(
e
)
=>
{
let
msgData
=
e
.
data
;
...
...
@@ -208,32 +200,14 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
}
if
(
!
this
.
iframe
.
nativeElement
.
contentWindow
)
{
if
(
!
iframeContent
)
{
return
;
}
console
.
log
(
'
this.iframe.:
'
,
this
.
iframe
);
// var iframecont = document.getElementById('iframe')['contentWindow'];
console
.
log
(
'
iframecont.:
'
,
this
.
iframe
);
const
obj
=
{
contentObj
:
{}};
const
data
=
{
msg
:
'
success
'
,
data
:
JSON
.
stringify
(
this
.
_item
.
data
)};
// iframecont.postMessage({ action: 'getData', data: JSON.stringify(data) }, '*');
// const data = JSON.stringify( { action: 'getData'});
this
.
iframe
.
nativeElement
.
contentWindow
.
postMessage
(
{
action
:
'
getData
'
,
data
:
JSON
.
stringify
(
data
)
},
'
*
'
);
// iframecont.postMessage({ action: 'getData', data: null }, '*');
// setTimeout(() => {
// _this.frameLoaded = true;
// }, 300);
iframeContent
.
postMessage
(
{
action
:
'
getData
'
,
data
:
JSON
.
stringify
(
data
)
},
'
*
'
);
// this.iframe.nativeElement.contentWindow.postMessage( { action: 'getData', data: JSON.stringify(data) }, '*');
}
...
...
@@ -265,40 +239,17 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
if
(
msgData
.
action
===
"
getUpload
"
)
{
console
.
log
(
'
in getUpload
'
)
// if ( ! this.iframe.nativeElement.contentWindow) {
// return;
// }
const
protocolStr
=
document
.
location
.
protocol
;
// console.log('protocolStr:', protocolStr);
console
.
log
(
'
this.iframe:
'
,
this
.
iframe
);
console
.
log
(
"
this.iframe.nativeElement.air
"
,
this
.
iframe
.
nativeElement
.
air
);
this
.
iframe
.
nativeElement
.
contentWindow
.
postMessage
({
iframeContent
.
postMessage
({
action
:
'
getUpload
'
,
uploadUrl
:
this
.
uploadUrl
,
uploadData
:
this
.
uploadData
},
'
*
'
);
}
// if (msgData.action === "getUpload") {
// console.log("getUpload e: ", e);
// // this.iframe.nativeElement.contentWindow.postMessage( { action: 'getData', data: JSON.stringify(data) }, '*');
// this.iframe.nativeElement.contentWindow.air.uploadUrl = this.uploadUrl;
// this.iframe.nativeElement.contentWindow.air.uploadData = this.uploadData;
// // for (let i = 0; i < uploadCallbackQueue.length; i++) {
// // uploadCallbackQueue[i](msgData.uploadUrl, msgData.uploadData);
// // }
// this.iframe.nativeElement.contentWindow.air.getUploadCallback(this.uploadUrl, this.uploadData);
// return;
// }
// _this.checkIframeListener(msgData);
});
}
...
...
src/app/form/form.component.html
View file @
33b16a6f
...
...
@@ -19,7 +19,7 @@
</div>
<div
*
ngIf=
"item.sentenceArr.length < 4"
>
<div
*
ngIf=
"item.sentenceArr
&& item.sentenceArr
.length < 4"
>
<button
nz-button
nzType=
"dashed"
(
click
)="
addBtnClick
()"
style=
"width: 200px; height: 50px;"
>
<i
nz-icon
nzType=
"plus-circle"
nzTheme=
"outline"
></i>
...
...
@@ -28,18 +28,21 @@
</div>
<div
*
ngIf=
"item.templateArr"
>
<div
*
ngFor=
"let template of item.templateArr; let i = index"
style=
"margin-bottom: 10px;"
>
<div
*
ngFor=
"let template of item.templateArr; let i = index"
style=
"margin-bottom: 10px;"
>
<app-sub-template
[
item
]="
template
"
[
key
]="
i
+
1
"
(
save
)="
onSaveTemplate
($
event
,
i
)"
(
deleteFunc
)="
onDeleteTemplate
($
event
,
i
)"
>
</app-sub-template>
<app-sub-template
[
item
]="
template
"
[
key
]="
i
+
1
"
(
save
)="
onSaveTemplate
($
event
,
i
)"
(
deleteFunc
)="
onDeleteTemplate
($
event
,
i
)"
>
</app-sub-template>
</div>
</div>
<button
nz-button
nzType=
"primary"
(
click
)="
addSubTemplate
()"
style=
"border-radius: 0.5rem; border: 1px solid #ddd; margin-top: 15px;"
>
<i
nz-icon
nzType=
"plus"
nzTheme=
"outline"
></i>
...
...
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