@tailor-cms/tce-preview-runtime 0.5.1 → 0.5.2
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 +6 -0
- package/package.json +2 -1
- package/src/App.vue +1 -1
- package/src/components/AppBar.vue +8 -8
- package/src/components/MainLayout.vue +17 -38
- package/src/components/SplashLoader.vue +21 -53
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -14,13 +14,13 @@ const appUrl = new URL(window.location.href);
|
|
|
14
14
|
const apiPrefix = '/tce-server';
|
|
15
15
|
const api = ky.create({ prefixUrl: apiPrefix });
|
|
16
16
|
const wsProtocol = appUrl.protocol === 'http:' ? 'ws:' : 'wss:';
|
|
17
|
-
const ws = new WebSocket(`${wsProtocol}//${appUrl.host}${apiPrefix}`);
|
|
18
17
|
|
|
19
18
|
const element = ref<ContentElement>();
|
|
20
19
|
const userState = ref({});
|
|
21
20
|
|
|
22
21
|
onMounted(async () => {
|
|
23
22
|
await getElement();
|
|
23
|
+
const ws = new WebSocket(`${wsProtocol}//${appUrl.host}${apiPrefix}`);
|
|
24
24
|
ws.addEventListener('message', (message) => {
|
|
25
25
|
const event = JSON.parse(message.data);
|
|
26
26
|
const elementUid = element.value?.uid;
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import logoUrl from '../assets/logo.png';
|
|
3
|
-
import { useGlobalState } from '../state';
|
|
4
|
-
import { version } from './../../package.json';
|
|
5
|
-
|
|
6
|
-
const { showEdit, showDisplay, showBothComponents } = useGlobalState();
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
1
|
<template>
|
|
10
2
|
<VAppBar color="blue-grey-darken-4" elevation="6">
|
|
11
3
|
<template #prepend>
|
|
@@ -47,3 +39,11 @@ const { showEdit, showDisplay, showBothComponents } = useGlobalState();
|
|
|
47
39
|
</VBtn>
|
|
48
40
|
</VAppBar>
|
|
49
41
|
</template>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
import logoUrl from '../assets/logo.png';
|
|
45
|
+
import { useGlobalState } from '../state';
|
|
46
|
+
import { version } from './../../package.json';
|
|
47
|
+
|
|
48
|
+
const { showEdit, showDisplay, showBothComponents } = useGlobalState();
|
|
49
|
+
</script>
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<main :class="{ 'dark-theme': isDark }">
|
|
3
|
+
<SplashLoader :is-visible="!isLoaded" />
|
|
4
|
+
<PreviewPanel id="panelTop" :is-loaded="isLoaded" />
|
|
5
|
+
<BottomPanel
|
|
6
|
+
id="panelBottom"
|
|
7
|
+
:element="props.element"
|
|
8
|
+
:is-loaded="isLoaded"
|
|
9
|
+
:user-state="props.userState"
|
|
10
|
+
class="preview-panel-bottom"
|
|
11
|
+
@reset-element="$emit('resetElement')"
|
|
12
|
+
@reset-state="$emit('resetState')"
|
|
13
|
+
/>
|
|
14
|
+
</main>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
1
17
|
<script setup lang="ts">
|
|
2
18
|
import { onMounted, ref } from 'vue';
|
|
3
19
|
import Split from 'split.js';
|
|
@@ -13,53 +29,16 @@ const props = defineProps<{ element: any; userState: any }>();
|
|
|
13
29
|
const { isDark } = useGlobalState();
|
|
14
30
|
const isLoaded = ref(false);
|
|
15
31
|
|
|
16
|
-
const runtimeId = import.meta.env.VITE_RUNTIME_ID;
|
|
17
|
-
const bootRegistry = JSON.parse(
|
|
18
|
-
localStorage.getItem('element-kit-boot') || '{}',
|
|
19
|
-
);
|
|
20
|
-
const isFirstBoot = !bootRegistry[runtimeId];
|
|
21
|
-
if (isFirstBoot) {
|
|
22
|
-
localStorage.setItem(
|
|
23
|
-
'element-kit-boot',
|
|
24
|
-
JSON.stringify({
|
|
25
|
-
...bootRegistry,
|
|
26
|
-
[runtimeId]: true,
|
|
27
|
-
}),
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
32
|
onMounted(() => {
|
|
32
33
|
// Client/server vertical split
|
|
33
34
|
Split([`#panelTop`, `#panelBottom`], {
|
|
34
35
|
direction: 'vertical',
|
|
35
36
|
sizes: [70, 30],
|
|
36
37
|
});
|
|
37
|
-
setTimeout(
|
|
38
|
-
() => {
|
|
39
|
-
isLoaded.value = true;
|
|
40
|
-
if (isFirstBoot) document.location.reload();
|
|
41
|
-
},
|
|
42
|
-
isFirstBoot ? 25000 : 5000,
|
|
43
|
-
);
|
|
38
|
+
setTimeout(() => { isLoaded.value = true; }, 5000);
|
|
44
39
|
});
|
|
45
40
|
</script>
|
|
46
41
|
|
|
47
|
-
<template>
|
|
48
|
-
<main :class="{ 'dark-theme': isDark }">
|
|
49
|
-
<SplashLoader :is-first-boot="isFirstBoot" :is-visible="!isLoaded" />
|
|
50
|
-
<PreviewPanel id="panelTop" :is-loaded="isLoaded" />
|
|
51
|
-
<BottomPanel
|
|
52
|
-
id="panelBottom"
|
|
53
|
-
:element="props.element"
|
|
54
|
-
:is-loaded="isLoaded"
|
|
55
|
-
:user-state="props.userState"
|
|
56
|
-
class="preview-panel-bottom"
|
|
57
|
-
@reset-element="$emit('resetElement')"
|
|
58
|
-
@reset-state="$emit('resetState')"
|
|
59
|
-
/>
|
|
60
|
-
</main>
|
|
61
|
-
</template>
|
|
62
|
-
|
|
63
42
|
<style>
|
|
64
43
|
main {
|
|
65
44
|
height: calc(100vh - var(--nav-height));
|
|
@@ -7,11 +7,6 @@
|
|
|
7
7
|
</div>
|
|
8
8
|
<div class="splash-loader__text text-body-1">
|
|
9
9
|
<div>Booting Content Element Kit....</div>
|
|
10
|
-
<v-progress-linear
|
|
11
|
-
v-if="isFirstBoot"
|
|
12
|
-
:model-value="progress"
|
|
13
|
-
class="my-3"
|
|
14
|
-
/>
|
|
15
10
|
<div class="font-weight-bold">Beta preview v{{ version }}</div>
|
|
16
11
|
</div>
|
|
17
12
|
</div>
|
|
@@ -19,57 +14,30 @@
|
|
|
19
14
|
</transition>
|
|
20
15
|
</template>
|
|
21
16
|
|
|
22
|
-
<script lang="ts">
|
|
17
|
+
<script lang="ts" setup>
|
|
18
|
+
import { onMounted } from 'vue';
|
|
19
|
+
|
|
23
20
|
import logoUrl from '../assets/logo.png';
|
|
24
21
|
import { version } from './../../package.json';
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
backgroundColor: {
|
|
45
|
-
type: String,
|
|
46
|
-
default: '#fff',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
data: () => ({
|
|
50
|
-
interval: 0,
|
|
51
|
-
progress: 0,
|
|
52
|
-
}),
|
|
53
|
-
computed: {
|
|
54
|
-
version: () => version,
|
|
55
|
-
},
|
|
56
|
-
mounted() {
|
|
57
|
-
this.setColor();
|
|
58
|
-
if (!this.isFirstBoot) return;
|
|
59
|
-
this.interval = setInterval(() => {
|
|
60
|
-
this.progress += 1;
|
|
61
|
-
if (this.progress === 100) clearInterval(this.interval);
|
|
62
|
-
}, 200);
|
|
63
|
-
},
|
|
64
|
-
beforeUnmount() {
|
|
65
|
-
clearInterval(this.interval);
|
|
66
|
-
},
|
|
67
|
-
methods: {
|
|
68
|
-
setColor() {
|
|
69
|
-
document.documentElement.style.setProperty('--splash-color', this.color);
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
};
|
|
23
|
+
interface Props {
|
|
24
|
+
isVisible: boolean;
|
|
25
|
+
logo?: string;
|
|
26
|
+
color?: string;
|
|
27
|
+
backgroundColor?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
31
|
+
isVisible: true,
|
|
32
|
+
logo: logoUrl,
|
|
33
|
+
color: '#00bfa5',
|
|
34
|
+
backgroundColor: '#fff',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
onMounted(() => {
|
|
38
|
+
const color = props.color || '#00bfa5';
|
|
39
|
+
document.documentElement.style.setProperty('--splash-color', color);
|
|
40
|
+
});
|
|
73
41
|
</script>
|
|
74
42
|
|
|
75
43
|
<style lang="scss" scoped>
|