Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SSIWB2504
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
SSIWB2504
Commits
6097235f
Commit
6097235f
authored
Aug 03, 2025
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
题目调整完成
parent
761b51d8
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
403 additions
and
603 deletions
+403
-603
ComponentBase.ts
src/app/form/ComponentBase.ts
+117
-0
form.component.css
src/app/form/form.component.css
+27
-0
form.component.html
src/app/form/form.component.html
+179
-426
form.component.ts
src/app/form/form.component.ts
+78
-175
play.component.ts
src/app/play/play.component.ts
+2
-2
No files found.
src/app/form/ComponentBase.ts
0 → 100644
View file @
6097235f
import
{
ApplicationRef
,
ChangeDetectorRef
,
ElementRef
,
ViewChild
}
from
"
@angular/core
"
;
export
class
ComponentBase
{
// 储存数据用
saveKey
=
""
;
// 储存对象
item
:
any
=
{};
ngOnChanges
()
{
}
ngOnDestroy
()
{
}
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
)
{
}
ngOnInit
()
{
// 获取存储的数据
(
<
any
>
window
).
courseware
.
getData
((
data
)
=>
{
if
(
data
)
{
this
.
item
=
data
;
this
.
itemStr
=
JSON
.
stringify
(
this
.
item
,
null
,
4
).
trim
();
}
this
.
init
();
this
.
changeDetectorRef
.
markForCheck
();
this
.
changeDetectorRef
.
detectChanges
();
this
.
refresh
();
},
this
.
saveKey
);
}
@
ViewChild
(
"
itemTextarea
"
,
{
static
:
true
})
itemTextarea
:
ElementRef
;
copyData
()
{
this
.
itemTextarea
.
nativeElement
.
select
();
document
.
execCommand
(
"
copy
"
);
}
/**
* 储存图片数据
* @param e
*/
// onAssetUploadSuccess(e: any, ...key: Array<string>) {
// let item = this.item;
// for (let i = 0; i < key.length; i++) {
// if (i + 1 == key.length) {
// if (key[i] == "audio") {
// let sp = e.url.split(".mp3");
// let u = sp[0] + "_l.mp3";
// item[key[i]] = u;
// item["audioName"] = e.name || "";
// } else {
// item[key[i]] = e.url;
// }
// this.save();
// return;
// }
// item = item[key[i]];
// }
// }
/**
* 储存图片数据
* @param e
*/
onImageUploadSuccess
(
e
,
key
,
it
=
this
.
item
)
{
it
[
key
]
=
e
.
url
;
this
.
save
();
}
/**
* 储存音频数据
* @param e
*/
onAudioUploadSuccess
(
e
,
key
,
it
=
this
.
item
,
audioName
)
{
let
url
=
e
.
url
;
it
[
key
]
=
url
;
it
[
audioName
]
=
e
.
audioName
||
""
;
console
.
log
(
JSON
.
stringify
(
e
));
this
.
save
();
}
save
()
{
(
<
any
>
window
).
courseware
.
setData
(
this
.
item
,
null
,
this
.
saveKey
);
this
.
itemStr
=
JSON
.
stringify
(
this
.
item
,
null
,
4
).
trim
();
this
.
refresh
();
console
.
log
(
'
this.item =
'
+
JSON
.
stringify
(
this
.
item
));
}
itemStr
=
""
;
load
()
{
this
.
itemStr
=
this
.
itemTextarea
.
nativeElement
.
value
;
if
(
this
.
isJSON
(
this
.
itemStr
))
{
this
.
item
=
JSON
.
parse
(
this
.
itemStr
);
this
.
init
();
this
.
changeDetectorRef
.
markForCheck
();
this
.
changeDetectorRef
.
detectChanges
();
this
.
refresh
();
}
}
isJSON
(
str
)
{
if
(
typeof
str
==
'
string
'
)
{
try
{
var
obj
=
JSON
.
parse
(
str
);
if
(
typeof
obj
==
'
object
'
&&
obj
)
{
return
true
;
}
return
false
;
}
catch
(
e
)
{
return
false
;
}
}
return
false
;
}
/**
* 刷新 渲染页面
*/
refresh
()
{
setTimeout
(()
=>
{
this
.
appRef
.
tick
();
},
1
);
}
init
()
{
}
}
src/app/form/form.component.css
View file @
6097235f
...
@@ -33,3 +33,30 @@
...
@@ -33,3 +33,30 @@
padding
:
10px
;
padding
:
10px
;
margin
:
10px
;
margin
:
10px
;
}
}
.button-right
{
border-style
:
dotted
;
border-color
:
rgb
(
42
,
142
,
72
);
width
:
100px
;
height
:
50px
;
color
:
rgb
(
42
,
142
,
72
);
background-color
:
white
;
}
.button-wrong
{
border-style
:
dotted
;
border-color
:
rgb
(
180
,
0
,
0
);
width
:
100px
;
height
:
50px
;
color
:
rgb
(
180
,
0
,
0
);
background-color
:
white
;
}
.button-disable
{
border-style
:
dotted
;
border-color
:
black
;
width
:
100px
;
height
:
50px
;
color
:
black
;
background-color
:
white
;
}
\ No newline at end of file
src/app/form/form.component.html
View file @
6097235f
This diff is collapsed.
Click to expand it.
src/app/form/form.component.ts
View file @
6097235f
import
{
import
{
Component
,
EventEmitter
,
Input
,
OnDestroy
,
OnChanges
,
OnInit
,
Output
,
ApplicationRef
,
ChangeDetectorRef
}
from
'
@angular/core
'
;
Component
,
import
{
JsonPipe
}
from
'
@angular/common
'
;
EventEmitter
,
import
{
ComponentBase
}
from
'
./ComponentBase
'
;
Input
,
OnDestroy
,
OnChanges
,
OnInit
,
Output
,
ApplicationRef
,
ChangeDetectorRef
,
}
from
"
@angular/core
"
;
import
{
JsonPipe
}
from
"
@angular/common
"
;
import
{
log
}
from
"
ng-zorro-antd
"
;
@
Component
({
@
Component
({
selector
:
"
app-form
"
,
selector
:
'
app-form
'
,
templateUrl
:
"
./form.component.html
"
,
templateUrl
:
'
./form.component.html
'
,
styleUrls
:
[
"
./form.component.css
"
],
styleUrls
:
[
'
./form.component.css
'
]
})
})
export
class
FormComponent
implements
OnInit
,
OnChanges
,
OnDestroy
{
export
class
FormComponent
extends
ComponentBase
implements
OnInit
,
OnChanges
,
OnDestroy
{
// 储存数据用
// 储存数据用
saveKey
=
"
ss
iwb
2501
"
;
saveKey
=
"
ss
app
2501
"
;
// 储存对象
// 储存对象
item
;
item
:
any
=
{
type
=
0
;
score
:
0
,
dataType
;
title
:
''
,
questionText
:
""
,
// 样式选项
questionType
:
"
read
"
,
styles
=
[
questionTextAudio
:
""
,
{
id
:
0
,
name
:
'
样式1
'
,
image
:
'
http://staging-teach.cdn.ireadabc.com/b41bf63c28c65bc46c3a1ae77e70cb75.png
'
},
bgAudio
:
""
,
{
id
:
1
,
name
:
'
样式2
'
,
image
:
'
http://staging-teach.cdn.ireadabc.com/49f2cb0d2b76bf866788a2c0244af69e.png
'
}
questions
:
[],
];
// 字母索引数组
singleLetterIndexes
=
[
0
,
1
,
2
,
3
,
4
];
// 对应character_0到character_4
doubleLetterIndexes
=
[
0
,
1
,
2
,
3
,
4
];
// 对应character_00到character_44
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
)
{}
createShell
()
{
this
.
item
.
wordList
.
push
({
word
:
""
,
audio
:
""
,
backWord
:
""
,
backWordAudio
:
""
,
});
this
.
save
();
}
removeShell
(
idx
)
{
this
.
item
.
wordList
.
splice
(
idx
,
1
);
this
.
save
();
}
ngOnInit
()
{
this
.
item
=
{
title
:
""
,
audio_title
:
""
};
this
.
dataType
=
{
single
:
{
words
:
""
,
wordArr
:
[]
},
single_audio
:
""
,
single_show
:
true
,
character_00
:
{
words
:
""
,
wordArr
:
[]
},
character_11
:
{
words
:
""
,
wordArr
:
[]
},
character_22
:
{
words
:
""
,
wordArr
:
[]
},
character_33
:
{
words
:
""
,
wordArr
:
[]
},
character_44
:
{
words
:
""
,
wordArr
:
[]
},
character_0
:
{
words
:
""
,
wordArr
:
[]
},
character_1
:
{
words
:
""
,
wordArr
:
[]
},
character_2
:
{
words
:
""
,
wordArr
:
[]
},
character_3
:
{
words
:
""
,
wordArr
:
[]
},
character_4
:
{
words
:
""
,
wordArr
:
[]
},
character_0_show
:
true
,
character_1_show
:
true
,
character_2_show
:
true
,
character_3_show
:
true
,
character_4_show
:
true
,
character_00_show
:
true
,
character_11_show
:
true
,
character_22_show
:
true
,
character_33_show
:
true
,
character_44_show
:
true
,
};
};
this
.
type
=
0
;
// 获取存储的数据
(
<
any
>
window
).
courseware
.
getData
((
data
)
=>
{
if
(
data
)
{
this
.
item
=
data
;
}
this
.
init
();
this
.
changeDetectorRef
.
markForCheck
();
this
.
changeDetectorRef
.
detectChanges
();
this
.
refresh
();
},
this
.
saveKey
);
}
ngOnChanges
()
{}
ngOnDestroy
()
{}
// item: any = {
// title: '幸运大转盘',
init
()
{
// questionText: "亲爱的小玩家,游戏马上就要开始啦!请动动手指转动转盘,当转盘停止,注意观察指针指向的魔法图片,并大声说出魔法咒语,魔法咒语正确,你就可以获得一张魔法卡牌。 游戏结束后,根据获得的魔法卡牌数量,你将获得相应的能量石奖励!开始挑战吧!",
if
(
this
.
item
.
type
)
{
// questionTextAudio: "http://staging-teach.cdn.ireadabc.com/18ebee93b3eabcd55649a01366431af7.mp3",
this
.
type
=
this
.
item
.
type
;
// questions: [],
}
// };
// 加载数据
if
(
this
.
item
.
dataType
)
{
isVisible
=
false
;
this
.
dataType
=
this
.
item
.
dataType
;
deleteTitle
=
"
是否删除题目
"
;
}
deleteCallback
=
function
()
{
};
}
openDelete
(
title
,
callback
)
{
this
.
deleteCallback
=
callback
;
/**
this
.
deleteTitle
=
title
;
* 储存图片数据
this
.
isVisible
=
true
;
* @param e
}
*/
handleCancel
()
{
onImageUploadSuccess
(
e
,
key
)
{
this
.
isVisible
=
false
;
this
.
item
[
key
]
=
e
.
url
;
}
this
.
save
();
handleOk
()
{
}
this
.
deleteCallback
&&
this
.
deleteCallback
();
this
.
handleCancel
();
/**
}
* 储存音频数据
* @param e
addQuestion
()
{
*/
this
.
item
.
questions
.
push
({
onAudioUploadSuccess
(
e
,
key
)
{
type
:
'
img
'
,
this
.
item
[
key
]
=
e
.
url
;
imgSize
:
'
big
'
,
// 默认大图片
this
.
save
();
audio
:
''
,
}
image
:
''
,
time
:
null
,
onAudioUploadSuccessByItem
(
e
,
it
,
key
)
{
// word: '',
it
[
key
]
=
e
.
url
;
audioName
:
""
,
});
this
.
save
();
this
.
save
();
}
}
onWordAudioUploadSuccess
(
e
,
idx
)
{
removeQuestion
(
idx
)
{
this
.
item
.
wordList
[
idx
].
audio
=
e
.
url
;
this
.
openDelete
(
"
确定删除题目?
"
,
()
=>
{
this
.
item
.
questions
.
splice
(
idx
,
1
);
this
.
save
();
this
.
save
();
})
}
}
copyQuestion
(
idx
)
{
onBackWordAudioUploadSuccess
(
e
,
idx
)
{
let
data
=
this
.
item
.
questions
[
idx
]
this
.
item
.
wordList
[
idx
].
backWordAudio
=
e
.
url
;
this
.
item
.
questions
.
push
(
JSON
.
parse
(
JSON
.
stringify
(
data
)))
;
this
.
save
();
this
.
save
();
}
}
deleteBgAudio
()
{
onUpWordClicked
(
key
,
index
)
{
this
.
item
.
bgAudio
=
""
;
if
(
this
.
dataType
[
key
].
wordArr
[
index
].
type
==
"
normal
"
)
{
this
.
item
.
audioBgName
=
""
;
this
.
dataType
[
key
].
wordArr
[
index
].
type
=
"
red
"
;
}
else
{
this
.
dataType
[
key
].
wordArr
[
index
].
type
=
"
normal
"
;
}
this
.
save
();
this
.
save
();
}
}
// addOption(idx) {
onSaveWord
(
key
)
{
// if (this.item.questions[idx].options.length == 4) return;
// console.log(this.dataType);
// this.item.questions[idx].options.push({
// text: '',
let
res
=
[];
// audio: '',
let
words
=
this
.
dataType
[
key
].
words
.
split
(
""
);
// image: '',
for
(
let
w
of
words
)
{
// word: '',
res
.
push
({
word
:
w
,
type
:
"
normal
"
});
// });
}
// this.save();
this
.
dataType
[
key
].
wordArr
=
res
;
// }
this
.
save
();
// removeOption(idx, n) {
}
// this.openDelete("确定删除选项?", () => {
// this.item.questions[idx].options.splice(n, 1);
/**
// this.save();
* 储存数据
// })
*/
// }
save
()
{
ngChange
()
{
this
.
item
.
type
=
this
.
type
;
this
.
item
.
dataType
=
this
.
dataType
;
(
<
any
>
window
).
courseware
.
setData
(
this
.
item
,
null
,
this
.
saveKey
);
this
.
refresh
();
console
.
log
(
"
this.item =
"
+
JSON
.
stringify
(
this
.
item
));
}
/**
* 刷新 渲染页面
*/
refresh
()
{
setTimeout
(()
=>
{
this
.
appRef
.
tick
();
},
1
);
}
onSetType
()
{
this
.
save
();
this
.
save
();
}
}
}
}
src/app/play/play.component.ts
View file @
6097235f
...
@@ -342,8 +342,8 @@ export class PlayComponent implements OnInit, OnDestroy {
...
@@ -342,8 +342,8 @@ export class PlayComponent implements OnInit, OnDestroy {
initBackground
()
{
initBackground
()
{
// 创建背景元素
// 创建背景元素
var
element
=
this
.
g_cartoon
.
createCartoonElement
(
`background`
,
"
MySprite
"
)
var
element
=
this
.
g_cartoon
.
createCartoonElement
(
`background`
,
"
MySprite
"
)
// 初始化背景图像,使用resources.js中的bg资源
// 初始化背景图像,使用resources.js中的b
ei_jin
g资源
element
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
"
bg
"
));
element
.
ref
.
init
(
this
.
g_cartoon
.
images
.
get
(
"
b
ei_jin
g
"
));
// 计算背景缩放比例,确保背景能够覆盖整个画布
// 计算背景缩放比例,确保背景能够覆盖整个画布
// 使用g_mapScale作为基础缩放比例,确保与其他元素保持一致的缩放
// 使用g_mapScale作为基础缩放比例,确保与其他元素保持一致的缩放
...
...
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