mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-06 23:21:16 +08:00
Merge pull request #911 from nagisa77/feature/sidebar-logic
feat: 侧边栏按钮样式逻辑修改
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
<div class="article-category-container" v-if="category">
|
||||
<div class="article-info-item" @click="gotoCategory">
|
||||
<BaseImage
|
||||
v-if="category.smallIcon"
|
||||
v-if="isImageIcon(category.smallIcon)"
|
||||
class="article-info-item-img"
|
||||
:src="category.smallIcon"
|
||||
:alt="category.name"
|
||||
/>
|
||||
<component v-else :is="category.smallIcon || category.icon" class="article-info-item-img" />
|
||||
<div class="article-info-item-text">{{ category.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -22,6 +23,11 @@ const gotoCategory = async () => {
|
||||
const value = encodeURIComponent(props.category.id ?? props.category.name)
|
||||
await navigateTo({ path: '/', query: { category: value } }, { replace: true })
|
||||
}
|
||||
|
||||
const isImageIcon = (icon) => {
|
||||
if (!icon) return false
|
||||
return /^https?:\/\//.test(icon) || icon.startsWith('/')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -7,11 +7,17 @@
|
||||
@click="gotoTag(tag)"
|
||||
>
|
||||
<BaseImage
|
||||
v-if="tag.smallIcon"
|
||||
v-if="isImageIcon(tag.smallIcon)"
|
||||
class="article-info-item-img"
|
||||
:src="tag.smallIcon"
|
||||
:alt="tag.name"
|
||||
/>
|
||||
<component
|
||||
v-else-if="tag.smallIcon || tag.icon"
|
||||
:is="tag.smallIcon || tag.icon"
|
||||
class="article-info-item-img"
|
||||
/>
|
||||
<tag-one v-else class="article-info-item-img" />
|
||||
<div class="article-info-item-text">{{ tag.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -26,6 +32,11 @@ const gotoTag = async (tag) => {
|
||||
const value = encodeURIComponent(tag.id ?? tag.name)
|
||||
await navigateTo({ path: '/', query: { tags: value } }, { replace: true })
|
||||
}
|
||||
|
||||
const isImageIcon = (icon) => {
|
||||
if (!icon) return false
|
||||
return /^https?:\/\//.test(icon) || icon.startsWith('/')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -122,6 +122,11 @@
|
||||
class="section-item-icon"
|
||||
:alt="t.name"
|
||||
/>
|
||||
<component
|
||||
v-else-if="t.smallIcon || t.icon"
|
||||
:is="t.smallIcon || t.icon"
|
||||
class="section-item-icon"
|
||||
/>
|
||||
<tag-one v-else class="section-item-icon" />
|
||||
<span class="section-item-text"
|
||||
>{{ t.name }} <span class="section-item-text-count">x {{ t.count }}</span></span
|
||||
|
||||
@@ -63,6 +63,16 @@ import {
|
||||
History,
|
||||
Lightning,
|
||||
PeoplesTwo,
|
||||
Code,
|
||||
GoodTwo,
|
||||
Twitter,
|
||||
Bitcoin,
|
||||
Fire,
|
||||
Communication,
|
||||
WaterLevel,
|
||||
RobotOne,
|
||||
Server,
|
||||
Protection,
|
||||
} from '@icon-park/vue-next'
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
@@ -129,4 +139,14 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
nuxtApp.vueApp.component('HistoryIcon', History)
|
||||
nuxtApp.vueApp.component('Lightning', Lightning)
|
||||
nuxtApp.vueApp.component('PeoplesTwo', PeoplesTwo)
|
||||
nuxtApp.vueApp.component('CodeIcon', Code)
|
||||
nuxtApp.vueApp.component('GoodTwo', GoodTwo)
|
||||
nuxtApp.vueApp.component('Twitter', Twitter)
|
||||
nuxtApp.vueApp.component('Bitcoin', Bitcoin)
|
||||
nuxtApp.vueApp.component('Fire', Fire)
|
||||
nuxtApp.vueApp.component('Communication', Communication)
|
||||
nuxtApp.vueApp.component('WaterLevel', WaterLevel)
|
||||
nuxtApp.vueApp.component('RobotOne', RobotOne)
|
||||
nuxtApp.vueApp.component('ServerIcon', Server)
|
||||
nuxtApp.vueApp.component('Protection', Protection)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user