Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ab6c3a

Browse files
committed
setup notification
1 parentbac9dc8 commit2ab6c3a

File tree

6 files changed

+74
-22
lines changed

6 files changed

+74
-22
lines changed

‎src/editor/commands.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,10 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
5757
testRunner=createTestRunner(config,{
5858
onSuccess:(payload:Payload)=>{
5959
// send test pass message back to client
60-
notify({message:'PASS'})
6160
webview.send({type:'TEST_PASS', payload})
62-
// update local storage
6361
},
6462
onFail:(payload:Payload,message:string)=>{
6563
// send test fail message back to client
66-
notify({message:`FAIL${message}`})
6764
webview.send({type:'TEST_FAIL', payload})
6865
},
6966
onError:(payload:Payload)=>{

‎typings/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ export interface MachineStateSchema {
8383
TestRunning:{}
8484
TestPass:{}
8585
TestFail:{}
86-
TestError:{}
8786
StepNext:{}
8887
LevelComplete:{}
8988
}

‎web-app/src/services/notify/index.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import{Notification}from'@alifd/next'
2+
3+
interfaceProps{
4+
key:string
5+
title:string
6+
content:string
7+
duration?:number
8+
onClose?:()=>void
9+
icon?:string
10+
}
11+
12+
Notification.config({
13+
placement:'topRight',
14+
})
15+
16+
constnotify=(props:Props)=>{
17+
Notification.open({
18+
key:props.key,
19+
title:props.title,
20+
content:props.content,
21+
duration:props.duration,
22+
onClose:props.onClose,
23+
})
24+
}
25+
26+
exportdefaultnotify
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
importeditorActionsfrom'./editor'
2+
importcommandActionsfrom'./command'
3+
importcontextActionsfrom'./context'
4+
importtestActionsfrom'./test'
5+
6+
constcreateActions=(editorSend:any)=>({
7+
...editorActions(editorSend),
8+
...commandActions,
9+
...contextActions,
10+
...testActions,
11+
})
12+
13+
exportdefaultcreateActions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import*asCRfrom'typings'
2+
import{ActionFunctionMap}from'xstate'
3+
importnotifyfrom'../../notify'
4+
5+
consttestActions:ActionFunctionMap<CR.MachineContext,CR.MachineEvent>={
6+
testPass(){
7+
notify({
8+
key:'test',
9+
title:'Success!',
10+
content:'',
11+
duration:1500,
12+
})
13+
},
14+
testFail(context,event){
15+
notify({
16+
key:'test',
17+
title:'Fail',
18+
content:'',
19+
duration:3000,
20+
})
21+
},
22+
}
23+
24+
exportdefaulttestActions

‎web-app/src/services/state/machine.ts

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
import*asCRfrom'typings'
22
import{assign,Machine,MachineOptions}from'xstate'
3-
importeditorActionsfrom'./actions/editor'
4-
importcommandActionsfrom'./actions/command'
5-
importcontextActionsfrom'./actions/context'
3+
importcreateActionsfrom'./actions'
64
import*asservicesfrom'./services'
75

86
constcreateOptions=({ editorSend}:any):MachineOptions<CR.MachineContext,CR.MachineEvent>=>({
97
activities:{},
10-
actions:{
11-
...editorActions(editorSend),
12-
...contextActions,
13-
...commandActions,
14-
},
8+
actions:createActions(editorSend),
159
guards:{},
1610
services:{},
1711
delays:{},
@@ -195,16 +189,16 @@ export const createMachine = (options: any) => {
195189
on:{
196190
TEST_PASS:{
197191
target:'TestPass',
198-
actions:['updateStepProgress'],
192+
actions:['updateStepProgress','testPass'],
193+
},
194+
TEST_FAIL:{
195+
target:'TestFail',
196+
actions:['testFail'],
197+
},
198+
TEST_ERROR:{
199+
target:'TestFail',
200+
actions:['testFail'],
199201
},
200-
TEST_FAIL:'TestFail',
201-
TEST_ERROR:'TestError',
202-
},
203-
},
204-
TestError:{
205-
onEntry:['testFail'],
206-
after:{
207-
0:'Normal',
208202
},
209203
},
210204
TestPass:{
@@ -214,7 +208,6 @@ export const createMachine = (options: any) => {
214208
},
215209
},
216210
TestFail:{
217-
onEntry:['testFail'],
218211
after:{
219212
0:'Normal',
220213
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp