ref: main page nav active

This commit is contained in:
KUN1007 2023-08-25 17:49:49 +08:00
parent 4db6747d60
commit 6e6c0a77c8
4 changed files with 28 additions and 42 deletions

View file

@ -22,7 +22,7 @@ export interface HomeTopicRequestData {
page: number page: number
limit: number limit: number
sortField: string sortField: string
sortOrder: 'asc' | 'desc' sortOrder: string
} }
export interface HomeTopic { export interface HomeTopic {

View file

@ -57,22 +57,6 @@ const debouncedSearch = debounce((inputValue: string) => {
/> />
</span> </span>
</div> </div>
<div>
<span
>啊这可海星啊这可海星啊这可海星啊这可海星啊这可海星<Icon
class="delete"
icon="line-md:close-circle"
/>
</span>
</div>
<div>
<span
>啊这可海星啊这可海星啊这可海星啊这可海星啊这可海星<Icon
class="delete"
icon="line-md:close-circle"
/>
</span>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -11,7 +11,8 @@ import {
export const useKUNGalgameHomeStore = defineStore({ export const useKUNGalgameHomeStore = defineStore({
id: 'home', id: 'home',
persist: true, persist: true,
state: (): HomeTopicRequestData => ({ state: () => ({
// 搜索框的 store
/** /**
* @param {String} keywords - * @param {String} keywords -
* @param {Array} category - Galgame, Technique, Others * @param {Array} category - Galgame, Technique, Others
@ -27,12 +28,15 @@ export const useKUNGalgameHomeStore = defineStore({
limit: 17, limit: 17,
sortField: 'updated', sortField: 'updated',
sortOrder: 'desc', sortOrder: 'desc',
// 其它的 store
isActiveMainPageAside: true,
}), }),
getters: {}, getters: {},
actions: { actions: {
// 获取首页话题 // 获取首页话题
getHomeTopic(): Promise<HomeTopicResponseData> { getHomeTopic(): Promise<HomeTopicResponseData> {
const requestData = { const requestData: HomeTopicRequestData = {
keywords: this.keywords, keywords: this.keywords,
category: this.category, category: this.category,
page: this.page, page: this.page,

View file

@ -7,28 +7,20 @@ import AsideActive from './components/AsideActive.vue'
import Aside from './components/Aside.vue' import Aside from './components/Aside.vue'
// // store
const asideBarStatus = (): boolean => { import { useKUNGalgameHomeStore } from '@/store/modules/home'
if (localStorage.getItem('KUNGalgame-main-page-aside') === 'true') { import { storeToRefs } from 'pinia'
return true
} else { const { isActiveMainPageAside } = storeToRefs(useKUNGalgameHomeStore())
return false
}
}
const isActive = ref<boolean>(asideBarStatus())
const asideWidth = ref('240px') const asideWidth = ref('240px')
const handleFold = () => { const handleFold = () => {
isActive.value = !isActive.value isActiveMainPageAside.value = !isActiveMainPageAside.value
} }
watch( watch(
isActive, isActiveMainPageAside,
() => { () => {
localStorage.setItem( asideWidth.value = isActiveMainPageAside.value ? '240px' : '40px'
'KUNGalgame-main-page-aside',
isActive.value.toString()
)
asideWidth.value = isActive.value ? '240px' : '40px'
}, },
{ immediate: true } { immediate: true }
) )
@ -40,20 +32,26 @@ watch(
<!-- 侧边栏交互 --> <!-- 侧边栏交互 -->
<div class="nav-aside" @click="handleFold"> <div class="nav-aside" @click="handleFold">
<!-- fa 箭头图标字体 --> <!-- fa 箭头图标字体 -->
<Icon icon="line-md:arrow-left" style="font-size: 17px" v-if="isActive" /> <Icon
icon="line-md:arrow-left"
style="font-size: 17px"
v-if="isActiveMainPageAside"
/>
<Icon <Icon
icon="line-md:arrow-right" icon="line-md:arrow-right"
style="font-size: 17px" style="font-size: 17px"
v-if="!isActive" v-if="!isActiveMainPageAside"
/> />
<span v-if="isActive">{{ $tm('mainPage.asideActive.fold') }}</span> <span v-if="isActiveMainPageAside">{{
$tm('mainPage.asideActive.fold')
}}</span>
</div> </div>
<div class="item-active" v-if="isActive"> <div class="item-active" v-if="isActiveMainPageAside">
<AsideActive :isActive="isActive" /> <AsideActive :isActive="isActiveMainPageAside" />
</div> </div>
<div class="item" v-if="!isActive"> <div class="item" v-if="!isActiveMainPageAside">
<Aside :isActive="!isActive" v-if="!isActive" /> <Aside :isActive="!isActiveMainPageAside" v-if="!isActiveMainPageAside" />
</div> </div>
</div> </div>
</template> </template>