|
|
@@ -1,16 +1,27 @@
|
|
|
import { YTAvoid } from "basic"
|
|
|
+import { HistoryApis } from "../Apis/HistoryApis"
|
|
|
+import { HistoryTimelineItem } from "../model/Index"
|
|
|
import { uRouter } from "../utils/RouterUtils"
|
|
|
|
|
|
|
|
|
@ComponentV2
|
|
|
export struct SecondView {
|
|
|
@Local safeTop: number = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
|
|
|
- @Local dataSource: Array<string> = new Array(18).fill('')
|
|
|
+ @Local dataSource: Array<HistoryTimelineItem> = []
|
|
|
|
|
|
router2HistoryToday(){
|
|
|
uRouter.router2HistoryToday()
|
|
|
}
|
|
|
|
|
|
+ // 获取战争历史时间线
|
|
|
+ async getHistoryTimeline() {
|
|
|
+ this.dataSource = await HistoryApis.getModernWarTimeline()
|
|
|
+ }
|
|
|
+
|
|
|
+ aboutToAppear(): void {
|
|
|
+ this.getHistoryTimeline()
|
|
|
+ }
|
|
|
+
|
|
|
build() {
|
|
|
Column(){
|
|
|
Column({space: 20}){
|
|
|
@@ -36,7 +47,7 @@ export struct SecondView {
|
|
|
List({space: 17}){
|
|
|
Repeat(this.dataSource)
|
|
|
.each((i) => {
|
|
|
- HistoryItem()
|
|
|
+ HistoryItem({data: i.item})
|
|
|
})
|
|
|
}
|
|
|
.width("100%")
|
|
|
@@ -56,7 +67,7 @@ export struct SecondView {
|
|
|
@ComponentV2
|
|
|
struct HistoryItem{
|
|
|
@Local h: number = 120
|
|
|
-
|
|
|
+ @Param @Require data: HistoryTimelineItem
|
|
|
|
|
|
build() {
|
|
|
Column({space: 5}){
|
|
|
@@ -65,7 +76,7 @@ struct HistoryItem{
|
|
|
.width(35)
|
|
|
.aspectRatio(1)
|
|
|
|
|
|
- Text('1840')
|
|
|
+ Text(this.data.tagName)
|
|
|
.fontSize(14)
|
|
|
.fontWeight(400)
|
|
|
.fontColor('#000000')
|
|
|
@@ -88,13 +99,13 @@ struct HistoryItem{
|
|
|
.width(23)
|
|
|
.aspectRatio(1)
|
|
|
|
|
|
- Text('鸦片战争')
|
|
|
+ Text(this.data.title)
|
|
|
.fontSize(16)
|
|
|
.fontWeight(500)
|
|
|
.fontColor('#333333')
|
|
|
}
|
|
|
|
|
|
- Text('中国近代史的开端,清政府战败,签订《南京条约》')
|
|
|
+ Text(this.data.content.replace(/<[^>]*>/g, ''))
|
|
|
.fontSize(14)
|
|
|
.fontWeight(400)
|
|
|
.width("100%")
|
|
|
@@ -106,7 +117,7 @@ struct HistoryItem{
|
|
|
.backgroundColor(Color.White)
|
|
|
.alignItems(HorizontalAlign.Start)
|
|
|
.constraintSize({minHeight: '115'})
|
|
|
- .padding({ top: 10, left: 3, right: 3, bottom: 10 })
|
|
|
+ .padding({ top: 10, left: 10, right: 3, bottom: 10 })
|
|
|
}
|
|
|
}
|
|
|
.width("100%")
|