Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
MobileInternet Client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobileInternetProject
MobileInternet Client
Commits
ac06cd9d
Commit
ac06cd9d
authored
1 month ago
by
张 昊翔
Browse files
Options
Downloads
Patches
Plain Diff
feat: 添加了多线程功能
parent
1e028451
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
entry/src/main/ets/pages/Index.ets
+25
-2
25 additions, 2 deletions
entry/src/main/ets/pages/Index.ets
entry/src/main/ets/pages/LocalPage.ets
+23
-2
23 additions, 2 deletions
entry/src/main/ets/pages/LocalPage.ets
entry/src/main/ets/public/WebAPI.ets
+32
-0
32 additions, 0 deletions
entry/src/main/ets/public/WebAPI.ets
with
80 additions
and
4 deletions
entry/src/main/ets/pages/Index.ets
+
25
−
2
View file @
ac06cd9d
...
@@ -4,6 +4,20 @@ import {LocalPage} from '../pages/LocalPage'
...
@@ -4,6 +4,20 @@ import {LocalPage} from '../pages/LocalPage'
import
{
Login
}
from
'../pages/LoginPage'
import
{
Login
}
from
'../pages/LoginPage'
import
webAPI
from
'../public/WebAPI'
;
import
webAPI
from
'../public/WebAPI'
;
import
TodoItemModel
from
'../viewmodel/TodoItemModel'
;
import
TodoItemModel
from
'../viewmodel/TodoItemModel'
;
import
{
taskpool
}
from
'@kit.ArkTS'
;
/*
并发获取完成数量和列表
*/
@
Concurrent
async
function
showCompletedNum
():
Promise
<
number
>
{
return
await
webAPI
.
getDone
()
}
@
Concurrent
async
function
showTodoList
():
Promise
<
Array
<
TodoItemModel
>>
{
return
await
webAPI
.
getItems
()
}
@
Entry
@
Entry
@
Component
@
Component
...
@@ -11,6 +25,8 @@ struct Index {
...
@@ -11,6 +25,8 @@ struct Index {
@
State
state
:
number
=
0
@
State
state
:
number
=
0
@
State
totalTasks
:
Array
<
TodoItemModel
>
=
[]
//待获取的todolist数据
@
State
totalTasks
:
Array
<
TodoItemModel
>
=
[]
//待获取的todolist数据
@
State
totalTaskCnt
:
number
=
0
@
State
completedTaskCnt
:
number
=
0
@
State
currentIndex
:
number
=
0
;
//导航栏下标
@
State
currentIndex
:
number
=
0
;
//导航栏下标
private
tabsController
:
TabsController
=
new
TabsController
();
private
tabsController
:
TabsController
=
new
TabsController
();
...
@@ -43,13 +59,20 @@ struct Index {
...
@@ -43,13 +59,20 @@ struct Index {
Column
()
{
Column
()
{
Tabs
({
barPosition
:
BarPosition
.
End
,
controller
:
this
.
tabsController
})
{
Tabs
({
barPosition
:
BarPosition
.
End
,
controller
:
this
.
tabsController
})
{
TabContent
()
{
TabContent
()
{
LocalPage({state:this.state, totalTasks:this.totalTasks})
LocalPage
({
state
:
this
.
state
,
totalTasks
:
this
.
totalTasks
,
totalTaskCnt
:
this
.
totalTaskCnt
,
completedTaskCnt
:
this
.
completedTaskCnt
})
}
}
.
onWillShow
(
async
()
=>
{
.
onWillShow
(
async
()
=>
{
// 在显示之前,更新待办事项状态
// 在显示之前,更新待办事项状态
if
(
webAPI
.
token
==
''
)
this
.
state
=
0
if
(
webAPI
.
token
==
''
)
this
.
state
=
0
else
{
else
{
this.totalTasks = await webAPI.getItems()
//this.totalTasks = await webAPI.getItems()
taskpool
.
execute
(
showCompletedNum
)
.
then
((
ret
)
=>
{
this
.
completedTaskCnt
=
ret
as
number
})
taskpool
.
execute
(
showTodoList
)
.
then
((
ret
)
=>
{
this
.
totalTasks
=
ret
as
Array
<
TodoItemModel
>
})
if
(
this
.
totalTasks
.
length
==
0
)
this
.
state
=
1
if
(
this
.
totalTasks
.
length
==
0
)
this
.
state
=
1
else
this
.
state
=
2
else
this
.
state
=
2
}
}
...
...
This diff is collapsed.
Click to expand it.
entry/src/main/ets/pages/LocalPage.ets
+
23
−
2
View file @
ac06cd9d
...
@@ -9,8 +9,10 @@ import webAPI from '../public/WebAPI';
...
@@ -9,8 +9,10 @@ import webAPI from '../public/WebAPI';
@Component
@Component
export struct LocalPage {
export struct LocalPage {
@Link state:number
@Link state:
number
@Link totalTasks: Array<TodoItemModel>
@Link totalTasks: Array<TodoItemModel>
@Link totalTaskCnt: number
@Link completedTaskCnt: number
@Provide('localPageStack') LocalPageStack: NavPathStack = new NavPathStack(); //router
@Provide('localPageStack') LocalPageStack: NavPathStack = new NavPathStack(); //router
@Builder
@Builder
...
@@ -72,6 +74,25 @@ export struct LocalPage {
...
@@ -72,6 +74,25 @@ export struct LocalPage {
.fontColor('grey')
.fontColor('grey')
}
}
else {
else {
Column() { //已完成和未完成任务数量
Row() {
Text('已完成: ' + this.completedTaskCnt)
.margin({top: 10})
.fontSize(20)
.fontColor('grey')
.width('50%')
Text('未完成: ' + (this.totalTaskCnt - this.completedTaskCnt))
.margin({top: 10})
.fontSize(20)
.fontColor('grey')
.width('50%')
}
}
.align(Alignment.Top)
.margin({top: 10})
.width('100%')
.height('15%')
.backgroundColor($r("app.color.grey"))
Scroll() { //事项
Scroll() { //事项
Column({space: CommonConstants.column_space}) {
Column({space: CommonConstants.column_space}) {
ForEach(this.totalTasks, (item: TodoItemModel, index: number) => {
ForEach(this.totalTasks, (item: TodoItemModel, index: number) => {
...
@@ -88,7 +109,7 @@ export struct LocalPage {
...
@@ -88,7 +109,7 @@ export struct LocalPage {
.align(Alignment.Top)
.align(Alignment.Top)
.margin({top: 10})
.margin({top: 10})
.width('100%')
.width('100%')
.height('
10
0%')
.height('
8
0%')
.backgroundColor($r("app.color.grey"))
.backgroundColor($r("app.color.grey"))
.scrollBar(BarState.On)
.scrollBar(BarState.On)
}
}
...
...
This diff is collapsed.
Click to expand it.
entry/src/main/ets/public/WebAPI.ets
+
32
−
0
View file @
ac06cd9d
...
@@ -200,4 +200,36 @@ export default class webAPI {
...
@@ -200,4 +200,36 @@ export default class webAPI {
}
}
return result
return result
}
}
static async getDone(): Promise<number> {
/*
获取当前用户已完成的事项数目
*/
if(webAPI.token == '') {
promptAction.showToast({ message: '未登录,获取完成事项数目失败' })
return -1
}
let httpRequest = http.createHttp()
try {
const data = await httpRequest.request(`localhost:8080/api/todolist/${webAPI.userId}/count`, {
method: http.RequestMethod.GET,
header: {
'token': webAPI.token
}
});
if (data.responseCode === 200) {
const resultJson: httpResult = JSON.parse(data.result + '')
let resultValue: number = parseInt(resultJson.result);
return resultValue
}
// for debug
// console.log(String(JSON.stringify(data)))
} catch (error) {
console.error('Login API error:', error)
} finally {
httpRequest.destroy()
}
return -1
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment