Skip to content

Commit

Permalink
fix:解决评论日期显示问题 以及 mogu_picture中swagger文档无法显示的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
moxi624 committed Jul 17, 2020
1 parent 0173800 commit e6993b2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

> 【阿里云】 限量爆款低至91.8元/年 [点我进入](https://www.aliyun.com/minisite/goods?userCode=w7aungxw)
>
> 【腾讯云】星星海SA2云服务器618钜惠,1核2G 首年95元 [点我进入](https://url.cn/WuGZnFBn)
> 【腾讯云】云产品限时秒杀,爆款1核2G云服务器,首年99元 [点我进入](https://url.cn/ehxjf5Bv)
>
> 【阿里云翼计划】 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岁的用户)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
Expand All @@ -20,4 +21,18 @@ public class InterceptorConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new TokenInterceptor()).addPathPatterns("/**");
}

/**
* 注册资源映射
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations(
"classpath:/static/");
registry.addResourceHandler("swagger-ui.html").addResourceLocations(
"classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/");
}
}
17 changes: 6 additions & 11 deletions vue_mogu_web/src/utils/webUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function timeAgo(dateTimeStamp) {
let week = day * 7;
let halfamonth = day * 15;
let month = day * 30;
let year = day * 365;
let now = new Date().getTime(); //获取当前时间毫秒
dateTimeStamp = dateTimeStamp.substring(0, 18);
//必须把日期'-'转为'/'
Expand All @@ -67,14 +68,18 @@ export function timeAgo(dateTimeStamp) {
let dayC = diffValue / day;
let weekC = diffValue / week;
let monthC = diffValue / month;
let yearC = diffValue / year;

minC = parseInt(minC)
hourC = parseInt(hourC)
dayC = parseInt(dayC)
weekC = parseInt(weekC)
monthC = parseInt(monthC)
yearC = parseInt(yearC)

if (monthC >= 1 && monthC <= 3) {
if (yearC > 1) {
result = " " + parseInt(yearC) + "年前"
} else if (monthC >= 1 && monthC < 12) {
result = " " + parseInt(monthC) + "月前"
} else if (weekC >= 1 && weekC <= 4) {
result = " " + parseInt(weekC) + "周前"
Expand All @@ -86,16 +91,6 @@ export function timeAgo(dateTimeStamp) {
result = " " + parseInt(minC) + "分钟前"
} else if (diffValue >= 0 && diffValue <= minute) {
result = "刚刚"
} else {
let datetime = new Date();
datetime.setTime(dateTimeStamp);
let Nyear = datetime.getFullYear();
let Nmonth = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
let Ndate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
let Nhour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
let Nminute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
let Nsecond = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
result = Nyear + "-" + Nmonth + "-" + Ndate
}
return result;
}

0 comments on commit e6993b2

Please sign in to comment.