feat(api): 添加 401 状态码处理逻辑

- 在 http.js 中添加了对 401 状态码的处理,重定向到登录页面
- 更新了 LiveRoom 组件,暂时注释掉了 initializePlayer 方法
- 在 goods store 中添加了 currentItem 和 artWorkDetail 两个状态
- 更新了 message 组件,添加了对错误信息的处理
-调整了首页布局,移除了多余的 transition 标签
- 更新了登录页面的默认验证码
This commit is contained in:
xingyy 2025-01-21 11:43:27 +08:00
parent 1b996eafca
commit 7a968f1fe6
9 changed files with 51 additions and 25 deletions

View File

@ -14,6 +14,7 @@ export function setupHttp() {
const config = useRuntimeConfig()
const baseURL = config.public.NUXT_PUBLIC_API_BASE
const {token}= authStore()
const router = useRouter()
http = ofetch.create({
baseURL,
headers: { 'Content-Type': 'application/json' },
@ -27,6 +28,9 @@ export function setupHttp() {
if (response._data.status===1){
message.error(response._data.msg)
}
if (response._data.status===401){
router.replace('/login')
}
},
async onResponseError({ response }) {
const { message } = response._data

View File

@ -1,4 +1,5 @@
<script setup>
import error from '../images/error.png'
import success from '../images/success.png'
import warning from '../images/warning.png'

View File

@ -59,7 +59,7 @@ const initializePlayer = () => {
onMounted(() => {
initializePlayer()
/* initializePlayer()*/
})
onBeforeUnmount(() => {
if (player.value) {
@ -74,8 +74,21 @@ const goPay = () => {
<template>
<div class="relative h-full">
<div :id="playerId" class="w-screen"
:style="fullLive?'height: calc(100vh - var(--van-nav-bar-height))':'height:100%'"></div>
<div class="w-full h-full">
<video
class="h-full w-full"
autoplay
loop
muted
playsinline
style=" object-fit: cover"
>
<source src="@/static/video/example.mp4" type="video/mp4" />
您的浏览器不支持 HTML5 视频
</video>
</div>
<!-- <div :id="playerId" class="w-screen"
:style="fullLive?'height: calc(100vh - var(&#45;&#45;van-nav-bar-height))':'height:100%'"></div>-->
<template v-if="fullLive">
<sideButton class="absolute top-196px right-0 z-999"></sideButton>
<div class="absolute top-505px left-1/2 transform -translate-x-1/2 flex flex-col items-center">

View File

@ -4,7 +4,7 @@
v-for="(item, index) in items"
:key="index"
class="w-full"
@click="openShow"
@click="openShow(item,index)"
>
<div class="relative w-full">
<van-image
@ -47,7 +47,7 @@ const props = defineProps({
const emit = defineEmits(['openShow']);
const openShow = () => {
emit('openShow');
const openShow = (item,index) => {
emit('openShow', item,index);
};
</script>

View File

@ -1,9 +1,9 @@
<script setup lang="ts">
<script setup>
import Column from "~/pages/home/components/Column/index.vue";
import {goodStore} from "~/stores/goods";
import {artworkDetail, artworkList} from "~/api/goods";
import {useRect} from "@vant/use";
const {itemList, pageRef,auctionDetail,liveRef} = goodStore();
const {itemList, pageRef,auctionDetail,liveRef,artWorkDetail,currentItem} = goodStore();
const loading = ref(false);
const showHeight = ref('');
const show = ref(false);
@ -41,10 +41,16 @@ const refreshData = async () => {
}
loading1.value = false
}
const getDetail=async ()=>{
const res=await artworkDetail()
const res=await artworkDetail({uuid:currentItem.value.artworkUuid})
if (res.status===0){
artWorkDetail.value
}
const openShow = () => {
}
const openShow = (item,index) => {
currentItem.value=item
getDetail()
const rect = useRect(liveRef.value.$el);
showHeight.value = rect.height;
nextTick(() => {
@ -58,7 +64,7 @@ const openShow = () => {
<van-list :immediate-check="false" v-model:loading="loading" :finished="finished" finished-text="没有更多了"
@load="loadData">
<div class="w-full flex gap-[16px]">
<Column v-for="(column, colIndex) in columns" :key="colIndex" :colIndex="colIndex" :items="column" @click="openShow" />
<Column v-for="(column, colIndex) in columns" :key="colIndex" :colIndex="colIndex" :items="column" @openShow="openShow" />
</div>
</van-list>
</van-pull-refresh>

View File

@ -28,7 +28,6 @@ initData()
<client-only>
<LiveRoom @click="changeLive" :class="['changeLive', fullLive ? 'expanded' : 'collapsed']" ref="liveRef" :fullLive="fullLive"/>
</client-only>
<transition name="fade">
<div v-show="!fullLive" class="bg-#fff">
<van-tabs sticky animated>
<van-tab title="拍品列表">
@ -40,7 +39,6 @@ initData()
</van-tabs>
<van-back-top right="15vw" bottom="10vh"/>
</div>
</transition>
</div>
</template>
<style>

View File

@ -38,7 +38,7 @@ const startCountdown=()=> {
}
const countdown = ref(0);
const phoneNum = ref('17630920520')
const code = ref('132657')
const code = ref('123789')
const pane = ref(0)
const showKeyboard = ref(false);
//

Binary file not shown.

View File

@ -5,11 +5,13 @@ export const goodStore = createGlobalState(() => {
const actionDetails = ref({})
const fullLive = ref(false)
const liveRef = ref(null);
const currentItem=ref({})
const pageRef = ref({
page: 1,
pageSize: 5,
itemCount: 0
})
const artWorkDetail=ref(null)
const itemList = ref([])
const auctionDetail = ref({})
const getAuctionDetail = async () => {
@ -22,6 +24,8 @@ export const goodStore = createGlobalState(() => {
return artworkList({auctionUuid: auctionDetail.value.uuid, ...page})
}
return {
currentItem,
artWorkDetail,
liveRef,
pageRef,
getArtworkList,