@mixd-id/web-scaffold 0.2.240706 → 0.2.250801010
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/docs/components/Dashboard.md +56 -0
- package/log.txt +7 -0
- package/package.json +27 -19
- package/src/components/404.vue +61 -0
- package/src/components/AccountIcon.vue +19 -0
- package/src/components/Ahref.vue +1 -1
- package/src/components/Alert.vue +4 -13
- package/src/components/ArrayList.vue +49 -0
- package/src/components/Article.vue +24 -30
- package/src/components/Button.vue +83 -169
- package/src/components/Card.vue +257 -0
- package/src/components/Carousel.vue +61 -60
- package/src/components/Cart.vue +192 -0
- package/src/components/CartIcon.vue +89 -0
- package/src/components/ChartBar.vue +2 -3
- package/src/components/Checkbox.vue +20 -11
- package/src/components/Checkout.vue +373 -0
- package/src/components/CheckoutDelivery.vue +267 -0
- package/src/components/CodeEditor.vue +5 -16
- package/src/components/CollapsiblePanel.vue +70 -0
- package/src/components/ColorPicker.vue +12 -5
- package/src/components/ColorPicker2.vue +41 -19
- package/src/components/ColorPicker3.vue +100 -0
- package/src/components/Confirm.vue +9 -7
- package/src/components/ContextMenu.vue +122 -206
- package/src/components/ContextMenuItem.vue +53 -0
- package/src/components/Dashboard.vue +243 -0
- package/src/components/Dashboard2.vue +118 -0
- package/src/components/DashboardComponentSelector.vue +96 -0
- package/src/components/DashboardConfigs.vue +202 -0
- package/src/components/Datepicker.vue +102 -41
- package/src/components/DayTimeRange.vue +3 -2
- package/src/components/Dropdown.vue +7 -4
- package/src/components/Flex.vue +14 -40
- package/src/components/GHeatMaps.vue +2 -2
- package/src/components/Grid.vue +6 -6
- package/src/components/HTMLEditor.vue +27 -14
- package/src/components/Image.vue +62 -108
- package/src/components/ImagePreview.vue +14 -4
- package/src/components/ImageUploader.vue +114 -0
- package/src/components/ImportModal.vue +3 -3
- package/src/components/Link.vue +62 -6
- package/src/components/List.vue +528 -403
- package/src/components/ListContextMenu.vue +88 -0
- package/src/components/ListItem.vue +6 -4
- package/src/components/ListPage1.vue +14 -15
- package/src/components/ListView.vue +5 -6
- package/src/components/ListViewSettings.vue +2 -2
- package/src/components/LogViewerItem.vue +1 -1
- package/src/components/MarkdownEdit.vue +128 -0
- package/src/components/MarkdownPreview.vue +102 -0
- package/src/components/MenuItem1.vue +36 -0
- package/src/components/Modal.vue +95 -43
- package/src/components/MultiDropdown.vue +124 -0
- package/src/components/MultilineText.vue +1 -4
- package/src/components/OTPField.vue +40 -26
- package/src/components/ObjectTree.vue +1 -1
- package/src/components/PageBuilder.vue +3 -3
- package/src/components/Paragraph.vue +1 -2
- package/src/components/PresetSelectorFilterItem.vue +107 -95
- package/src/components/Radio.vue +1 -1
- package/src/components/SearchModal.vue +153 -0
- package/src/components/Slider.vue +1 -1
- package/src/components/Svg.vue +1 -1
- package/src/components/SvgEditor.vue +173 -0
- package/src/components/Switch.vue +4 -5
- package/src/components/Table.vue +2 -2
- package/src/components/TableView.vue +2 -3
- package/src/components/TableViewHead.vue +2 -2
- package/src/components/Tabs.vue +1 -1
- package/src/components/Testimonial.vue +2 -2
- package/src/components/Text.vue +7 -22
- package/src/components/TextEditor.vue +3 -3
- package/src/components/TextWithTag.vue +61 -30
- package/src/components/Textarea.vue +16 -22
- package/src/components/Textbox.vue +9 -19
- package/src/components/Timepicker.vue +25 -15
- package/src/components/Toast.vue +5 -3
- package/src/components/TreeMenu.vue +122 -0
- package/src/components/TreeView.vue +15 -10
- package/src/components/TreeView2.vue +38 -0
- package/src/components/TreeViewItem.vue +58 -29
- package/src/components/TreeViewItem2.vue +55 -0
- package/src/components/Uploader.vue +45 -0
- package/src/components/Video.vue +119 -0
- package/src/components/VirtualGrid.vue +24 -7
- package/src/components/VirtualTable.vue +363 -128
- package/src/configs/dashboard/data-table.js +9 -0
- package/src/configs/web-page-builder.js +118 -0
- package/src/directives/intersect.js +26 -0
- package/src/hooks/device.js +14 -0
- package/src/index.js +62 -107
- package/src/mixin/component.js +151 -67
- package/src/themes/default/index.js +118 -159
- package/src/utils/dashboard.js +22 -962
- package/src/utils/helpers.cjs +635 -0
- package/src/utils/helpers.js +91 -60
- package/src/utils/helpers.mjs +245 -12
- package/src/utils/importer.js +22 -3
- package/src/utils/list.mjs +1509 -0
- package/src/utils/preset-selector.cjs +1455 -0
- package/src/utils/preset-selector.js +489 -95
- package/src/utils/preset-selector.mjs +59 -20
- package/src/utils/queue.js +63 -0
- package/src/utils/web.mjs +120 -0
- package/src/utils/wss.js +38 -36
- package/src/utils/wss.mjs +24 -19
- package/src/widgets/AhrefSetting.vue +16 -13
- package/src/widgets/ArticleSetting.vue +15 -27
- package/src/widgets/BackgroundColorSetting.vue +153 -0
- package/src/widgets/BorderColorSetting.vue +57 -0
- package/src/widgets/BotEditor/BotEditorActions.vue +3 -2
- package/src/widgets/BotEditor/BotEditorSettings.vue +21 -0
- package/src/widgets/BotEditor.vue +35 -15
- package/src/widgets/ButtonSetting.vue +12 -13
- package/src/widgets/CarouselSetting.vue +33 -45
- package/src/widgets/CartSetting.vue +46 -0
- package/src/widgets/CheckoutSetting.vue +46 -0
- package/src/widgets/CollapsiblePanelSetting.vue +46 -0
- package/src/widgets/ColumnSelector.vue +29 -5
- package/src/widgets/ComponentSetting.vue +1 -1
- package/src/widgets/ComponentSetting2.vue +145 -236
- package/src/widgets/ComponentSetting3.vue +1 -1
- package/src/widgets/ContactForm.vue +3 -3
- package/src/widgets/ContactFormSetting.vue +41 -30
- package/src/widgets/Dashboard/BarChart.vue +47 -11
- package/src/widgets/Dashboard/BarChartSetting.vue +1 -1
- package/src/widgets/Dashboard/DataTable.vue +125 -0
- package/src/widgets/Dashboard/DataTableSetting.vue +243 -0
- package/src/widgets/Dashboard/DatasourceSelector.vue +1 -1
- package/src/widgets/Dashboard/Doughnut.vue +49 -7
- package/src/widgets/Dashboard/DoughnutSetting.vue +2 -2
- package/src/widgets/Dashboard/Metric.vue +78 -19
- package/src/widgets/Dashboard/MetricSetting.vue +81 -28
- package/src/widgets/Dashboard/Pie.vue +55 -6
- package/src/widgets/Dashboard/PieSetting.vue +1 -1
- package/src/widgets/Dashboard/PolarArea.vue +49 -7
- package/src/widgets/Dashboard/PolarAreaSetting.vue +1 -1
- package/src/widgets/Dashboard/SharingModal.vue +4 -5
- package/src/widgets/Dashboard/ViewSelector.vue +2 -2
- package/src/widgets/Dashboard/VirtualTableSetting.vue +121 -184
- package/src/widgets/{Dashboard.vue → Dashboard0.vue} +426 -343
- package/src/widgets/EmbeddedVideoSetting.vue +7 -5
- package/src/widgets/FAQ.vue +16 -3
- package/src/widgets/FAQSetting.vue +53 -47
- package/src/widgets/FeatureList.vue +3 -0
- package/src/widgets/FeatureListSetting.vue +112 -102
- package/src/widgets/FlexSetting.vue +83 -106
- package/src/widgets/GridSetting.vue +71 -196
- package/src/widgets/Header2.vue +34 -71
- package/src/widgets/Header2Setting.vue +95 -179
- package/src/widgets/HeaderSetting.vue +16 -18
- package/src/widgets/IconListSetting.vue +69 -65
- package/src/widgets/ImageSetting.vue +33 -60
- package/src/widgets/LinkSetting.vue +60 -37
- package/src/widgets/LinkSettingModal.vue +173 -0
- package/src/widgets/LogViewer.vue +1 -1
- package/src/widgets/MarginSetting.vue +2 -2
- package/src/widgets/MenuEditor.vue +1 -1
- package/src/widgets/MenuItem1Setting.vue +78 -0
- package/src/widgets/ModalSetting.vue +42 -44
- package/src/widgets/MultiValueSetting.vue +2 -2
- package/src/widgets/MultiValueSetting2.vue +78 -45
- package/src/widgets/OGSettingModal.vue +103 -0
- package/src/widgets/PaddingSetting.vue +2 -2
- package/src/widgets/ParagraphSetting.vue +16 -13
- package/src/widgets/PositionSetting.vue +209 -0
- package/src/widgets/PresetBar.vue +359 -210
- package/src/widgets/PresetBarPivot.vue +31 -19
- package/src/widgets/PresetSelector.vue +29 -17
- package/src/widgets/SearchModalSetting.vue +70 -0
- package/src/widgets/Share.vue +1 -2
- package/src/widgets/ShareSetting.vue +67 -60
- package/src/widgets/StyleSetting.vue +365 -150
- package/src/widgets/TestimonialSetting.vue +97 -88
- package/src/widgets/TextBlockSetting.vue +16 -13
- package/src/widgets/UserActionBuilder/UserActionConsole.vue +30 -10
- package/src/widgets/UserActionBuilder/UserActionOutput.vue +2 -2
- package/src/widgets/UserActionBuilder/UserActionOutputReply.vue +64 -87
- package/src/widgets/UserActionBuilder/UserActionProps.vue +3 -3
- package/src/widgets/UserActionBuilder.vue +4 -16
- package/src/widgets/WebComponentSelector.vue +15 -11
- package/src/widgets/WebLayoutSelector.vue +41 -270
- package/src/widgets/WebPageBuilder.vue +1019 -707
- package/src/widgets/WebPageBuilder2.vue +7 -7
- package/src/widgets/WebPageBuilder4/ButtonSetting.vue +0 -8
- package/src/widgets/WebPageBuilder4/CarouselSetting.vue +63 -7
- package/src/widgets/WebPageBuilder4/FlexAlignSetting.vue +3 -3
- package/src/widgets/WebPageBuilder4/FlexSetting.vue +1 -10
- package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +2 -2
- package/src/widgets/WebPageBuilder4/PropertySetting.vue +0 -7
- package/src/widgets/WebPageBuilder4/WebPageComponentSelector.vue +1 -7
- package/src/widgets/WebPageBuilder4.vue +289 -575
- package/src/widgets/WebPageSelector.vue +1 -1
- package/src/widgets/YoutubeVideoSetting.vue +16 -13
- package/tailwind.config.js +3 -35
- package/docs/schema/user-action.json +0 -266
- package/src/App.vue +0 -25
- package/src/components/SearchButton.vue +0 -57
- package/src/entry-client.js +0 -27
- package/src/entry-server.js +0 -73
- package/src/events/event.js +0 -2
- package/src/main.js +0 -29
- package/src/mixin/website.js +0 -121
- package/src/router.js +0 -57
- package/src/widgets/MobileMenu.vue +0 -182
- package/src/widgets/WebPageBuilder4/ActionSetting.vue +0 -158
- package/src/widgets/WebPageBuilder4/ColorSetting.vue +0 -63
- package/src/widgets/WebPageBuilder4/DataSetting.vue +0 -92
- package/src/widgets/WebPageBuilder4/FontSizeSetting.vue +0 -76
- package/src/widgets/WebPageBuilder4/LinkSetting.vue +0 -68
- package/src/widgets/WebPageBuilder4/MobileMenuSetting.vue +0 -106
- package/src/widgets/WebPageBuilder4/Setting.vue +0 -73
- package/src/widgets/WebPageBuilder4/StyleSetting.vue +0 -77
- package/src/widgets/WebPageBuilder4/SvgSetting.vue +0 -207
- package/src/widgets/WebPageBuilder4/TextTransformSetting.vue +0 -70
- package/src/widgets/WebPageBuilder4/WebPageDataEdit.vue +0 -121
- package/test.json +0 -22
- /package/src/widgets/{Header1.vue → Header0.vue} +0 -0
- /package/src/widgets/{Header1Setting.vue → Header0Setting.vue} +0 -0
|
@@ -24,40 +24,74 @@ const sortsFn = function(a, b, sorts, index){
|
|
|
24
24
|
const pickColumns = function(columns, keys){
|
|
25
25
|
if(!Array.isArray(columns)) return []
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
columns = JSON.parse(JSON.stringify(columns))
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
columns = columns.reduce((cur, obj) => {
|
|
30
|
+
cur[obj.key] = {
|
|
31
|
+
...obj,
|
|
32
|
+
visible: false
|
|
33
|
+
}
|
|
34
|
+
return cur
|
|
35
|
+
}, {})
|
|
36
|
+
|
|
37
|
+
const res = []
|
|
38
|
+
|
|
39
|
+
for(let key of keys){
|
|
40
|
+
if(typeof key === 'string'){
|
|
41
|
+
if(columns[key]){
|
|
42
|
+
columns[key].visible = true
|
|
43
|
+
res.push(columns[key])
|
|
44
|
+
delete columns[key]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else if(typeof key === 'object' && key !== null && key.key){
|
|
48
|
+
if(columns[key.key]){
|
|
49
|
+
res.push(Object.assign(columns[key.key], key, { visible:true }))
|
|
50
|
+
delete columns[key.key]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
31
53
|
}
|
|
32
54
|
|
|
33
|
-
|
|
34
|
-
}
|
|
55
|
+
res.push(...Object.values(columns))
|
|
35
56
|
|
|
36
|
-
|
|
37
|
-
return md5('preset-' + new Date().getTime() + extra)
|
|
57
|
+
return res
|
|
38
58
|
}
|
|
39
59
|
|
|
40
60
|
const setupConfig = (config) => {
|
|
41
61
|
|
|
62
|
+
if(config.domains && !Array.isArray(config.presets)){
|
|
63
|
+
let defaultConfig
|
|
64
|
+
for(let key in config.domains){
|
|
65
|
+
if(location.host.indexOf(key) >= 0){
|
|
66
|
+
defaultConfig = config.domains[key]
|
|
67
|
+
break
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if(!defaultConfig)
|
|
71
|
+
defaultConfig = config.domains['default'] ?? {}
|
|
72
|
+
|
|
73
|
+
Object.assign(config, JSON.parse(JSON.stringify(defaultConfig)))
|
|
74
|
+
}
|
|
75
|
+
|
|
42
76
|
if(Array.isArray(config.presets)){
|
|
43
77
|
for(let idx in config.presets){
|
|
44
|
-
if(!Array.isArray(config.presets[idx].
|
|
45
|
-
config.presets[idx].
|
|
78
|
+
if(!Array.isArray(config.presets[idx].columns)){
|
|
79
|
+
config.presets[idx].columns = []
|
|
46
80
|
}
|
|
47
81
|
|
|
48
|
-
if(config.presets[idx].
|
|
49
|
-
config.presets[idx].
|
|
82
|
+
if(config.presets[idx].columns[0] && typeof config.presets[idx].columns[0] === 'string'){
|
|
83
|
+
config.presets[idx].columns = pickColumns(config.columns ?? [], config.presets[idx].columns)
|
|
50
84
|
}
|
|
51
85
|
|
|
52
|
-
if(!config.presets[idx].
|
|
53
|
-
config.presets[idx].
|
|
86
|
+
if(!config.presets[idx].view)
|
|
87
|
+
config.presets[idx].view = 'table'
|
|
54
88
|
|
|
55
89
|
if(!config.presets[idx].uid)
|
|
56
|
-
config.presets[idx].uid = getPresetUid(
|
|
90
|
+
config.presets[idx].uid = getPresetUid(config.name)
|
|
57
91
|
}
|
|
58
92
|
|
|
59
|
-
if(!config.
|
|
60
|
-
config.
|
|
93
|
+
if(!config.presetIdx && config.presets.length > 0){
|
|
94
|
+
config.presetIdx = 0
|
|
61
95
|
}
|
|
62
96
|
}
|
|
63
97
|
|
|
@@ -185,11 +219,16 @@ const generateTotalColumns = (preset, items) => {
|
|
|
185
219
|
items.push(totalItem)
|
|
186
220
|
}
|
|
187
221
|
|
|
222
|
+
let presetUidSalt = 0
|
|
223
|
+
const getPresetUid = function(extra = ''){
|
|
224
|
+
return md5('preset-' + new Date().getTime() + extra + (++presetUidSalt))
|
|
225
|
+
}
|
|
226
|
+
|
|
188
227
|
export {
|
|
189
|
-
|
|
190
|
-
generatePivotColumns,
|
|
191
|
-
generateTotalColumns,
|
|
228
|
+
sortsFn,
|
|
192
229
|
pickColumns,
|
|
193
230
|
setupConfig,
|
|
194
|
-
|
|
231
|
+
generatePivotColumns,
|
|
232
|
+
generateTotalColumns,
|
|
233
|
+
getPresetUid
|
|
195
234
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const redis = require('redis');
|
|
2
|
+
const client = redis.createClient();
|
|
3
|
+
client.connect()
|
|
4
|
+
.then(() => console.log('Connected to Redis'))
|
|
5
|
+
.catch((err) => console.error('Redis connection error:', err));
|
|
6
|
+
|
|
7
|
+
const queues = {}
|
|
8
|
+
|
|
9
|
+
const sleep = ms => new Promise(r => setTimeout(r, ms))
|
|
10
|
+
|
|
11
|
+
const processQueue = async(key) => {
|
|
12
|
+
const queue = queues[key]
|
|
13
|
+
if(queue.processing) return
|
|
14
|
+
queue.processing = true
|
|
15
|
+
|
|
16
|
+
const result = await client.hGetAll(key);
|
|
17
|
+
const keys = Object.keys(result ?? {})
|
|
18
|
+
if(keys.length < 1){
|
|
19
|
+
queue.processing = false
|
|
20
|
+
return
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const itemKeys = keys.splice(0, queue.concurrency)
|
|
24
|
+
if(itemKeys.length > 0){
|
|
25
|
+
await Promise.all(itemKeys.map(async itemKey => {
|
|
26
|
+
try{
|
|
27
|
+
const obj = JSON.parse(await client.hGet(key, itemKey))
|
|
28
|
+
await queue.pop(obj)
|
|
29
|
+
}
|
|
30
|
+
finally{
|
|
31
|
+
await client.hDel(key, itemKey)
|
|
32
|
+
}
|
|
33
|
+
}))
|
|
34
|
+
|
|
35
|
+
await sleep(queue.interval ?? 0)
|
|
36
|
+
}
|
|
37
|
+
queue.processing = false
|
|
38
|
+
|
|
39
|
+
await processQueue(key)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const queueItem = async(obj, opt) => {
|
|
43
|
+
if(!queues[opt.key]){
|
|
44
|
+
queues[opt.key] = {
|
|
45
|
+
interval: 16,
|
|
46
|
+
concurrency: 1,
|
|
47
|
+
|
|
48
|
+
...opt
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await client.del(opt.key)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { key } = opt
|
|
55
|
+
const subKey = `${key}-${new Date().getTime() + Math.random()}`
|
|
56
|
+
await client.hSet(key, subKey, JSON.stringify(obj));
|
|
57
|
+
|
|
58
|
+
processQueue(key).then()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = {
|
|
62
|
+
queueItem
|
|
63
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const extractCompProps = (component, props) => {
|
|
2
|
+
|
|
3
|
+
const comp = {}
|
|
4
|
+
|
|
5
|
+
if(component.uid){
|
|
6
|
+
for(let prop of props){
|
|
7
|
+
|
|
8
|
+
if(typeof prop === 'string'){
|
|
9
|
+
if(component[prop]){
|
|
10
|
+
comp[component.uid] = {
|
|
11
|
+
...(comp[component.uid] ?? {}),
|
|
12
|
+
[prop]: component[prop]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
else if(Array.isArray(prop)){
|
|
17
|
+
const type = prop[0]
|
|
18
|
+
const typeProps = prop[1]
|
|
19
|
+
|
|
20
|
+
if(component.type === type){
|
|
21
|
+
for(let tprop of typeProps){
|
|
22
|
+
comp[component.uid] = {
|
|
23
|
+
...(comp[component.uid] ?? {}),
|
|
24
|
+
[tprop]: component[tprop]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if(component.items){
|
|
33
|
+
for(let i in component.items){
|
|
34
|
+
const item = component.items[i]
|
|
35
|
+
|
|
36
|
+
Object.assign(comp, extractCompProps(item, props))
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return comp
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const setCompProps = (component, props) => {
|
|
44
|
+
|
|
45
|
+
Object.assign(component, props)
|
|
46
|
+
|
|
47
|
+
if(Array.isArray(component.items)){
|
|
48
|
+
for(let item of component.items){
|
|
49
|
+
if(item.uid && props[item.uid]){
|
|
50
|
+
setCompProps(item, props)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const extractPageInstanceProps = (page, props = [ 'data', 'params',
|
|
57
|
+
[ 'ArticleThumbnails', [ 'items' ] ],
|
|
58
|
+
[ 'HMCThumbnails', [ 'items' ] ],
|
|
59
|
+
[ 'FeatureList', [ 'items' ] ],
|
|
60
|
+
[ 'SpecTable', [ 'items' ] ],
|
|
61
|
+
[ 'Review', [ 'items' ] ],
|
|
62
|
+
]) => {
|
|
63
|
+
|
|
64
|
+
const comp = {}
|
|
65
|
+
|
|
66
|
+
if(Array.isArray(page.headers)){
|
|
67
|
+
for(let component of page.headers){
|
|
68
|
+
Object.assign(comp, extractCompProps(component, props))
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if(Array.isArray(page.components)){
|
|
73
|
+
for(let component of page.components){
|
|
74
|
+
Object.assign(comp, extractCompProps(component, props))
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if(Array.isArray(page.footers)){
|
|
79
|
+
for(let component of page.footers){
|
|
80
|
+
Object.assign(comp, extractCompProps(component, props))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return comp
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const setPageInstanceProps = (page, props) => {
|
|
88
|
+
|
|
89
|
+
if(Array.isArray(page.headers)){
|
|
90
|
+
for(let component of page.headers){
|
|
91
|
+
if(component.uid && props[component.uid]){
|
|
92
|
+
setCompProps(component, props[component.uid])
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if(Array.isArray(page.components)){
|
|
98
|
+
for(let component of page.components){
|
|
99
|
+
if(component.uid && props[component.uid]){
|
|
100
|
+
setCompProps(component, props[component.uid])
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if(Array.isArray(page.footers)){
|
|
106
|
+
for(let component of page.footers){
|
|
107
|
+
if(component.uid && props[component.uid]){
|
|
108
|
+
setCompProps(component, props[component.uid])
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export {
|
|
116
|
+
extractCompProps,
|
|
117
|
+
setCompProps,
|
|
118
|
+
extractPageInstanceProps,
|
|
119
|
+
setPageInstanceProps
|
|
120
|
+
}
|
package/src/utils/wss.js
CHANGED
|
@@ -74,18 +74,21 @@ class WSS extends EventEmitter2{
|
|
|
74
74
|
_reqFn = []
|
|
75
75
|
_retryCount = 0
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
_connectionId = 0
|
|
78
|
+
_debugIds = {}
|
|
79
|
+
|
|
80
|
+
async fromBinaryData(binaryData, debugMode = false){
|
|
78
81
|
const encryptedString = Buffer.from(binaryData).toString('utf-8');
|
|
79
|
-
const decryptedData = this._opt.key ?
|
|
82
|
+
const decryptedData = this._opt.key && !debugMode ?
|
|
80
83
|
CryptoJS.AES.decrypt(encryptedString, this._opt.key).toString(CryptoJS.enc.Utf8) :
|
|
81
84
|
encryptedString;
|
|
82
85
|
const receivedObject = JSON.parse(decryptedData);
|
|
83
86
|
return await revertDataUrlObj(receivedObject);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
|
-
async toBinaryData(obj){
|
|
89
|
+
async toBinaryData(obj, debugMode = false){
|
|
87
90
|
const dataUrlObj = await convertDataUrlObj(obj)
|
|
88
|
-
const encryptedData = this._opt.key ?
|
|
91
|
+
const encryptedData = this._opt.key && !debugMode ?
|
|
89
92
|
CryptoJS.AES.encrypt(JSON.stringify(dataUrlObj), this._opt.key).toString() :
|
|
90
93
|
JSON.stringify(dataUrlObj);
|
|
91
94
|
return new TextEncoder().encode(encryptedData);
|
|
@@ -106,12 +109,17 @@ class WSS extends EventEmitter2{
|
|
|
106
109
|
this._client.connect().then()
|
|
107
110
|
|
|
108
111
|
this._instance.on('connection', async (socket, req) => {
|
|
112
|
+
socket.id = `${++this._connectionId}`
|
|
113
|
+
|
|
114
|
+
if(`${req.url}`.indexOf('debug-ws') > 0){
|
|
115
|
+
this._debugIds[socket.id] = {}
|
|
116
|
+
}
|
|
109
117
|
|
|
110
118
|
let subscriber
|
|
111
119
|
|
|
112
120
|
const listener = (message) => {
|
|
113
121
|
const { model, event, items } = JSON.parse(message)
|
|
114
|
-
this.toBinaryData({ data:{ model, event, items } })
|
|
122
|
+
this.toBinaryData({ data:{ model, event, items } }, !!this._debugIds[socket.id])
|
|
115
123
|
.then(data => socket.send(data))
|
|
116
124
|
}
|
|
117
125
|
|
|
@@ -123,10 +131,6 @@ class WSS extends EventEmitter2{
|
|
|
123
131
|
if(subscriber){
|
|
124
132
|
subscriber.unsubscribe(channel, listener)
|
|
125
133
|
}
|
|
126
|
-
|
|
127
|
-
if(process.verbose){
|
|
128
|
-
process.verbose('wss.leave', channel)
|
|
129
|
-
}
|
|
130
134
|
}
|
|
131
135
|
|
|
132
136
|
socket.join = (channel) => {
|
|
@@ -138,10 +142,6 @@ class WSS extends EventEmitter2{
|
|
|
138
142
|
if(subscriber) {
|
|
139
143
|
subscriber.subscribe(channel, listener)
|
|
140
144
|
}
|
|
141
|
-
|
|
142
|
-
if(process.verbose){
|
|
143
|
-
process.verbose('wss.join', channel)
|
|
144
|
-
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
socket.to = (channel) => {
|
|
@@ -157,7 +157,7 @@ class WSS extends EventEmitter2{
|
|
|
157
157
|
|
|
158
158
|
let obj
|
|
159
159
|
try{
|
|
160
|
-
obj = await this.fromBinaryData(binaryData);
|
|
160
|
+
obj = await this.fromBinaryData(binaryData, !!this._debugIds[socket.id]);
|
|
161
161
|
}
|
|
162
162
|
catch(e){
|
|
163
163
|
return socket.close(1002, e.message);
|
|
@@ -170,7 +170,7 @@ class WSS extends EventEmitter2{
|
|
|
170
170
|
this._retryCount = 0
|
|
171
171
|
}
|
|
172
172
|
else if(ping){
|
|
173
|
-
socket.send(await this.toBinaryData({ pong: 1 }))
|
|
173
|
+
socket.send(await this.toBinaryData({ pong: 1 }, !!this._debugIds[socket.id]))
|
|
174
174
|
}
|
|
175
175
|
else{
|
|
176
176
|
let status = 200
|
|
@@ -185,13 +185,7 @@ class WSS extends EventEmitter2{
|
|
|
185
185
|
data = arr.length > 0 ? JSON.parse(JSON.stringify(arr.pop())) : data
|
|
186
186
|
}
|
|
187
187
|
catch(e){
|
|
188
|
-
|
|
189
|
-
if(e.response){
|
|
190
|
-
'$report' in process ? process.$report(e) : console.error(e.response.status, e.response.data)
|
|
191
|
-
}
|
|
192
|
-
else{
|
|
193
|
-
'$report' in process ? process.$report(e) : console.error(e)
|
|
194
|
-
}
|
|
188
|
+
console.error(e)
|
|
195
189
|
|
|
196
190
|
status = 500
|
|
197
191
|
data = {
|
|
@@ -209,7 +203,7 @@ class WSS extends EventEmitter2{
|
|
|
209
203
|
_requestId,
|
|
210
204
|
status,
|
|
211
205
|
data
|
|
212
|
-
}))
|
|
206
|
+
}, !!this._debugIds[socket.id]))
|
|
213
207
|
}
|
|
214
208
|
});
|
|
215
209
|
|
|
@@ -222,21 +216,28 @@ class WSS extends EventEmitter2{
|
|
|
222
216
|
|
|
223
217
|
const token = req.headers['sec-websocket-protocol'];
|
|
224
218
|
try{
|
|
225
|
-
|
|
219
|
+
if(this._opt.auth){
|
|
220
|
+
await this._opt.auth(token, socket)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
for(let fn of this._authFn) {
|
|
224
|
+
await fn(token, socket)
|
|
225
|
+
}
|
|
226
|
+
|
|
226
227
|
socket.isAuth = true
|
|
227
|
-
socket.send(await this.toBinaryData({ auth:true }))
|
|
228
|
+
socket.send(await this.toBinaryData({ auth:true }, !!this._debugIds[socket.id]))
|
|
228
229
|
|
|
229
230
|
subscriber = this._client.duplicate()
|
|
230
231
|
await subscriber.connect()
|
|
231
232
|
}
|
|
232
233
|
catch(e){
|
|
233
|
-
return socket.close(1002, e.message);
|
|
234
|
+
return socket.close(1002, (e.message ?? '').substring(0, 123));
|
|
234
235
|
}
|
|
235
236
|
|
|
236
237
|
if(this._opt.ping !== false){
|
|
237
238
|
|
|
238
239
|
const ping = async() => {
|
|
239
|
-
socket.send(await this.toBinaryData({ ping:1 }))
|
|
240
|
+
socket.send(await this.toBinaryData({ ping:1 }, !!this._debugIds[socket.id]))
|
|
240
241
|
socket.pinging = true
|
|
241
242
|
|
|
242
243
|
setTimeout(() => {
|
|
@@ -245,6 +246,12 @@ class WSS extends EventEmitter2{
|
|
|
245
246
|
|
|
246
247
|
if(this._retryCount > 10){
|
|
247
248
|
socket.close(1002, 'ping timeout')
|
|
249
|
+
if(subscriber){
|
|
250
|
+
subscriber.disconnect()
|
|
251
|
+
}
|
|
252
|
+
else{
|
|
253
|
+
console.log('CLOSE SOCKET#2', token.substring(0, 10) + '...')
|
|
254
|
+
}
|
|
248
255
|
}
|
|
249
256
|
}
|
|
250
257
|
else{
|
|
@@ -265,6 +272,10 @@ class WSS extends EventEmitter2{
|
|
|
265
272
|
this._reqFn.push(fn)
|
|
266
273
|
}
|
|
267
274
|
|
|
275
|
+
use(fn){
|
|
276
|
+
this.req.apply(this, arguments)
|
|
277
|
+
}
|
|
278
|
+
|
|
268
279
|
async broadcast(channels, { model, event, items }){
|
|
269
280
|
|
|
270
281
|
if(!Array.isArray(channels))
|
|
@@ -272,15 +283,6 @@ class WSS extends EventEmitter2{
|
|
|
272
283
|
|
|
273
284
|
for(let channel of channels){
|
|
274
285
|
await this._client.publish(channel, JSON.stringify({ model, event, items }))
|
|
275
|
-
|
|
276
|
-
if(process.verbose){
|
|
277
|
-
process.verbose('wss.broadcast', {
|
|
278
|
-
channel,
|
|
279
|
-
model,
|
|
280
|
-
event,
|
|
281
|
-
items
|
|
282
|
-
})
|
|
283
|
-
}
|
|
284
286
|
}
|
|
285
287
|
}
|
|
286
288
|
|
package/src/utils/wss.mjs
CHANGED
|
@@ -46,6 +46,7 @@ class WSS extends EventEmitter2{
|
|
|
46
46
|
_callbacks = {}
|
|
47
47
|
_pendingSend = []
|
|
48
48
|
_pinging = false
|
|
49
|
+
_retryCount = 1
|
|
49
50
|
|
|
50
51
|
constructor(opt) {
|
|
51
52
|
super();
|
|
@@ -69,7 +70,6 @@ class WSS extends EventEmitter2{
|
|
|
69
70
|
this.emit('visibilitychange', this._instance.readyState, [])
|
|
70
71
|
|
|
71
72
|
this.ping().catch(e => {
|
|
72
|
-
console.log('ping error', e)
|
|
73
73
|
this.reconnect().then()
|
|
74
74
|
})
|
|
75
75
|
}
|
|
@@ -79,19 +79,26 @@ class WSS extends EventEmitter2{
|
|
|
79
79
|
|
|
80
80
|
async fromBinaryData(binaryData){
|
|
81
81
|
const encryptedString = new TextDecoder().decode(binaryData)
|
|
82
|
-
const decryptedData = this._opt.key ?
|
|
82
|
+
const decryptedData = this._opt.key && !this._opt.debug ?
|
|
83
83
|
CryptoJS.AES.decrypt(encryptedString, this._opt.key).toString(CryptoJS.enc.Utf8) :
|
|
84
84
|
encryptedString;
|
|
85
85
|
return JSON.parse(decryptedData)
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
async toBinaryData(obj){
|
|
89
|
-
const encryptedData = this._opt.key ?
|
|
89
|
+
const encryptedData = this._opt.key && !this._opt.debug ?
|
|
90
90
|
CryptoJS.AES.encrypt(JSON.stringify(obj), this._opt.key).toString() :
|
|
91
91
|
JSON.stringify(obj);
|
|
92
92
|
return new TextEncoder().encode(encryptedData)
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
flushPending(){
|
|
96
|
+
for(let sendParams of this._pendingSend){
|
|
97
|
+
this.sendSync(sendParams.path, sendParams.params, sendParams.cb, sendParams.err)
|
|
98
|
+
}
|
|
99
|
+
this._pendingSend = []
|
|
100
|
+
}
|
|
101
|
+
|
|
95
102
|
async connect(reconnect = false){
|
|
96
103
|
|
|
97
104
|
this._instance = new WebSocket(this._opt.url, [ this._opt.token ])
|
|
@@ -112,13 +119,8 @@ class WSS extends EventEmitter2{
|
|
|
112
119
|
}
|
|
113
120
|
else if(auth){
|
|
114
121
|
this._instance.isAuth = auth
|
|
115
|
-
|
|
122
|
+
this.flushPending()
|
|
116
123
|
this.emit('connect', reconnect, [])
|
|
117
|
-
|
|
118
|
-
for(let sendParams of this._pendingSend){
|
|
119
|
-
this.sendSync(sendParams.path, sendParams.params, sendParams.cb, sendParams.err)
|
|
120
|
-
}
|
|
121
|
-
this._pendingSend = []
|
|
122
124
|
}
|
|
123
125
|
else if(_requestId){
|
|
124
126
|
if(this._callbacks[_requestId] && this._instance.readyState === 1){
|
|
@@ -128,8 +130,8 @@ class WSS extends EventEmitter2{
|
|
|
128
130
|
|
|
129
131
|
if(this._opt.debug){
|
|
130
132
|
status === 200 ?
|
|
131
|
-
console.log(`${new Date().getTime() - t1}ms`, `l:${JSON.stringify(data ?? '').length}
|
|
132
|
-
console.error(`${new Date().getTime() - t1}ms`, `l:${JSON.stringify(data ?? '').length}
|
|
133
|
+
console.log(`${path} (${new Date().getTime() - t1}ms)`, params, data, `l:${JSON.stringify(data ?? '').length}`) :
|
|
134
|
+
console.error(`${path} (${new Date().getTime() - t1}ms)`, params, data, `l:${JSON.stringify(data ?? '').length}`)
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
}
|
|
@@ -144,15 +146,15 @@ class WSS extends EventEmitter2{
|
|
|
144
146
|
|
|
145
147
|
};
|
|
146
148
|
|
|
147
|
-
this._instance.
|
|
148
|
-
|
|
149
|
+
this._instance.onopen = () => {
|
|
150
|
+
this._retryCount = 0
|
|
151
|
+
}
|
|
149
152
|
|
|
153
|
+
this._instance.onerror = (e) => {
|
|
150
154
|
this.emit('error', e, [])
|
|
151
155
|
}
|
|
152
156
|
|
|
153
157
|
this._instance.onclose = (e) => {
|
|
154
|
-
console.log('onclose', e)
|
|
155
|
-
|
|
156
158
|
switch(e.code){
|
|
157
159
|
|
|
158
160
|
case 1002:
|
|
@@ -164,6 +166,9 @@ class WSS extends EventEmitter2{
|
|
|
164
166
|
|
|
165
167
|
default:
|
|
166
168
|
this.emit('disconnect', null, [])
|
|
169
|
+
|
|
170
|
+
const retryAfter = (num => num > 60000 ? 60000 : num)(import.meta.env.DEV ? 1000 : Math.pow(1.2, ++this._retryCount) * 1000)
|
|
171
|
+
window.setTimeout(() => this.connect(true), retryAfter)
|
|
167
172
|
break
|
|
168
173
|
}
|
|
169
174
|
};
|
|
@@ -185,6 +190,7 @@ class WSS extends EventEmitter2{
|
|
|
185
190
|
|
|
186
191
|
sendSync(path, params, cb, err, override){
|
|
187
192
|
if(!this._instance || this._instance.readyState > 1){
|
|
193
|
+
this._pendingSend.push({ path, params, cb, err })
|
|
188
194
|
return
|
|
189
195
|
}
|
|
190
196
|
else if(!this._instance.isAuth){
|
|
@@ -205,7 +211,6 @@ class WSS extends EventEmitter2{
|
|
|
205
211
|
params
|
|
206
212
|
})
|
|
207
213
|
.then(async(dataUrlObj) => {
|
|
208
|
-
|
|
209
214
|
const binaryData = await this.toBinaryData(dataUrlObj)
|
|
210
215
|
this._instance.send(binaryData)
|
|
211
216
|
|
|
@@ -217,12 +222,12 @@ class WSS extends EventEmitter2{
|
|
|
217
222
|
t1: new Date().getTime()
|
|
218
223
|
}
|
|
219
224
|
|
|
225
|
+
/*const timeout = (override ?? {}).timeout ?? this._opt.timeout
|
|
220
226
|
setTimeout(() => {
|
|
221
227
|
if(this._callbacks[_requestId] && this._instance.readyState === 1){
|
|
222
228
|
err({ message: 'Timeout' })
|
|
223
|
-
delete this._callbacks[_requestId]
|
|
224
229
|
}
|
|
225
|
-
},
|
|
230
|
+
}, timeout)*/
|
|
226
231
|
})
|
|
227
232
|
}
|
|
228
233
|
|
|
@@ -243,7 +248,7 @@ class WSS extends EventEmitter2{
|
|
|
243
248
|
return (this._instance ?? {}).readyState
|
|
244
249
|
}
|
|
245
250
|
|
|
246
|
-
async ping(timeout =
|
|
251
|
+
async ping(timeout = 3000){
|
|
247
252
|
return new Promise(async (resolve, reject) => {
|
|
248
253
|
|
|
249
254
|
this._pinging = true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="$style.comp">
|
|
3
3
|
|
|
4
|
-
<div class="flex flex-col gap-4">
|
|
4
|
+
<div class="p-6 py-4 flex flex-col gap-4">
|
|
5
5
|
|
|
6
6
|
<div>
|
|
7
7
|
<label class="flex-1 text-text-400">Text</label>
|
|
@@ -37,11 +37,12 @@
|
|
|
37
37
|
</div>
|
|
38
38
|
</div>
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
<ComponentSetting2 :item="item"
|
|
41
|
+
:view-type="viewType"
|
|
42
|
+
:view-types="viewTypes"
|
|
43
|
+
:view-index="viewIndex"
|
|
44
|
+
defaultDisplay="block"
|
|
45
|
+
@change="$emit('change')" />
|
|
45
46
|
|
|
46
47
|
</div>
|
|
47
48
|
</template>
|
|
@@ -54,14 +55,16 @@ export default{
|
|
|
54
55
|
|
|
55
56
|
props: {
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
item: {
|
|
59
|
+
type: Object,
|
|
60
|
+
required: true
|
|
61
|
+
},
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
viewType: String,
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
viewIndex: Number,
|
|
66
|
+
|
|
67
|
+
viewTypes: Array,
|
|
65
68
|
|
|
66
69
|
},
|
|
67
70
|
|
|
@@ -88,7 +91,7 @@ export default{
|
|
|
88
91
|
<style module>
|
|
89
92
|
|
|
90
93
|
.comp{
|
|
91
|
-
|
|
94
|
+
@apply flex flex-col divide-y divide-border-50;
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
</style>
|