详情和列表图片优化

master
fuxiaochun 2023-08-18 15:30:06 +08:00
parent e92ad62f1f
commit 0529fd569c
3 changed files with 45 additions and 8 deletions

View File

@ -34,8 +34,7 @@
</div>
</div>
<template v-if="detail">
<AiAssistantFolat></AiAssistantFolat>
<AiAssistant :content="detail.content"></AiAssistant>
<AiAssistantFolat :content="detail.content"></AiAssistantFolat>
</template>
</div>
</template>
@ -47,7 +46,6 @@ import { showToast } from 'vant';
import { useRouter, useRoute } from 'vue-router';
import { DateFormat } from '@/utils/format.js';
import AiAssistantFolat from '@/views/chat/components/ai-assistant-float.vue';
import AiAssistant from '@/views/chat/components/ai-assistant.vue'
const props = defineProps({
id: {type: [Number, String], required: true },

View File

@ -58,6 +58,7 @@ const userInfo = useUserInfo();
const router = useRouter();
const route = useRoute();
const authModal = useAuthModal();
const timer = ref(0);
const showMenu = ref(false);
@ -70,8 +71,38 @@ onMounted(()=>{
if (userInfoData.id) {
userInfo.updateUserInfo(userInfoData);
}
let authData = localCache.get('auth') || {};
if (authData.expires_time) {
checkToken();
}
});
const checkToken = () => {
let diffTime = 1000 * 60 * 10; // 10mins
let nowTime = Date.now();
let authData = localCache.get('auth') || {};
let overTime = authData.expires_time || nowTime;
if (overTime - nowTime <= diffTime) {
clearTimeout(timer.value);
flushtoken();
} else {
timer.value = setTimeout(checkToken, 300000); //300000
}
};
const flushtoken = () => {
http('/api/auth/refresh', {}).then(res => {
let nowTime = Date.now();
let overTime = nowTime + res.data.expires_in * 1000;
let authData = { ...res.data, expires_time: overTime };
localCache.set('auth', authData);
checkToken();
}).catch(err => {
showToast(err.message);
});
};
const toggleMenu = ()=>{
showMenu.value = !showMenu.value;
};

View File

@ -4,7 +4,9 @@
<template v-if="dataList.length > 0">
<ul>
<li :key="item.id" v-for="item in dataList" @click="goDetail(item.id)">
<img :src="item.cover" :alt="item.title">
<div class="img">
<img :src="item.cover" :alt="item.title">
</div>
<div class="title">
<h2>{{ item.title }}</h2>
<span>{{ DateFormat(new Date(item.published_at * 1000), 'yyyy.MM.dd') }}</span>
@ -51,8 +53,6 @@ const dataList = ref([]);
const placeholder = ref('');
const hasMore = ref(false);
console.log(props);
onMounted(()=>{
getList();
});
@ -114,11 +114,19 @@ const goDetail = (id) => {
margin-bottom: 20px;
color: #333;
cursor: pointer;
img{
.img{
width: 100%;
height: 264px;
display: block;
background-color: #666;
overflow: hidden;
img{
object-fit: cover;
display: block;
background-color: #666;
&[src='']{
display: none;
}
}
}
.title{
height: 80px;