Skip to content

Commit

Permalink
FEATURE(loading): 初始化 Loading 文件
Browse files Browse the repository at this point in the history
  • Loading branch information
SuneBear committed Sep 28, 2023
1 parent 40e04c2 commit 5676b00
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 6 deletions.
11 changes: 11 additions & 0 deletions components/initial-loading.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template lang="pug">
.initial-loading
</template>

<script lang="ts" setup>
</script>

<style lang="stylus">
.initial-loading
null
</style>
7 changes: 7 additions & 0 deletions components/landing-sketch/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const init = ({
scrollContainer = document.body
}) => {
const store = useStore()

console.log('init', scrollContainer)
}
22 changes: 16 additions & 6 deletions pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
<template lang="pug">
.page.page-home
h2 Home
.flex.align-center.my-2
.brand-color.mr-2( :style="{ color: 'var(--brand)' }" ) Brand Color
nuxt-icon( name="youtube" )
.page.page-home( ref="scrollContainer" )
initial-loading

theme-switcher
.sketch-container( ref="sketchContainer" )

.section.section-contact.flex.flex-col.items-center.gap-5vh
business-card
</template>

<script lang="ts" setup>
import { init } from '@/components/landing-sketch'
const scrollContainer = ref<HTMLDivElement>()
const initSketch = () => {
init({
scrollContainer: scrollContainer.value
})
}
onMounted(() => {
initSketch()
})
</script>

<style lang="stylus">
Expand Down
31 changes: 31 additions & 0 deletions stores/use-store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { defineStore } from 'pinia'

type MainState = {
ui: {
isLoading: boolean
loadingProgress: number
},
context: {
lastPath: string
}
}

export const useStore = defineStore('main', {
state: () => ({
ui: {
isLoading: true,
loadingProgress: 0,
},

context: {
lastPath: '/',
},
} as MainState),

getters: {
},

actions: {

}
})

0 comments on commit 5676b00

Please sign in to comment.