@tailor-cms/tce-preview-runtime 0.0.27 → 0.0.28

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-cms/tce-preview-runtime",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "dependencies": {
5
5
  "@mdi/font": "^7.0.96",
6
6
  "@vitejs/plugin-vue": "4.3.4",
package/src/App.vue CHANGED
@@ -17,13 +17,19 @@ onMounted(async () => {
17
17
  });
18
18
  });
19
19
 
20
+ function timeout(ms: number) {
21
+ return new Promise((resolve) => setTimeout(resolve, ms));
22
+ }
23
+
20
24
  async function getElement() {
21
25
  try {
22
26
  const response = await api('content-element').json();
23
27
  return response || {};
24
28
  } catch (error) {
25
29
  console.log('Error on element get', error);
26
- return { msg: 'Error upon retrieving element state' };
30
+ await timeout(2000);
31
+ console.log('Retrying element get...');
32
+ return getElement();
27
33
  }
28
34
  }
29
35
  </script>
@@ -12,19 +12,37 @@ const props = defineProps<{ element: any }>();
12
12
  const { isDark } = useGlobalState();
13
13
  const isLoaded = ref(false);
14
14
 
15
+ const runtimeId = import.meta.env.VITE_RUNTIME_ID;
16
+ const bootRegistry = JSON.parse(
17
+ localStorage.getItem('element-kit-boot') || '{}',
18
+ );
19
+ const isFirstBoot = !bootRegistry[runtimeId];
20
+
15
21
  onMounted(() => {
16
22
  // Client/server vertical split
17
23
  Split([`#panelTop`, `#panelBottom`], {
18
24
  direction: 'vertical',
19
25
  sizes: [70, 30],
20
26
  });
21
- setTimeout(() => (isLoaded.value = true), 5000);
27
+ setTimeout(
28
+ () => {
29
+ isLoaded.value = true;
30
+ localStorage.setItem(
31
+ 'element-kit-boot',
32
+ JSON.stringify({
33
+ ...bootRegistry,
34
+ [runtimeId]: true,
35
+ }),
36
+ );
37
+ },
38
+ isFirstBoot ? 17000 : 5000,
39
+ );
22
40
  });
23
41
  </script>
24
42
 
25
43
  <template>
26
44
  <main :class="{ 'dark-theme': isDark }">
27
- <SplashLoader v-show="!isLoaded" />
45
+ <SplashLoader v-show="!isLoaded" :is-first-boot="isFirstBoot" />
28
46
  <PreviewPanel id="panelTop" :is-loaded="isLoaded" />
29
47
  <BottomPanel
30
48
  id="panelBottom"
@@ -7,6 +7,11 @@
7
7
  </div>
8
8
  <div class="splash-loader__text text-body-1">
9
9
  <div>Booting Teaching Element Kit....</div>
10
+ <v-progress-linear
11
+ v-if="isFirstBoot"
12
+ :model-value="progress"
13
+ class="my-3"
14
+ />
10
15
  <div class="font-weight-bold">Alpha preview v0.0.1</div>
11
16
  </div>
12
17
  </div>
@@ -19,6 +24,10 @@ import logoUrl from '../assets/logo.png';
19
24
 
20
25
  export default {
21
26
  props: {
27
+ isFirstBoot: {
28
+ type: Boolean,
29
+ required: true,
30
+ },
22
31
  logo: {
23
32
  type: String,
24
33
  default: logoUrl,
@@ -32,8 +41,20 @@ export default {
32
41
  default: '#fff',
33
42
  },
34
43
  },
35
- created() {
44
+ data: () => ({
45
+ interval: 0,
46
+ progress: 0,
47
+ }),
48
+ mounted() {
36
49
  this.setColor();
50
+ if (!this.isFirstBoot) return;
51
+ this.interval = setInterval(() => {
52
+ this.progress += 1;
53
+ if (this.progress === 100) clearInterval(this.interval);
54
+ }, 160);
55
+ },
56
+ beforeUnmount() {
57
+ clearInterval(this.interval);
37
58
  },
38
59
  methods: {
39
60
  setColor() {