Skip to content

Commit

Permalink
[#58] update setup script for layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreezag committed Mar 3, 2024
1 parent 3a38f6b commit f6171d0
Showing 1 changed file with 37 additions and 45 deletions.
82 changes: 37 additions & 45 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,65 +1,57 @@
<template>
<div class="main-layout">
<LayoutSidebar
class="main-layout__sidebar"
:api-version="apiVersion"
:client-version="clientVersion"
/>

<div class="main-layout__content">
<slot />
</div>
</div>
</template>

<script lang="ts">
import { storeToRefs } from "pinia";
import { defineComponent } from "vue";
<script lang="ts" setup>
import { computed, ref, onMounted } from "vue";
import { LayoutSidebar } from "~/src/widgets/ui";
import { useEvents } from "~/src/shared/lib/use-events";
import { useSettings } from "~/src/shared/lib/use-settings";
import SfdumpWrap from "~/src/shared/lib/vendor/dumper";
import { version } from "../package.json";
import { useSettingsStore } from "~/stores/settings";
export default defineComponent({
components: {
LayoutSidebar,
},
async setup() {
SfdumpWrap(window.document);
SfdumpWrap(window.document);
useSettingsStore();
const settingsStore = useSettingsStore();
const { themeType, isFixedHeader } = storeToRefs(settingsStore);
const {
api: { getVersion },
} = useSettings();
const {
api: { getVersion },
} = useSettings();
const apiVersion = ref("");
const clientVersion = ref(
!version || version === "0.0.1" ? "@dev" : `v${version}`
);
const apiVersion = await getVersion();
const getApiVersion = async () => {
const data = await getVersion();
const { events } = useEvents();
apiVersion.value = String(data).match(/^[0-9.]+.*$/)
? `v${data}`
: `@${data}`;
};
if (!events?.items?.value?.length) {
events.getAll();
}
onMounted(() => {
getApiVersion();
const clientVersion =
!version || version === "0.0.1" ? "@dev" : `v${version}`;
const { events } = useEvents();
return {
themeType,
isFixedHeader,
apiVersion: String(apiVersion).match(/^[0-9.]+.*$/)
? `v${apiVersion}`
: `@${apiVersion}`,
clientVersion,
};
},
if (!events?.items?.value?.length) {
events.getAll();
}
});
</script>

<template>
<div class="main-layout">
<LayoutSidebar
class="main-layout__sidebar"
:api-version="apiVersion"
:client-version="clientVersion"
/>

<div class="main-layout__content">
<slot />
</div>
</div>
</template>

<style lang="scss" scoped>
@import "assets/mixins";
Expand Down

0 comments on commit f6171d0

Please sign in to comment.