|
@@ -40,7 +40,7 @@
|
|
|
<img :src="getAssetsFile('menu.png')" alt="" @click="show=true"/>
|
|
<img :src="getAssetsFile('menu.png')" alt="" @click="show=true"/>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="user">
|
|
<div class="user">
|
|
|
- <span v-if="!hasToken" class="el-dropdown-link">
|
|
|
|
|
|
|
+ <span v-if="!user.isLogin" class="el-dropdown-link">
|
|
|
<img :src="getAssetsFile('gamer.png')" @click="router.push('/login')" />
|
|
<img :src="getAssetsFile('gamer.png')" @click="router.push('/login')" />
|
|
|
</span>
|
|
</span>
|
|
|
<el-dropdown v-else trigger="click" >
|
|
<el-dropdown v-else trigger="click" >
|
|
@@ -73,8 +73,8 @@
|
|
|
:key="index"
|
|
:key="index"
|
|
|
:title="item.text"
|
|
:title="item.text"
|
|
|
@click="toPath(item.url)"/>
|
|
@click="toPath(item.url)"/>
|
|
|
- <van-cell title="账号设置" @click="toSetting"/>
|
|
|
|
|
- <van-cell v-if="hasToken" title="退出登录" @click="logOut"/>
|
|
|
|
|
|
|
+ <van-cell v-if="user.isLogin" title="账号设置" @click="toSetting"/>
|
|
|
|
|
+ <van-cell v-if="user.isLogin" title="退出登录" @click="logOut"/>
|
|
|
</van-popup>
|
|
</van-popup>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
@@ -98,8 +98,11 @@ const { search } = useStore()
|
|
|
const show = ref(false)
|
|
const show = ref(false)
|
|
|
const game_name = ref(local.get('searchText') || '')
|
|
const game_name = ref(local.get('searchText') || '')
|
|
|
// 绑定el-autocomplete组件
|
|
// 绑定el-autocomplete组件
|
|
|
-const hasToken = ref(sessionStorage.getItem('token'))
|
|
|
|
|
-
|
|
|
|
|
|
|
+const oriMenu = reactive([
|
|
|
|
|
+ { text: '首页', value: 1, url: '/home' },
|
|
|
|
|
+ { text: '分类', value: 2, url: '/cate' },
|
|
|
|
|
+ { text: '我的游戏', value: 3, url: '/my_game' }
|
|
|
|
|
+])
|
|
|
const currentIndex = ref(local.get('headerPath') || '') // 取保存的title
|
|
const currentIndex = ref(local.get('headerPath') || '') // 取保存的title
|
|
|
console.log('currentIndex', currentIndex.value)
|
|
console.log('currentIndex', currentIndex.value)
|
|
|
|
|
|
|
@@ -110,8 +113,9 @@ if (route.query.account) {
|
|
|
|
|
|
|
|
// 顶部导航栏
|
|
// 顶部导航栏
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
- const token = sessionStorage.getItem('token')
|
|
|
|
|
|
|
+ const token = sessionStorage.getItem('token') || ''
|
|
|
if (token) {
|
|
if (token) {
|
|
|
|
|
+ user.isLogin = true
|
|
|
user.getUserProfile()
|
|
user.getUserProfile()
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
@@ -119,11 +123,14 @@ onMounted(() => {
|
|
|
// 退出登录
|
|
// 退出登录
|
|
|
const logOut = () => {
|
|
const logOut = () => {
|
|
|
// console.log(22);
|
|
// console.log(22);
|
|
|
|
|
+ show.value = false
|
|
|
|
|
+ user.menuPath = oriMenu
|
|
|
sessionStorage.removeItem('token')
|
|
sessionStorage.removeItem('token')
|
|
|
- hasToken.value = ''
|
|
|
|
|
|
|
+ user.isLogin = false
|
|
|
router.push({ path: '/login' })
|
|
router.push({ path: '/login' })
|
|
|
}
|
|
}
|
|
|
const toSetting = () => {
|
|
const toSetting = () => {
|
|
|
|
|
+ show.value = false
|
|
|
router.push('/settings')
|
|
router.push('/settings')
|
|
|
}
|
|
}
|
|
|
interface LinkItem {
|
|
interface LinkItem {
|
|
@@ -173,7 +180,7 @@ const searchChange = async(str: string, cb: (arg: any) => void) => {
|
|
|
|
|
|
|
|
const handleSelect = (item: LinkItem) => {
|
|
const handleSelect = (item: LinkItem) => {
|
|
|
if (item) {
|
|
if (item) {
|
|
|
- if (route.path !== 'search') {
|
|
|
|
|
|
|
+ if (route.path !== '/search') {
|
|
|
router.push({ path: '/search' })
|
|
router.push({ path: '/search' })
|
|
|
}
|
|
}
|
|
|
search.onSearch()
|
|
search.onSearch()
|
|
@@ -183,7 +190,7 @@ const handleSelect = (item: LinkItem) => {
|
|
|
|
|
|
|
|
// 手动回车跳转搜索页
|
|
// 手动回车跳转搜索页
|
|
|
const handleKeyEnter = () => {
|
|
const handleKeyEnter = () => {
|
|
|
- if (route.path !== 'search') {
|
|
|
|
|
|
|
+ if (route.path !== '/search') {
|
|
|
router.push({ path: '/search' })
|
|
router.push({ path: '/search' })
|
|
|
}
|
|
}
|
|
|
search.onSearch()
|
|
search.onSearch()
|
|
@@ -204,8 +211,8 @@ const platform = computed(() => {
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
const toPath = (url: any) => {
|
|
const toPath = (url: any) => {
|
|
|
- router.push({ path: url })
|
|
|
|
|
show.value = false
|
|
show.value = false
|
|
|
|
|
+ router.push({ path: url })
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|