@mixd-id/web-scaffold 0.1.230406242 → 0.1.230406244
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/package.json +1 -1
- package/src/components/Alert.vue +9 -3
- package/src/components/DayTimeRange.vue +126 -0
- package/src/components/Modal.vue +2 -0
- package/src/components/Textarea.vue +3 -1
- package/src/index.js +1 -0
- package/src/themes/default/index.js +2 -2
- package/src/utils/helpers.js +22 -0
- package/src/utils/wss.js +14 -2
- package/src/utils/wss.mjs +10 -8
package/package.json
CHANGED
package/src/components/Alert.vue
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
<h5 :class="$style.title">{{ title }}</h5>
|
|
16
16
|
</div>
|
|
17
17
|
|
|
18
|
-
<div :class="$style.details"
|
|
19
|
-
<p class="text-center break-words">{{ message }}</p>
|
|
18
|
+
<div :class="$style.details">
|
|
19
|
+
<p class="text-center break-words" v-if="message">{{ message }}</p>
|
|
20
|
+
<p class="text-center break-words max-w-[420px]" v-if="stack">{{ stack }}</p>
|
|
20
21
|
</div>
|
|
21
22
|
|
|
22
23
|
<div :class="$style.details" v-if="details">
|
|
@@ -128,7 +129,6 @@ export default{
|
|
|
128
129
|
},
|
|
129
130
|
|
|
130
131
|
message(){
|
|
131
|
-
|
|
132
132
|
if(this.err.errors){
|
|
133
133
|
return typeof this.err.errors === 'object' && Object.keys(this.err.errors).length > 0 ?
|
|
134
134
|
Object.values(this.err.errors).join("\n") :
|
|
@@ -150,6 +150,12 @@ export default{
|
|
|
150
150
|
}
|
|
151
151
|
},
|
|
152
152
|
|
|
153
|
+
stack(){
|
|
154
|
+
if(this.err.stack){
|
|
155
|
+
return this.err.stack
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
|
|
153
159
|
details(){
|
|
154
160
|
|
|
155
161
|
if(this.alert.details && typeof this.alert.details === 'object'){
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="$style.comp">
|
|
3
|
+
<div v-for="(val, idx) in value" class="flex flex-row items-start">
|
|
4
|
+
<button type="button" @click="value.splice(idx, 1);updateModelValue()" class="p-2">
|
|
5
|
+
<svg width="16" height="16" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 464c-118.7 0-216-96.1-216-216 0-118.7 96.1-216 216-216 118.7 0 216 96.1 216 216 0 118.7-96.1 216-216 216zm94.8-285.3L281.5 256l69.3 69.3c4.7 4.7 4.7 12.3 0 17l-8.5 8.5c-4.7 4.7-12.3 4.7-17 0L256 281.5l-69.3 69.3c-4.7 4.7-12.3 4.7-17 0l-8.5-8.5c-4.7-4.7-4.7-12.3 0-17l69.3-69.3-69.3-69.3c-4.7-4.7-4.7-12.3 0-17l8.5-8.5c4.7-4.7 12.3-4.7 17 0l69.3 69.3 69.3-69.3c4.7-4.7 12.3-4.7 17 0l8.5 8.5c4.6 4.7 4.6 12.3 0 17z"/></svg>
|
|
6
|
+
</button>
|
|
7
|
+
<div class="pr-2">
|
|
8
|
+
<select v-model="val.key" @change="updateModelValue">
|
|
9
|
+
<option value="*">All Days</option>
|
|
10
|
+
<option value="sun">Sun</option>
|
|
11
|
+
<option value="mon">Mon</option>
|
|
12
|
+
<option value="tue">Tue</option>
|
|
13
|
+
<option value="wed">Wed</option>
|
|
14
|
+
<option value="thu">Thu</option>
|
|
15
|
+
<option value="fri">Fri</option>
|
|
16
|
+
<option value="sat">Sat</option>
|
|
17
|
+
</select>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="flex-1 flex flex-col gap-1 pl-2 border-l-[1px] border-text-100 divide-y divide-text-100">
|
|
20
|
+
<div v-for="(range, i) in val.value" class="flex flex-row">
|
|
21
|
+
<div class="flex-1 flex flex-row">
|
|
22
|
+
<input type="time" v-model="val.value[i][0]">
|
|
23
|
+
<div class="py-2">-</div>
|
|
24
|
+
<input type="time" v-model="val.value[i][1]">
|
|
25
|
+
</div>
|
|
26
|
+
<div class="p-2 flex flex-row gap-2">
|
|
27
|
+
<button v-if="val.value.length > 1" type="button" @click="val.value.splice(i, 1)">
|
|
28
|
+
<svg width="14" height="14" class="fill-text-300 hover:fill-red-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M140 274c-6.6 0-12-5.4-12-12v-12c0-6.6 5.4-12 12-12h232c6.6 0 12 5.4 12 12v12c0 6.6-5.4 12-12 12H140zm364-18c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-32 0c0-119.9-97.3-216-216-216-119.9 0-216 97.3-216 216 0 119.9 97.3 216 216 216 119.9 0 216-97.3 216-216z"/></svg>
|
|
29
|
+
</button>
|
|
30
|
+
<button type="button" @click="val.value.push([ '00:00', '23:59' ])">
|
|
31
|
+
<svg width="14" height="14" class="fill-text-300 hover:fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M443.5 248.5l-7.1-7.1c-4.7-4.7-12.3-4.7-17 0L241 419.9V44c0-6.6-5.4-12-12-12h-10c-6.6 0-12 5.4-12 12v375.9L28.5 241.4c-4.7-4.7-12.3-4.7-17 0l-7.1 7.1c-4.7 4.7-4.7 12.3 0 17l211 211.1c4.7 4.7 12.3 4.7 17 0l211-211.1c4.8-4.8 4.8-12.3.1-17z"/></svg>
|
|
32
|
+
</button>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="flex justify-center">
|
|
38
|
+
<button type="button" @click="add" class="p-2">
|
|
39
|
+
<svg width="16" height="16" class="fill-primary" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M384 250v12c0 6.6-5.4 12-12 12h-98v98c0 6.6-5.4 12-12 12h-12c-6.6 0-12-5.4-12-12v-98h-98c-6.6 0-12-5.4-12-12v-12c0-6.6 5.4-12 12-12h98v-98c0-6.6 5.4-12 12-12h12c6.6 0 12 5.4 12 12v98h98c6.6 0 12 5.4 12 12zm120 6c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-32 0c0-119.9-97.3-216-216-216-119.9 0-216 97.3-216 216 0 119.9 97.3 216 216 216 119.9 0 216-97.3 216-216z"/></svg>
|
|
40
|
+
</button>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
|
|
47
|
+
export default{
|
|
48
|
+
|
|
49
|
+
emits: [ 'update:modelValue' ],
|
|
50
|
+
|
|
51
|
+
props: {
|
|
52
|
+
|
|
53
|
+
modelValue: {
|
|
54
|
+
type: Object
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
data(){
|
|
60
|
+
return {
|
|
61
|
+
value: [
|
|
62
|
+
{ key:'mon', value:[ [ '08:00', '10:00' ], [ '12:00', '14:00' ] ] }
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
methods: {
|
|
68
|
+
|
|
69
|
+
add(){
|
|
70
|
+
|
|
71
|
+
this.value.push({ value:[ [ '00:00', '23:59'] ] })
|
|
72
|
+
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
updateModelValue(){
|
|
76
|
+
const modelValue = {}
|
|
77
|
+
this.value.forEach( (val) => {
|
|
78
|
+
modelValue[val.key] = val.value
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
console.log(modelValue)
|
|
82
|
+
|
|
83
|
+
this.$emit('update:modelValue', modelValue)
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
updateValue(){
|
|
87
|
+
this.value = []
|
|
88
|
+
for( const key in this.modelValue ){
|
|
89
|
+
this.value.push({ key, value: this.modelValue[key] })
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
mounted() {
|
|
96
|
+
this.updateValue()
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
watch: {
|
|
100
|
+
|
|
101
|
+
modelValue(){
|
|
102
|
+
this.updateValue()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<style module>
|
|
112
|
+
|
|
113
|
+
.comp{
|
|
114
|
+
@apply border-[1px] border-text-200 bg-base-50 rounded-lg;
|
|
115
|
+
@apply inline-flex flex-col divide-y divide-text-100;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.comp select{
|
|
119
|
+
@apply bg-transparent p-2 outline-none;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.comp input{
|
|
123
|
+
@apply bg-transparent p-1 outline-none appearance-none;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
</style>
|
package/src/components/Modal.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="computedClass">
|
|
3
3
|
<slot name="start"></slot>
|
|
4
|
-
<textarea :maxlength="maxlength"
|
|
4
|
+
<textarea :maxlength="maxlength" :class="itemClass"
|
|
5
5
|
:placeholder="placeholder" :rows="rows" ref="input" @focus="isActive = true" @blur="onBlur" @input="onInput"
|
|
6
6
|
:value="modelValue" :readonly="Boolean(readonly)" />
|
|
7
7
|
<div v-if="state === -2 && !!(errors)">
|
|
@@ -29,6 +29,8 @@ export default{
|
|
|
29
29
|
|
|
30
30
|
customClass: String,
|
|
31
31
|
|
|
32
|
+
itemClass: String,
|
|
33
|
+
|
|
32
34
|
state: {
|
|
33
35
|
type: Number,
|
|
34
36
|
default: 1 // 1:normal, -1:disabled, -2:error
|
package/src/index.js
CHANGED
|
@@ -474,6 +474,7 @@ export default{
|
|
|
474
474
|
app.component('ObjectTree', defineAsyncComponent(() => import("./components/ObjectTree.vue")))
|
|
475
475
|
app.component('FBLogin', defineAsyncComponent(() => import("./components/FBLogin.vue")))
|
|
476
476
|
app.component('GSignIn', defineAsyncComponent(() => import("./components/GSignIn.vue")))
|
|
477
|
+
app.component('DayTimeRange', defineAsyncComponent(() => import("./components/DayTimeRange.vue")))
|
|
477
478
|
|
|
478
479
|
app.component('AhrefSetting', defineAsyncComponent(() => import("./widgets/AhrefSetting.vue")))
|
|
479
480
|
app.component('ArticleSetting', defineAsyncComponent(() => import("./widgets/ArticleSetting.vue")))
|
|
@@ -23,7 +23,7 @@ const plugin = Plugin(function({ addBase, config, theme }) {
|
|
|
23
23
|
'--base-500': '255, 255, 255',
|
|
24
24
|
'--base': '236, 236, 236',
|
|
25
25
|
|
|
26
|
-
"--text-50": '
|
|
26
|
+
"--text-50": '229, 229, 229',
|
|
27
27
|
"--text-100": '223, 223, 223',
|
|
28
28
|
"--text-200": '218, 218, 218',
|
|
29
29
|
"--text-300": '191, 191, 191',
|
|
@@ -70,7 +70,7 @@ const plugin = Plugin(function({ addBase, config, theme }) {
|
|
|
70
70
|
"--base-500": '22, 26, 33',
|
|
71
71
|
"--base": '22, 26, 33',
|
|
72
72
|
|
|
73
|
-
"--text-50": '
|
|
73
|
+
"--text-50": '33, 39, 46',
|
|
74
74
|
"--text-100": '48, 54, 61',
|
|
75
75
|
"--text-200": '53, 59, 66',
|
|
76
76
|
"--text-300": '77, 77, 77',
|
package/src/utils/helpers.js
CHANGED
|
@@ -2,6 +2,7 @@ const md5 = require("md5");
|
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const { Op } = module.parent.require('sequelize')
|
|
4
4
|
const axios = module.parent.require('axios')
|
|
5
|
+
const dayjs = module.parent.require('dayjs')
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
const ceil = (num, precision = 0) => {
|
|
@@ -470,6 +471,26 @@ const datasourceLoad = async ({ datasource, Models }) => {
|
|
|
470
471
|
return obj
|
|
471
472
|
}
|
|
472
473
|
|
|
474
|
+
const dayTimeRange = (params, value) => {
|
|
475
|
+
|
|
476
|
+
/*params = {
|
|
477
|
+
'*': [ [ '08:00', '12:00' ], [ '13:00', '18:00' ] ],
|
|
478
|
+
'sat': [ [ '08:00', '12:00' ], [ '13:00', '14:00' ] ],
|
|
479
|
+
}
|
|
480
|
+
value = '2023-02-06 17:59:00'*/
|
|
481
|
+
|
|
482
|
+
if(!value)
|
|
483
|
+
value = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
484
|
+
|
|
485
|
+
const curDay = dayjs(value).format('ddd').toLowerCase()
|
|
486
|
+
const curTime = dayjs(value).format('HH:mm')
|
|
487
|
+
const ranges = params[curDay] ?? params['*']
|
|
488
|
+
|
|
489
|
+
return (ranges ?? []).some((range) => {
|
|
490
|
+
return curTime >= range[0] && curTime <= range[1]
|
|
491
|
+
})
|
|
492
|
+
}
|
|
493
|
+
|
|
473
494
|
|
|
474
495
|
module.exports = {
|
|
475
496
|
ceil,
|
|
@@ -497,4 +518,5 @@ module.exports = {
|
|
|
497
518
|
removeStyleFromTag,
|
|
498
519
|
datasourceGet,
|
|
499
520
|
datasourceLoad,
|
|
521
|
+
dayTimeRange,
|
|
500
522
|
}
|
package/src/utils/wss.js
CHANGED
|
@@ -129,7 +129,15 @@ class WSS extends EventEmitter2{
|
|
|
129
129
|
|
|
130
130
|
socket.on('message', async (binaryData) => {
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
let obj
|
|
133
|
+
try{
|
|
134
|
+
obj = await this.fromBinaryData(binaryData);
|
|
135
|
+
}
|
|
136
|
+
catch(e){
|
|
137
|
+
return socket.close(1002, e.message);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const { _requestId, path, params } = obj
|
|
133
141
|
|
|
134
142
|
let status = 200
|
|
135
143
|
let data
|
|
@@ -142,7 +150,7 @@ class WSS extends EventEmitter2{
|
|
|
142
150
|
}
|
|
143
151
|
}
|
|
144
152
|
catch(e){
|
|
145
|
-
socket.close(1002, e.message);
|
|
153
|
+
return socket.close(1002, e.message);
|
|
146
154
|
}
|
|
147
155
|
break
|
|
148
156
|
|
|
@@ -158,6 +166,10 @@ class WSS extends EventEmitter2{
|
|
|
158
166
|
data = arr.length > 0 ? JSON.parse(JSON.stringify(arr.pop())) : data
|
|
159
167
|
}
|
|
160
168
|
catch(e){
|
|
169
|
+
if(this._opt.debug){
|
|
170
|
+
console.error(e)
|
|
171
|
+
}
|
|
172
|
+
|
|
161
173
|
status = 500
|
|
162
174
|
data = {
|
|
163
175
|
name: e.name,
|
package/src/utils/wss.mjs
CHANGED
|
@@ -121,14 +121,14 @@ class WSS extends EventEmitter2{
|
|
|
121
121
|
this._readyState = 2
|
|
122
122
|
this.send('_auth', this._opt.auth)
|
|
123
123
|
.then(() => {
|
|
124
|
+
this._readyState = 1
|
|
125
|
+
|
|
124
126
|
reconnect ? this.emit('reconnect', null, []) : this.emit('connect', null, [])
|
|
125
127
|
|
|
126
128
|
for(let sendParams of this._pendingSend){
|
|
127
129
|
this.sendSync(sendParams.path, sendParams.params, sendParams.cb, sendParams.err)
|
|
128
130
|
}
|
|
129
131
|
this._pendingSend = []
|
|
130
|
-
|
|
131
|
-
this._readyState = 1
|
|
132
132
|
})
|
|
133
133
|
};
|
|
134
134
|
|
|
@@ -178,24 +178,26 @@ class WSS extends EventEmitter2{
|
|
|
178
178
|
};
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
async reconnect(){
|
|
181
|
+
async reconnect(opt){
|
|
182
182
|
if(this._instance){
|
|
183
183
|
this._instance.close()
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
Object.assign(this._opt, opt)
|
|
187
|
+
|
|
186
188
|
await this.connect(true)
|
|
187
189
|
}
|
|
188
190
|
|
|
189
191
|
sendSync(path, params, cb, err, override){
|
|
190
|
-
if(this._instance.readyState !== 1 && this._readyState !== 1){
|
|
192
|
+
if(this._instance.readyState !== 1 || (path !== '_auth' && this._readyState !== 1)){
|
|
191
193
|
this._pendingSend.push({ path, params, cb, err })
|
|
192
194
|
return
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
if(!navigator.onLine){
|
|
197
|
+
/*if(!navigator.onLine){
|
|
196
198
|
err({ message: 'Unable to send, network disconnected' })
|
|
197
199
|
return
|
|
198
|
-
}
|
|
200
|
+
}*/
|
|
199
201
|
|
|
200
202
|
const _requestId = ++this._counter
|
|
201
203
|
|
|
@@ -216,14 +218,14 @@ class WSS extends EventEmitter2{
|
|
|
216
218
|
t1: new Date().getTime()
|
|
217
219
|
}
|
|
218
220
|
|
|
219
|
-
setTimeout(() => {
|
|
221
|
+
/*setTimeout(() => {
|
|
220
222
|
if(this._callbacks[_requestId]){
|
|
221
223
|
err({ message: 'Timeout' })
|
|
222
224
|
delete this._callbacks[_requestId]
|
|
223
225
|
|
|
224
226
|
this.reconnect()
|
|
225
227
|
}
|
|
226
|
-
}, (override ?? {}).timeout ?? this._opt.timeout)
|
|
228
|
+
}, (override ?? {}).timeout ?? this._opt.timeout)*/
|
|
227
229
|
})
|
|
228
230
|
}
|
|
229
231
|
|