@mixd-id/web-scaffold 0.1.2301231340 → 0.1.2301231343
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 +2 -2
- package/src/components/Button.vue +1 -1
- package/src/components/ContextMenu.vue +6 -3
- package/src/components/Image.vue +36 -45
- package/src/components/Textbox.vue +1 -1
- package/src/index.js +105 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mixd-id/web-scaffold",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2301231343",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite serve",
|
|
7
7
|
"build": "vite build",
|
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
"nprogress": "^0.2.0",
|
|
39
39
|
"pinia": "^2.0.14",
|
|
40
40
|
"prismjs": "^1.28.0",
|
|
41
|
-
"sequelize": "^6.29.0",
|
|
42
41
|
"serve-static": "^1.15.0",
|
|
43
42
|
"tailwindcss": "^3.2.4",
|
|
44
43
|
"vue": "^3.2.25",
|
|
@@ -48,6 +47,7 @@
|
|
|
48
47
|
"@vitejs/plugin-vue": "^2.2.0",
|
|
49
48
|
"autoprefixer": "^10.4.4",
|
|
50
49
|
"postcss": "^8.4.12",
|
|
50
|
+
"sequelize": "^6.29.0",
|
|
51
51
|
"vite": "^2.8.0"
|
|
52
52
|
},
|
|
53
53
|
"description": "This scaffold based on express vitejs vuejs",
|
|
@@ -86,7 +86,7 @@ export default{
|
|
|
86
86
|
@apply h-[var(--h-cp)];
|
|
87
87
|
@apply relative flex items-center justify-center;
|
|
88
88
|
@apply whitespace-nowrap text-ellipsis overflow-hidden;
|
|
89
|
-
@apply rounded-
|
|
89
|
+
@apply rounded-lg;
|
|
90
90
|
}
|
|
91
91
|
.button>*:first-child{
|
|
92
92
|
@apply flex items-center justify-center
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<Teleport to=".Y29u">
|
|
3
3
|
<div v-if="!!(computedState)" :class="$style.contextMenu" :style="computedStyle" ref="contextMenu">
|
|
4
4
|
<div :class="bodyClass">
|
|
5
|
-
<slot></slot>
|
|
5
|
+
<slot name="default" :context="context"></slot>
|
|
6
6
|
</div>
|
|
7
7
|
</div>
|
|
8
8
|
</Teleport>
|
|
@@ -50,7 +50,8 @@ export default {
|
|
|
50
50
|
data(){
|
|
51
51
|
return {
|
|
52
52
|
computedStyle: null,
|
|
53
|
-
isOpen: false
|
|
53
|
+
isOpen: false,
|
|
54
|
+
context: null
|
|
54
55
|
}
|
|
55
56
|
},
|
|
56
57
|
|
|
@@ -105,7 +106,7 @@ export default {
|
|
|
105
106
|
this.$refs.contextMenu.classList.remove(this.$style.active)
|
|
106
107
|
},
|
|
107
108
|
|
|
108
|
-
open(caller){
|
|
109
|
+
open(caller, context){
|
|
109
110
|
|
|
110
111
|
if(caller){
|
|
111
112
|
this.isOpen = true
|
|
@@ -118,6 +119,8 @@ export default {
|
|
|
118
119
|
caller = caller.$el ? caller.$el :
|
|
119
120
|
caller instanceof HTMLElement ? caller : null
|
|
120
121
|
|
|
122
|
+
this.context = context
|
|
123
|
+
|
|
121
124
|
if(caller){
|
|
122
125
|
|
|
123
126
|
this.$nextTick(() => {
|
package/src/components/Image.vue
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div :class="
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
<div :class="$style.loading" v-if="loading && spinnerType === 'spinner'">
|
|
9
|
-
<svg class="animate-spin aspect-square w-[15%] text-primary" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
|
|
2
|
+
<div :class="outerClass">
|
|
3
|
+
|
|
4
|
+
<slot v-if="$slots['empty'] && status === 0" name="empty" :instance="this"></slot>
|
|
5
|
+
<slot v-else-if="$slots['loading'] && status === 1" name="loading" :instance="this"></slot>
|
|
6
|
+
<div v-else-if="!$slots['loading'] && status === 1 && spinnerType === 'spinner'" :class="$style.loading">
|
|
7
|
+
<svg class="animate-spin aspect-square w-[15%] min-w-[14px] text-primary" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
|
|
10
8
|
</div>
|
|
9
|
+
<slot v-else-if="$slots['error'] && status === 3" name="error" :instance="this"></slot>
|
|
10
|
+
<img v-else :class="computedClass" :src="actualSrc" ref="img" />
|
|
11
|
+
|
|
12
|
+
<slot :instance="this"></slot>
|
|
13
|
+
|
|
14
|
+
<input v-if="Boolean(editable)" class="hidden" type="file" accept="image/*" ref="file" @change="onChange"/>
|
|
15
|
+
|
|
11
16
|
</div>
|
|
12
17
|
</template>
|
|
13
18
|
|
|
@@ -30,17 +35,11 @@ export default{
|
|
|
30
35
|
|
|
31
36
|
class: String,
|
|
32
37
|
|
|
33
|
-
outerClass: String,
|
|
34
|
-
|
|
35
38
|
editable:{
|
|
36
39
|
type: [ Boolean, String ],
|
|
37
40
|
default: false
|
|
38
41
|
},
|
|
39
42
|
|
|
40
|
-
aspectRatio: {
|
|
41
|
-
type: String
|
|
42
|
-
},
|
|
43
|
-
|
|
44
43
|
src:{
|
|
45
44
|
type: [ String, Object ]
|
|
46
45
|
},
|
|
@@ -59,36 +58,30 @@ export default{
|
|
|
59
58
|
|
|
60
59
|
computed:{
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
outerClass(){
|
|
63
62
|
return [
|
|
64
|
-
this.$style.
|
|
65
|
-
this.
|
|
66
|
-
this.
|
|
63
|
+
this.$style.comp,
|
|
64
|
+
this.class,
|
|
65
|
+
this.status === 1 && this.spinnerType === 'shimmer' && !this.$slots['loading'] ?
|
|
66
|
+
this.$style.shimmer : ''
|
|
67
67
|
]
|
|
68
68
|
.join(' ')
|
|
69
69
|
},
|
|
70
70
|
|
|
71
71
|
computedClass(){
|
|
72
72
|
return [
|
|
73
|
+
this.$style.img,
|
|
73
74
|
this.class
|
|
74
75
|
]
|
|
75
76
|
.join(' ')
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
imageStyle(){
|
|
79
|
-
return {
|
|
80
|
-
...(this.aspectRatio ? { 'aspect-ratio':this.aspectRatio } : {}),
|
|
81
|
-
...(this.actualSrc ? {} : { visibility:'hidden' })
|
|
82
|
-
}
|
|
83
77
|
}
|
|
84
78
|
|
|
85
79
|
},
|
|
86
80
|
|
|
87
81
|
data(){
|
|
88
82
|
return {
|
|
89
|
-
loading:
|
|
90
|
-
actualSrc:
|
|
91
|
-
loaded: false
|
|
83
|
+
status: 0, // 0:empty, 1:loading, 2:image, 3:error
|
|
84
|
+
actualSrc: 'data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
|
|
92
85
|
}
|
|
93
86
|
},
|
|
94
87
|
|
|
@@ -119,9 +112,9 @@ export default{
|
|
|
119
112
|
async loadSrc(){
|
|
120
113
|
|
|
121
114
|
if(typeof this.src === 'string') {
|
|
122
|
-
if (
|
|
123
|
-
this.loaded = true
|
|
115
|
+
if (this.src.startsWith('data:image')) {
|
|
124
116
|
this.actualSrc = this.src
|
|
117
|
+
this.status = 2
|
|
125
118
|
}
|
|
126
119
|
else{
|
|
127
120
|
const src = {}
|
|
@@ -140,38 +133,34 @@ export default{
|
|
|
140
133
|
|
|
141
134
|
var img = new Image()
|
|
142
135
|
img.addEventListener('load', () => {
|
|
143
|
-
this.
|
|
136
|
+
this.status = 2
|
|
144
137
|
this.actualSrc = img.src
|
|
145
|
-
this.loading = false
|
|
146
138
|
})
|
|
147
139
|
img.addEventListener('error', () => {
|
|
148
|
-
this.
|
|
140
|
+
this.status = 3
|
|
149
141
|
this.actualSrc = this.defaultSrc
|
|
150
|
-
this.loading = false
|
|
151
142
|
})
|
|
152
143
|
img.src = src[screens[b]]
|
|
153
|
-
this.
|
|
144
|
+
this.status = 1
|
|
154
145
|
}
|
|
155
146
|
}
|
|
156
147
|
}
|
|
157
148
|
}
|
|
158
|
-
else if(
|
|
149
|
+
else if(this.src instanceof File){
|
|
159
150
|
var reader = new FileReader();
|
|
160
151
|
|
|
161
152
|
reader.addEventListener('load', () => {
|
|
162
|
-
this.
|
|
153
|
+
this.status = 2
|
|
163
154
|
this.actualSrc = reader.result
|
|
164
|
-
this.loading = false
|
|
165
155
|
}, false)
|
|
166
156
|
|
|
167
157
|
reader.addEventListener('error', () => {
|
|
168
|
-
this.
|
|
158
|
+
this.status = 3
|
|
169
159
|
this.actualSrc = this.defaultSrc
|
|
170
|
-
this.loading = false
|
|
171
160
|
})
|
|
172
161
|
|
|
173
162
|
reader.readAsDataURL(this.src)
|
|
174
|
-
this.
|
|
163
|
+
this.status = 1
|
|
175
164
|
}
|
|
176
165
|
}
|
|
177
166
|
|
|
@@ -180,7 +169,6 @@ export default{
|
|
|
180
169
|
watch:{
|
|
181
170
|
|
|
182
171
|
src(to){
|
|
183
|
-
this.loaded = false
|
|
184
172
|
this.loadSrc()
|
|
185
173
|
},
|
|
186
174
|
|
|
@@ -195,10 +183,14 @@ export default{
|
|
|
195
183
|
|
|
196
184
|
<style module>
|
|
197
185
|
|
|
198
|
-
.
|
|
186
|
+
.comp{
|
|
199
187
|
@apply relative;
|
|
200
188
|
}
|
|
201
189
|
|
|
190
|
+
.img{
|
|
191
|
+
@apply object-contain;
|
|
192
|
+
}
|
|
193
|
+
|
|
202
194
|
.editArea{
|
|
203
195
|
@apply absolute top-0 left-0 right-0 bottom-0;
|
|
204
196
|
}
|
|
@@ -209,8 +201,7 @@ export default{
|
|
|
209
201
|
}
|
|
210
202
|
|
|
211
203
|
.shimmer{
|
|
212
|
-
@apply bg-text-
|
|
204
|
+
@apply bg-text-200 animate-pulse;
|
|
213
205
|
}
|
|
214
206
|
|
|
215
|
-
|
|
216
207
|
</style>
|
package/src/index.js
CHANGED
|
@@ -26,10 +26,112 @@ const download = (url, as) => {
|
|
|
26
26
|
}, 100)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
let preloads = []
|
|
30
|
+
|
|
31
|
+
const preload = (params) => {
|
|
32
|
+
|
|
33
|
+
if(!params) return
|
|
34
|
+
|
|
35
|
+
if(typeof params === 'string'){
|
|
36
|
+
params.split(',').forEach((param) => {
|
|
37
|
+
let media, href
|
|
38
|
+
if(param.startsWith('sm:')){
|
|
39
|
+
media = 'sm'
|
|
40
|
+
href = param.substring(param.indexOf(':') + 1)
|
|
41
|
+
}
|
|
42
|
+
else if(param.startsWith('md:')){
|
|
43
|
+
media = 'md'
|
|
44
|
+
href = param.substring(param.indexOf(':') + 1)
|
|
45
|
+
}
|
|
46
|
+
else if(param.startsWith('lg:')){
|
|
47
|
+
media = 'lg'
|
|
48
|
+
href = param.substring(param.indexOf(':') + 1)
|
|
49
|
+
}
|
|
50
|
+
else if(param.startsWith('xl:')){
|
|
51
|
+
media = 'xl'
|
|
52
|
+
href = param.substring(param.indexOf(':') + 1)
|
|
53
|
+
}
|
|
54
|
+
else if(param.startsWith('2xl:')){
|
|
55
|
+
media = '2xl'
|
|
56
|
+
href = param.substring(param.indexOf(':') + 1)
|
|
57
|
+
}
|
|
58
|
+
else{
|
|
59
|
+
media = ''
|
|
60
|
+
href = param
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
switch(media){
|
|
64
|
+
case 'sm':
|
|
65
|
+
media = "(min-width: 640px)"
|
|
66
|
+
break
|
|
67
|
+
case 'md':
|
|
68
|
+
media = "(min-width: 768px)"
|
|
69
|
+
break
|
|
70
|
+
case 'lg':
|
|
71
|
+
media = "(min-width: 1024px)"
|
|
72
|
+
break
|
|
73
|
+
case 'xl':
|
|
74
|
+
media = "(min-width: 1280px)"
|
|
75
|
+
break
|
|
76
|
+
case '2xl':
|
|
77
|
+
media = "(min-width: 1536px)"
|
|
78
|
+
break
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const ext = href.split('.').slice(-1).pop()
|
|
82
|
+
let as
|
|
83
|
+
switch(ext){
|
|
84
|
+
case 'png':
|
|
85
|
+
case 'jpg':
|
|
86
|
+
case 'jpeg':
|
|
87
|
+
case 'webp':
|
|
88
|
+
case 'gif':
|
|
89
|
+
as = 'image'
|
|
90
|
+
break
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if(href && as){
|
|
94
|
+
const preloadObj = {
|
|
95
|
+
href,
|
|
96
|
+
media,
|
|
97
|
+
as
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
preloads.push(preloadObj)
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
else{
|
|
105
|
+
if(Array.isArray(params)){
|
|
106
|
+
preloads.push(...params)
|
|
107
|
+
}
|
|
108
|
+
else{
|
|
109
|
+
preloads.push(params)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const popPreloads = () => {
|
|
115
|
+
|
|
116
|
+
let link = ''
|
|
117
|
+
|
|
118
|
+
preloads.forEach((obj) => {
|
|
119
|
+
let str = `<link rel="preload" href="${obj.href}" as="${obj.as}"`
|
|
120
|
+
if(obj.media)
|
|
121
|
+
str += ` media="${obj.media}"`
|
|
122
|
+
str += ' />'
|
|
123
|
+
|
|
124
|
+
link += str
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
preloads = []
|
|
128
|
+
|
|
129
|
+
return link
|
|
130
|
+
}
|
|
131
|
+
|
|
29
132
|
export default{
|
|
30
133
|
|
|
31
134
|
install: (app, options) => {
|
|
32
|
-
//console.log('installing webfxfy-vue...')
|
|
33
135
|
|
|
34
136
|
let isMobile = ref(calculateIsMobile())
|
|
35
137
|
|
|
@@ -44,6 +146,8 @@ export default{
|
|
|
44
146
|
app.config.globalProperties.uniqid = uniqid
|
|
45
147
|
app.config.globalProperties.isMobile = isMobile
|
|
46
148
|
app.config.globalProperties.$download = download
|
|
149
|
+
app.config.globalProperties.$preload = preload
|
|
150
|
+
app.config.globalProperties.$popPreloads = popPreloads
|
|
47
151
|
|
|
48
152
|
app.component('Alert', defineAsyncComponent(() => import("./components/Alert.vue")))
|
|
49
153
|
app.component('Button', defineAsyncComponent(() => import("./components/Button.vue")))
|