-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathindex.js
More file actions
221 lines (191 loc) · 5.55 KB
/
index.js
File metadata and controls
221 lines (191 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
// Action组件统一导出文件
// 导入所有组件
import ActionRenderer from './ActionRenderer.vue'
import ActionDialog from './ActionDialog.vue'
import InputAction from './InputAction.vue'
import MultiInputAction from './MultiInputAction.vue'
import MenuAction from './MenuAction.vue'
import SelectAction from './SelectAction.vue'
import MsgBoxAction from './MsgBoxAction.vue'
import WebViewAction from './WebViewAction.vue'
import HelpAction from './HelpAction.vue'
// 导入类型定义和工具函数
import * as types from './types.js'
// 导入状态管理器
import {
ActionStateManager,
actionStateManager,
showAction,
submitAction,
cancelAction,
actionError,
currentAction,
actionHistory,
actionQueue,
statistics,
globalConfig
} from './ActionStateManager.js'
// 导入样式
import './styles.css'
// 组件列表
const components = {
ActionRenderer,
ActionDialog,
InputAction,
MultiInputAction,
MenuAction,
SelectAction,
MsgBoxAction,
WebViewAction,
HelpAction
}
// Vue插件安装函数
const install = (app, options = {}) => {
// 注册所有组件
Object.keys(components).forEach(name => {
app.component(name, components[name])
})
// 配置全局状态管理器
if (options.config) {
actionStateManager.updateConfig(options.config)
}
// 注册全局属性
app.config.globalProperties.$actionManager = actionStateManager
app.config.globalProperties.$showAction = showAction
// 提供依赖注入
app.provide('actionManager', actionStateManager)
app.provide('showAction', showAction)
}
// 默认导出(Vue插件)
export default {
install,
...components
}
// 单独导出组件
export {
ActionRenderer,
ActionDialog,
InputAction,
MultiInputAction,
MenuAction,
SelectAction,
MsgBoxAction,
WebViewAction,
HelpAction
}
// 导出类型和工具
export {
types,
ActionStateManager,
actionStateManager,
showAction,
submitAction,
cancelAction,
actionError,
currentAction,
actionHistory,
actionQueue,
statistics,
globalConfig
}
// 导出便捷方法
export const Actions = {
// 显示输入框
input: (config) => showAction({ ...config, type: types.ActionType.INPUT }),
// 显示多行编辑框
edit: (config) => showAction({ ...config, type: types.ActionType.EDIT }),
// 显示多输入框
multiInput: (config) => showAction({ ...config, type: types.ActionType.MULTI_INPUT }),
// 显示增强多输入框
multiInputX: (config) => showAction({ ...config, type: types.ActionType.MULTI_INPUT_X }),
// 显示菜单
menu: (config) => showAction({ ...config, type: types.ActionType.MENU }),
// 显示选择框
select: (config) => showAction({ ...config, type: types.ActionType.SELECT }),
// 显示消息框
msgBox: (config) => showAction({ ...config, type: types.ActionType.MSGBOX }),
// 显示网页视图
webView: (config) => showAction({ ...config, type: types.ActionType.WEBVIEW }),
// 显示帮助
help: (config) => showAction({ ...config, type: types.ActionType.HELP }),
// 显示确认对话框
confirm: (message, title = '确认') => showAction({
actionId: `confirm-${Date.now()}`,
type: types.ActionType.MSGBOX,
msg: message,
title,
button: types.ButtonType.OK_CANCEL
}),
// 显示警告对话框
alert: (message, title = '提示') => showAction({
actionId: `alert-${Date.now()}`,
type: types.ActionType.MSGBOX,
msg: message,
title,
button: types.ButtonType.OK_ONLY
}),
// 显示信息对话框
info: (message, title = '信息') => showAction({
actionId: `info-${Date.now()}`,
type: types.ActionType.MSGBOX,
msg: message,
title,
button: types.ButtonType.OK_ONLY,
icon: 'info'
}),
// 显示成功对话框
success: (message, title = '成功') => showAction({
actionId: `success-${Date.now()}`,
type: types.ActionType.MSGBOX,
msg: message,
title,
button: types.ButtonType.OK_ONLY,
icon: 'success'
}),
// 显示错误对话框
error: (message, title = '错误') => showAction({
actionId: `error-${Date.now()}`,
type: types.ActionType.MSGBOX,
msg: message,
title,
button: types.ButtonType.OK_ONLY,
icon: 'error'
}),
// 显示警告对话框
warning: (message, title = '警告') => showAction({
actionId: `warning-${Date.now()}`,
type: types.ActionType.MSGBOX,
msg: message,
title,
button: types.ButtonType.OK_ONLY,
icon: 'warning'
}),
// 显示加载对话框
loading: (message = '加载中...', title = '请稍候') => showAction({
actionId: `loading-${Date.now()}`,
type: types.ActionType.MSGBOX,
msg: message,
title,
button: types.ButtonType.NONE,
showProgress: true
}),
// 显示进度对话框
progress: (message, title = '进度', progress = 0) => showAction({
actionId: `progress-${Date.now()}`,
type: types.ActionType.MSGBOX,
msg: message,
title,
button: types.ButtonType.CANCEL_ONLY,
showProgress: true,
progress
})
}
// 导出配置创建函数
export const createActionConfig = types.createActionConfig
export const createInputActionConfig = types.createInputActionConfig
export const createMultiInputActionConfig = types.createMultiInputActionConfig
export const createMenuActionConfig = types.createMenuActionConfig
export const createSelectActionConfig = types.createSelectActionConfig
export const createMsgBoxActionConfig = types.createMsgBoxActionConfig
export const createWebViewActionConfig = types.createWebViewActionConfig
export const createHelpActionConfig = types.createHelpActionConfig