@jetthai/cuora 1.0.158 → 1.0.159
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/package.json +1 -1
- package/src/machine/index.js +0 -2
- package/src/machine/side.js +16 -32
- package/src/machine/side_v2.js +0 -159
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.0.159](https://github.com/jetthai/cuora-module/compare/v1.0.158...v1.0.159) (2022-08-11)
|
|
6
|
+
|
|
5
7
|
### [1.0.158](https://github.com/jetthai/cuora-module/compare/v1.0.157...v1.0.158) (2022-08-11)
|
|
6
8
|
|
|
7
9
|
### [1.0.157](https://github.com/jetthai/cuora-module/compare/v1.0.156...v1.0.157) (2022-08-11)
|
package/package.json
CHANGED
package/src/machine/index.js
CHANGED
|
@@ -15,7 +15,6 @@ import reward_fc from './reward_fc'
|
|
|
15
15
|
import reward from './reward'
|
|
16
16
|
import setting from './setting'
|
|
17
17
|
import side from './side'
|
|
18
|
-
import side_v2 from './side_v2'
|
|
19
18
|
import user_info from './user_info'
|
|
20
19
|
import user_sign_up from './user_sign_up'
|
|
21
20
|
import user_reset_password from './user_reset_password'
|
|
@@ -49,7 +48,6 @@ export default {
|
|
|
49
48
|
reward_fc,
|
|
50
49
|
setting,
|
|
51
50
|
side,
|
|
52
|
-
side_v2,
|
|
53
51
|
user_info,
|
|
54
52
|
user_sign_up,
|
|
55
53
|
user_reset_password,
|
package/src/machine/side.js
CHANGED
|
@@ -28,52 +28,28 @@ export default function (request) {
|
|
|
28
28
|
initial: 'home',
|
|
29
29
|
states: {
|
|
30
30
|
home: {
|
|
31
|
-
entry:
|
|
31
|
+
entry: createSideAction('home'),
|
|
32
32
|
},
|
|
33
33
|
favorite: {
|
|
34
|
-
entry:
|
|
34
|
+
entry: createSideAction('favorite'),
|
|
35
35
|
},
|
|
36
36
|
hot: {
|
|
37
|
-
entry:
|
|
38
|
-
if (!context.roomHistory.some((item) => item.id === context.menu.hot.id)) {
|
|
39
|
-
return { room: context.menu['hot'] }
|
|
40
|
-
}
|
|
41
|
-
}),
|
|
37
|
+
entry: createSideAction('hot'),
|
|
42
38
|
},
|
|
43
39
|
new: {
|
|
44
|
-
entry:
|
|
45
|
-
if (!context.roomHistory.some((item) => item.id === context.menu.new.id)) {
|
|
46
|
-
return { room: context.menu['new'] }
|
|
47
|
-
}
|
|
48
|
-
}),
|
|
40
|
+
entry: createSideAction('new'),
|
|
49
41
|
},
|
|
50
42
|
slot: {
|
|
51
|
-
entry:
|
|
52
|
-
if (!context.roomHistory.some((item) => item.id === context.menu.slot.id)) {
|
|
53
|
-
return { room: context.menu['slot'] }
|
|
54
|
-
}
|
|
55
|
-
}),
|
|
43
|
+
entry: createSideAction('slot'),
|
|
56
44
|
},
|
|
57
45
|
fish: {
|
|
58
|
-
entry:
|
|
59
|
-
if (!context.roomHistory.some((item) => item.id === context.menu.fish.id)) {
|
|
60
|
-
return { room: context.menu['fish'] }
|
|
61
|
-
}
|
|
62
|
-
}),
|
|
46
|
+
entry: createSideAction('fish'),
|
|
63
47
|
},
|
|
64
48
|
arcade: {
|
|
65
|
-
entry:
|
|
66
|
-
if (!context.roomHistory.some((item) => item.id === context.menu.arcade.id)) {
|
|
67
|
-
return { room: context.menu['arcade'] }
|
|
68
|
-
}
|
|
69
|
-
}),
|
|
49
|
+
entry: createSideAction('arcade'),
|
|
70
50
|
},
|
|
71
51
|
table: {
|
|
72
|
-
entry:
|
|
73
|
-
if (!context.roomHistory.some((item) => item.id === context.menu.table.id)) {
|
|
74
|
-
return { room: context.menu['table'] }
|
|
75
|
-
}
|
|
76
|
-
}),
|
|
52
|
+
entry: createSideAction('table'),
|
|
77
53
|
},
|
|
78
54
|
search: {},
|
|
79
55
|
history: {
|
|
@@ -168,3 +144,11 @@ export default function (request) {
|
|
|
168
144
|
}
|
|
169
145
|
)
|
|
170
146
|
}
|
|
147
|
+
|
|
148
|
+
function createSideAction(name) {
|
|
149
|
+
return assign((context, event) => {
|
|
150
|
+
if (!context.roomHistory.some((item) => item.id === context.menu[name].id)) {
|
|
151
|
+
return { room: context.menu[name] }
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
}
|
package/src/machine/side_v2.js
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { assign, createMachine } from 'xstate'
|
|
2
|
-
import api from '../api/game'
|
|
3
|
-
|
|
4
|
-
export default function (request) {
|
|
5
|
-
return createMachine(
|
|
6
|
-
{
|
|
7
|
-
id: 'side',
|
|
8
|
-
initial: 'preparing',
|
|
9
|
-
context: {
|
|
10
|
-
menu: {},
|
|
11
|
-
room: null,
|
|
12
|
-
roomHistory: [],
|
|
13
|
-
},
|
|
14
|
-
states: {
|
|
15
|
-
preparing: {
|
|
16
|
-
invoke: {
|
|
17
|
-
src: 'getRoomItems',
|
|
18
|
-
onDone: {
|
|
19
|
-
target: 'room',
|
|
20
|
-
actions: 'makeMenu',
|
|
21
|
-
},
|
|
22
|
-
onError: {
|
|
23
|
-
target: 'room',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
room: {
|
|
28
|
-
initial: 'home',
|
|
29
|
-
states: {
|
|
30
|
-
home: {
|
|
31
|
-
entry: createSideAction('home'),
|
|
32
|
-
},
|
|
33
|
-
favorite: {
|
|
34
|
-
entry: createSideAction('favorite'),
|
|
35
|
-
},
|
|
36
|
-
hot: {
|
|
37
|
-
entry: createSideAction('hot'),
|
|
38
|
-
},
|
|
39
|
-
new: {
|
|
40
|
-
entry: createSideAction('new'),
|
|
41
|
-
},
|
|
42
|
-
slot: {
|
|
43
|
-
entry: createSideAction('slot'),
|
|
44
|
-
},
|
|
45
|
-
fish: {
|
|
46
|
-
entry: createSideAction('fish'),
|
|
47
|
-
},
|
|
48
|
-
arcade: {
|
|
49
|
-
entry: createSideAction('arcade'),
|
|
50
|
-
},
|
|
51
|
-
table: {
|
|
52
|
-
entry: createSideAction('table'),
|
|
53
|
-
},
|
|
54
|
-
search: {},
|
|
55
|
-
history: {
|
|
56
|
-
type: 'history',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
feature: {
|
|
61
|
-
on: {
|
|
62
|
-
RETURN: { target: 'room.history' },
|
|
63
|
-
CLICK_HOT: { target: 'room.hot' },
|
|
64
|
-
CLICK_NEW: { target: 'room.new' },
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
category: {
|
|
68
|
-
on: {
|
|
69
|
-
RETURN: { target: 'room.history' },
|
|
70
|
-
CLICK_SLOT: { target: 'room.slot' },
|
|
71
|
-
CLICK_FISH: { target: 'room.fish' },
|
|
72
|
-
CLICK_ARCADE: { target: 'room.arcade' },
|
|
73
|
-
CLICK_TABLE: { target: 'room.table' },
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
on: {
|
|
78
|
-
CLICK_HOME: { target: 'room.home' },
|
|
79
|
-
CLICK_FAVORITE: { target: 'room.favorite' },
|
|
80
|
-
CLICK_FEATURE: { target: 'feature' },
|
|
81
|
-
CLICK_CATEGORY: { target: 'category' },
|
|
82
|
-
CLICK_SEARCH: { target: 'room.search' },
|
|
83
|
-
FORWARD_ROOM: { actions: 'forwardRoom' },
|
|
84
|
-
BACKWARD_ROOM: { actions: 'backwardRoom' },
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
actions: {
|
|
89
|
-
makeMenu: assign((context, event) => {
|
|
90
|
-
const { list = [] } = event.data
|
|
91
|
-
const map = {
|
|
92
|
-
home: ['SYSTEM_PERSONAL', 'SYSTEM_INDEX_LIST'],
|
|
93
|
-
favorite: 'SYSTEM_MY_FAVORITE',
|
|
94
|
-
hot: 'SYSTEM_TOP_GAME',
|
|
95
|
-
new: 'SYSTEM_NEW_GAME',
|
|
96
|
-
slot: 'SYSTEM_BIG_CATEGORY_SLOT',
|
|
97
|
-
fish: 'SYSTEM_BIG_CATEGORY_FISHING',
|
|
98
|
-
arcade: 'SYSTEM_BIG_CATEGORY_ARCADE',
|
|
99
|
-
table: 'SYSTEM_BIG_CATEGORY_TABLECARD',
|
|
100
|
-
limit: 'SYSTEM_ACTIVITY_LIMIT_GAME',
|
|
101
|
-
}
|
|
102
|
-
const menu = {}
|
|
103
|
-
Object.keys(map).forEach((key) => {
|
|
104
|
-
if (Array.isArray(map[key])) {
|
|
105
|
-
// 若是陣列則依順序決定館別內容
|
|
106
|
-
map[key].some((val) => {
|
|
107
|
-
const category = list.find((item) => item.category === val)
|
|
108
|
-
if (category) {
|
|
109
|
-
menu[key] = category
|
|
110
|
-
return true
|
|
111
|
-
} else {
|
|
112
|
-
return false
|
|
113
|
-
}
|
|
114
|
-
})
|
|
115
|
-
} else {
|
|
116
|
-
menu[key] = list.find((item) => item.category === map[key])
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
return { menu }
|
|
120
|
-
}),
|
|
121
|
-
forwardRoom: assign((context, event) => {
|
|
122
|
-
const currentRoom = event.data
|
|
123
|
-
return {
|
|
124
|
-
room: currentRoom,
|
|
125
|
-
roomHistory: [...context.roomHistory, context.room],
|
|
126
|
-
}
|
|
127
|
-
}),
|
|
128
|
-
backwardRoom: assign((context, event) => {
|
|
129
|
-
const newRoomHistory = context.roomHistory.slice(0, -1)
|
|
130
|
-
return {
|
|
131
|
-
room: newRoomHistory.slice(-1)[0],
|
|
132
|
-
roomHistory: newRoomHistory,
|
|
133
|
-
}
|
|
134
|
-
}),
|
|
135
|
-
resetRoomHistory: assign((context, event) => {
|
|
136
|
-
return {
|
|
137
|
-
roomHistory: [],
|
|
138
|
-
}
|
|
139
|
-
}),
|
|
140
|
-
},
|
|
141
|
-
services: {
|
|
142
|
-
getRoomItems: async (context, event) => {
|
|
143
|
-
return await request.send(api.getGameCategory({ id: context.room?.id }))
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
}
|
|
147
|
-
)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function createSideAction(name) {
|
|
151
|
-
return assign((context, event) => {
|
|
152
|
-
const { roomHistory } = context
|
|
153
|
-
if (roomHistory.some((history) => history.id === context.menu[name].id)) {
|
|
154
|
-
return { room: roomHistory.slice(-1)[0], roomHistory: roomHistory.slice(0, -1) }
|
|
155
|
-
} else {
|
|
156
|
-
return { room: context.menu[name], roomHistory: [context.menu[name]] }
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
}
|