forked from ishareme/vue3-front-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(project): add pins router and as components
- Loading branch information
Showing
10 changed files
with
207 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template> | ||
<div | ||
:class="[sticky ? ' sticky top-0 left-0' : 'relative']" | ||
class="w-full h-5 border-b flex items-center z-10 bg-white dark:bg-zinc-800 border-b-zinc-200 dark:border-b-zinc-700" | ||
> | ||
<div | ||
class="w-5 h-full absolute left-0 top-0 flex items-center justify-center cursor-pointer" | ||
@click="onLeftClick" | ||
> | ||
<slot name="left"> | ||
<SvgIcon | ||
name="back" | ||
class="w-2 h-2" | ||
fillClass="fill-zinc-900 dark:fill-zinc-200" | ||
/> | ||
</slot> | ||
</div> | ||
<div | ||
class="h-full flex items-center justify-center m-auto font-bold text-base text-zinc-900 dark:text-zinc-200" | ||
> | ||
<slot></slot> | ||
</div> | ||
<div | ||
class="w-5 h-full absolute right-0 flex items-center justify-center" | ||
@click="onRightClick" | ||
> | ||
<slot name="right"></slot> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { useRouter } from 'vue-router'; | ||
const props = defineProps({ | ||
sticky: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
onLeftClick: { | ||
type: Function, | ||
}, | ||
onRightClick: { | ||
type: Function, | ||
}, | ||
}); | ||
const router = useRouter(); | ||
const onLeftClick = () => { | ||
if (props.onLeftClick) { | ||
props.onLeftClick(); | ||
return; | ||
} else { | ||
router.back(); | ||
} | ||
}; | ||
const onRightClick = () => { | ||
props.onRightClick && props.onRightClick(); | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,113 @@ | ||
<template> | ||
<div class="fixed top-0 left-0 w-screen h-screen text-xl bg-slate-200 z-20"> | ||
{{ id }} | ||
<div | ||
class="fixed top-0 left-0 w-screen h-screen text-xl z-20 backdrop-blur-4xl bg-transparent pb-2 overflow-y-auto xl:p-2 scrollbar-thin scrollbar-thumb-transparent xl:scrollbar-thumb-zinc-200 xl:dark:scrollbar-thumb-zinc-900 scrollbar-track-transparent" | ||
> | ||
<NavBar v-if="isMobileTerminal"> | ||
{{ photo.alt }} | ||
|
||
<template #right> | ||
<SvgIcon | ||
name="share" | ||
class="w-3 h-3" | ||
fillClass="fill-zinc-900 dark:fill-zinc-200" | ||
/> | ||
</template> | ||
</NavBar> | ||
<!-- pc端 --> | ||
<div | ||
v-else | ||
class="w-3.5 h-3.5 cursor-pointer duration-300 flex justify-center items-center bg-white hover:bg-main/70 absolute right-2 top-2 rounded-full shadow-sm group" | ||
> | ||
<SvgIcon | ||
name="close" | ||
class="w-1.5 h-1.5" | ||
fillClass="fill-zinc-400 group-hover:fill-zinc-100 dark:fill-zinc-200" | ||
@click="onClose" | ||
/> | ||
</div> | ||
|
||
<!-- 内容 --> | ||
<div | ||
v-if="photo.alt" | ||
class="xl:w-[80%] xl:h-full xl:m-auto xl:rounded-lg xl:flex xl:justify-center xl:items-center" | ||
> | ||
<img | ||
v-lazy | ||
:data-src=" | ||
isMobileTerminal ? photo.src?.large : photo.src?.large2 | ||
" | ||
class="w-screen mb-2 xl:w-3/5 xl:h-full xl:rounded-tl-lg xl:rounded-bl-lg xl:mb-0 xl:object-cover" | ||
/> | ||
<div | ||
class="xl:w-2/5 xl:h-full xl:bg-white xl:dark:bg-zinc-900 xl:rounded-tr-lg xl:rounded-br-lg xl:p-3" | ||
> | ||
<!-- pc下分享 收藏 --> | ||
<div v-if="!isMobileTerminal" class="flex justify-between mb-2"> | ||
<SvgIcon | ||
name="share" | ||
class="w-4 h-4 p-1 cursor-pointer hover:bg-zinc-200 dark:hover:bg-zinc-800 duration-300 rounded" | ||
/> | ||
<HButton | ||
type="info" | ||
icon="heart" | ||
iconClass="fill-zinc-900 dark:fill-zinc-200" | ||
/> | ||
</div> | ||
<!-- 标题 --> | ||
<p | ||
class="text-base text-zinc-900 dark:text-zinc-200 ml-1 font-bold xl:text-xl xl:mb-5" | ||
> | ||
{{ photo.alt }} | ||
</p> | ||
<!-- 作者 --> | ||
<div class="flex items-center mt-1 px-1"> | ||
<img | ||
v-lazy | ||
:data-src=" | ||
isMobileTerminal | ||
? photo.src?.medium | ||
: photo.src?.large | ||
" | ||
class="h-3 w-3 rounded-full" | ||
/> | ||
<span | ||
class="text-base text-zinc-900 dark:text-zinc-200 ml-1" | ||
>{{ photo.photographer }}</span | ||
> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
defineProps({ | ||
id: { | ||
type: [String, Number], | ||
import { isMobileTerminal } from '@/utils/flexible.js'; | ||
import { ref } from 'vue'; | ||
import { getPhotoById } from '@/api/pexel.js'; | ||
import { useRouter } from 'vue-router'; | ||
const props = defineProps({ | ||
currentPin: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}); | ||
const photo = ref(props.currentPin); | ||
const getPhotoData = async () => { | ||
try { | ||
const res = await getPhotoById(photo.value.id); | ||
photo.value = res; | ||
} catch (error) { | ||
console.log('[ error ]', error); | ||
} | ||
}; | ||
getPhotoData(); | ||
const router = useRouter(); | ||
const onClose = () => { | ||
photo.value = {}; | ||
router.back(); | ||
}; | ||
</script> | ||
|
||
<style lang="scss" scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
<template> | ||
<div> | ||
p | ||
<div class="w-full h-full bg-zinc-200 dark:bg-zinc-800"> | ||
<Pins :currentPin="{ id: $route.params.id }" /> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import Pins from './components/pins.vue'; | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
</style> | ||
<style lang="scss" scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters