fix: 修复编辑精选页时间显示格式问题并添加搜索功能

添加formatTime函数处理时间戳格式,确保编辑精选页的时间显示正确
为搜索输入框添加回车和失焦事件触发搜索
更新开发环境API地址为正式环境
This commit is contained in:
34701892@qq.com 2025-11-10 10:13:15 +08:00
parent 11a885d039
commit 8bead115f5
2 changed files with 18 additions and 4 deletions

View File

@ -2,10 +2,10 @@
ENV = development ENV = development
# 本地环境接口地址 # 本地环境接口地址
VITE_API_URL = http://123.60.153.169:8040/apih5 # VITE_API_URL = http://123.60.153.169:8040/apih5
# VITE_API_URL = http://4155gf93ll13.vicp.fun/apih5 # VITE_API_URL = http://4155gf93ll13.vicp.fun/apih5
# VITE_API_URL = http://123.60.79.143:8041/apih5 # VITE_API_URL = http://123.60.79.143:8041/apih5
# VITE_API_URL =http://localhost:8040/apih5 # VITE_API_URL =http://localhost:8040/apih5
# VITE_API_URL = https://cankao.cs.com.cn/apih5 VITE_API_URL = https://cankao.cs.com.cn/apih5
VITE_API_DATAV_URL = https://cankao.cs.com.cn/zzck_datav VITE_API_DATAV_URL = https://cankao.cs.com.cn/zzck_datav

View File

@ -8,7 +8,7 @@
<text class="pageTitle" v-if="pageType == 4">编辑精选</text> <text class="pageTitle" v-if="pageType == 4">编辑精选</text>
<image src="@/assets/zixun/top20_icon.png" class="title_icon" v-if="pageType != 4"></image> <image src="@/assets/zixun/top20_icon.png" class="title_icon" v-if="pageType != 4"></image>
<u-input v-if="pageType == 4" placeholder="请输入搜索内容" v-model="form.keyword" prefixIcon="search" <u-input v-if="pageType == 4" placeholder="请输入搜索内容" v-model="form.keyword" prefixIcon="search"
prefixIconStyle="font-size: 22px;color: #909399" @keyup.enter="getNewsList" @blur="getNewsList" prefixIconStyle="font-size: 22px;color: #909399"
style="margin-left: 40rpx; margin-top: 5rpx; border-radius: 20rpx"> style="margin-left: 40rpx; margin-top: 5rpx; border-radius: 20rpx">
<template #suffix> <template #suffix>
<u-button @tap="getNewsList" text="搜索" size="mini"></u-button> <u-button @tap="getNewsList" text="搜索" size="mini"></u-button>
@ -37,7 +37,8 @@
<text class="time">{{ item.source }}</text> <text class="time">{{ item.source }}</text>
<text class="time" style="margin-left: 30rpx" v-if="pageType != 4">{{ <text class="time" style="margin-left: 30rpx" v-if="pageType != 4">{{
dayjs(item.publish_time).format("YYYY-MM-DD HH:MM:ss") }}</text> dayjs(item.publish_time).format("YYYY-MM-DD HH:MM:ss") }}</text>
<text class="time" style="margin-left: 30rpx" v-if="pageType == 4">{{ item.time }}</text> <text class="time" style="margin-left: 30rpx" v-if="pageType == 4">{{
formatTime(item.time) }}</text>
</view> </view>
<text class="score" v-if="pageType != 4">{{ item.news_score }}</text> <text class="score" v-if="pageType != 4">{{ item.news_score }}</text>
@ -83,6 +84,19 @@ const router = useRouter();
const pageType = ref(route.query.type); const pageType = ref(route.query.type);
const newsList = ref([]); const newsList = ref([]);
function formatTime(timestamp) {
const date = new Date(Number(timestamp).toString().length === 10 ? timestamp * 1000 : timestamp);
return [
date.getFullYear(),
(date.getMonth() + 1).toString().padStart(2, '0'),
date.getDate().toString().padStart(2, '0')
].join('-') + ' ' + [
date.getHours().toString().padStart(2, '0'),
date.getMinutes().toString().padStart(2, '0'),
date.getSeconds().toString().padStart(2, '0')
].join(':');
}
async function getNewsList() { async function getNewsList() {
if (pageType.value == 4) { if (pageType.value == 4) {
// //