Skip to content

Commit e6993b2

Browse files
committed
fix:解决评论日期显示问题 以及 mogu_picture中swagger文档无法显示的问题
1 parent 0173800 commit e6993b2

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474

7575
> 【阿里云】 限量爆款低至91.8元/年 [点我进入](https://www.aliyun.com/minisite/goods?userCode=w7aungxw)
7676
>
77-
> 【腾讯云】星星海SA2云服务器618钜惠,1核2G 首年95元 [点我进入](https://url.cn/WuGZnFBn)
77+
> 【腾讯云】云产品限时秒杀,爆款1核2G云服务器,首年99元 [点我进入](https://url.cn/ehxjf5Bv)
7878
>
7979
> 【阿里云翼计划】 1核2G 5M / 年 (博主目前使用的) 仅需114元 [点我进入 ](https://promotion.aliyun.com/ntms/act/campus2018.html?spm=5176.10695662.1244717.1.641e5a06KpmU4A&accounttraceid=3ac1b990a4f445859080d2555566af8fiirr?userCode=w7aungxw&tag=share_component&share_source=copy_link?userCode=w7aungxw&tag=share_component&share_source=copy_link?userCode=w7aungxw&tag=share_component&share_source=copy_link) `(仅限学生或未满24岁的用户)`
8080

mogu_picture/src/main/java/com/moxi/mogublog/picture/config/InterceptorConfig.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.context.annotation.Bean;
55
import org.springframework.context.annotation.Configuration;
66
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
7+
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
78
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
89

910
/**
@@ -20,4 +21,18 @@ public class InterceptorConfig implements WebMvcConfigurer {
2021
public void addInterceptors(InterceptorRegistry registry) {
2122
registry.addInterceptor(new TokenInterceptor()).addPathPatterns("/**");
2223
}
24+
25+
/**
26+
* 注册资源映射
27+
* @param registry
28+
*/
29+
@Override
30+
public void addResourceHandlers(ResourceHandlerRegistry registry) {
31+
registry.addResourceHandler("/**").addResourceLocations(
32+
"classpath:/static/");
33+
registry.addResourceHandler("swagger-ui.html").addResourceLocations(
34+
"classpath:/META-INF/resources/");
35+
registry.addResourceHandler("/webjars/**").addResourceLocations(
36+
"classpath:/META-INF/resources/webjars/");
37+
}
2338
}

vue_mogu_web/src/utils/webUtils.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function timeAgo(dateTimeStamp) {
5050
let week = day * 7;
5151
let halfamonth = day * 15;
5252
let month = day * 30;
53+
let year = day * 365;
5354
let now = new Date().getTime(); //获取当前时间毫秒
5455
dateTimeStamp = dateTimeStamp.substring(0, 18);
5556
//必须把日期'-'转为'/'
@@ -67,14 +68,18 @@ export function timeAgo(dateTimeStamp) {
6768
let dayC = diffValue / day;
6869
let weekC = diffValue / week;
6970
let monthC = diffValue / month;
71+
let yearC = diffValue / year;
7072

7173
minC = parseInt(minC)
7274
hourC = parseInt(hourC)
7375
dayC = parseInt(dayC)
7476
weekC = parseInt(weekC)
7577
monthC = parseInt(monthC)
78+
yearC = parseInt(yearC)
7679

77-
if (monthC >= 1 && monthC <= 3) {
80+
if (yearC > 1) {
81+
result = " " + parseInt(yearC) + "年前"
82+
} else if (monthC >= 1 && monthC < 12) {
7883
result = " " + parseInt(monthC) + "月前"
7984
} else if (weekC >= 1 && weekC <= 4) {
8085
result = " " + parseInt(weekC) + "周前"
@@ -86,16 +91,6 @@ export function timeAgo(dateTimeStamp) {
8691
result = " " + parseInt(minC) + "分钟前"
8792
} else if (diffValue >= 0 && diffValue <= minute) {
8893
result = "刚刚"
89-
} else {
90-
let datetime = new Date();
91-
datetime.setTime(dateTimeStamp);
92-
let Nyear = datetime.getFullYear();
93-
let Nmonth = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
94-
let Ndate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
95-
let Nhour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
96-
let Nminute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
97-
let Nsecond = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
98-
result = Nyear + "-" + Nmonth + "-" + Ndate
9994
}
10095
return result;
10196
}

0 commit comments

Comments
 (0)