修复Y-m-d导致Safari兼容问题

This commit is contained in:
kuaifan 2021-09-21 15:06:34 +08:00
parent 318d92c759
commit 9aa0a5bb79
23 changed files with 114 additions and 66 deletions

View File

@ -1,6 +1,6 @@
{
"name": "DooTask",
"version": "0.3.24",
"version": "0.3.26",
"description": "DooTask is task management system.",
"scripts": {
"start": "./cmd dev",

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
public/js/build/177.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
public/js/build/799.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -292,6 +292,36 @@
return ret || def;
},
/**
* 返回10位数时间戳
* @param v
* @returns {number}
* @constructor
*/
Time: function (v) {
let time
if (typeof v === "string" && this.strExists(v, "-")) {
v = v.replace(/-/g, '/');
time = new Date(v).getTime();
} else {
time = new Date().getTime();
}
return Math.round(time / 1000)
},
/**
* 返回时间对象
* @param v
* @returns {Date}
* @constructor
*/
Date: function (v) {
if (typeof v === "string" && this.strExists(v, "-")) {
v = v.replace(/-/g, '/');
}
return new Date(v);
},
/**
* 补零
* @param str
@ -345,7 +375,7 @@
} else {
return v;
}
dateObj = new Date(v);
dateObj = $A.Date(v);
}
//
format = format.replace(/Y/g, dateObj.getFullYear());
@ -365,7 +395,7 @@
*/
timeDiff: function(s, e) {
if (typeof e === 'undefined') {
e = Math.round(new Date().getTime()/1000);
e = $A.Time();
}
let d = e - s;
if (d > 86400) {

View File

@ -93,8 +93,8 @@ export default {
title: data.name,
body: data.desc,
category: 'allday',
start: new Date(data.start_at).toISOString(),
end: new Date(data.end_at).toISOString(),
start: $A.Date(data.start_at).toISOString(),
end: $A.Date(data.end_at).toISOString(),
color: "#515a6e",
bgColor: data.color || '#E3EAFD',
borderColor: data.p_color,

View File

@ -128,7 +128,7 @@ export default {
},
formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000),
let time = Math.round($A.Date(date).getTime() / 1000),
string = '';
if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) {
string = $A.formatDate('H:i', time)

View File

@ -351,7 +351,7 @@ export default {
},
formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000),
let time = Math.round($A.Date(date).getTime() / 1000),
string = '';
if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) {
string = $A.formatDate('H:i', time)

View File

@ -400,7 +400,7 @@ export default {
ProjectLog, TaskArchived, TaskRow, Draggable, TaskAddSimple, UserInput, TaskAdd, TaskPriority},
data() {
return {
nowTime: Math.round(new Date().getTime() / 1000),
nowTime: $A.Time(),
nowInterval: null,
columnLoad: {},
@ -439,7 +439,7 @@ export default {
mounted() {
this.nowInterval = setInterval(() => {
this.nowTime = Math.round(new Date().getTime() / 1000);
this.nowTime = $A.Time();
}, 1000);
//
this.projectDialogsubscribe = Store.subscribe('onProjectDialogBack', () => {
@ -516,8 +516,8 @@ export default {
if (a.p_level != b.p_level) {
return a.p_level - b.p_level;
}
let at1 = new Date(a.end_at),
at2 = new Date(b.end_at);
let at1 = $A.Date(a.end_at),
at2 = $A.Date(b.end_at);
return at1 - at2;
});
},
@ -544,8 +544,8 @@ export default {
if (a.p_level != b.p_level) {
return a.p_level - b.p_level;
}
let at1 = new Date(a.end_at),
at2 = new Date(b.end_at);
let at1 = $A.Date(a.end_at),
at2 = $A.Date(b.end_at);
return at1 - at2;
});
},
@ -574,8 +574,8 @@ export default {
return task.complete_at;
});
return array.sort((a, b) => {
let at1 = new Date(a.complete_at),
at2 = new Date(b.complete_at);
let at1 = $A.Date(a.complete_at),
at2 = $A.Date(b.complete_at);
return at2 - at1;
});
},
@ -583,7 +583,7 @@ export default {
expiresFormat() {
const {nowTime} = this;
return function (date) {
let time = Math.round(new Date(date).getTime() / 1000) - nowTime;
let time = Math.round($A.Date(date).getTime() / 1000) - nowTime;
if (time < 86400 * 4 && time > 0 ) {
return this.formatSeconds(time);
} else if (time <= 0) {
@ -1065,7 +1065,7 @@ export default {
},
formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000),
let time = Math.round($A.Date(date).getTime() / 1000),
string = '';
if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) {
string = $A.formatDate('H:i', time)

View File

@ -179,7 +179,7 @@ export default {
methods: {
initLanguage() {
const lastSecond = (e) => {
return new Date($A.formatDate("Y-m-d 23:59:29", Math.round(e / 1000)))
return $A.Date($A.formatDate("Y-m-d 23:59:29", Math.round(e / 1000)))
};
this.timeOptions = {
shortcuts: [{

View File

@ -444,7 +444,7 @@ export default {
shortcuts: []
},
nowTime: Math.round(new Date().getTime() / 1000),
nowTime: $A.Time(),
nowInterval: null,
innerHeight: window.innerHeight,
@ -484,7 +484,7 @@ export default {
mounted() {
this.nowInterval = setInterval(() => {
this.nowTime = Math.round(new Date().getTime() / 1000);
this.nowTime = $A.Time();
}, 1000);
window.addEventListener('resize', this.innerHeightListener);
},
@ -591,7 +591,7 @@ export default {
expiresFormat() {
const {nowTime} = this;
return function (date) {
let time = Math.round(new Date(date).getTime() / 1000) - nowTime;
let time = Math.round($A.Date(date).getTime() / 1000) - nowTime;
if (time < 86400 * 4 && time > 0 ) {
return this.formatSeconds(time);
} else if (time <= 0) {
@ -604,11 +604,11 @@ export default {
cutTime() {
const {nowTime, taskDetail} = this;
let string = "";
let start_at = Math.round(new Date(taskDetail.start_at).getTime() / 1000);
let start_at = Math.round($A.Date(taskDetail.start_at).getTime() / 1000);
if (start_at > nowTime) {
string = $A.formatDate('Y/m/d H:i', start_at) + " ~ "
}
let end_at = Math.round(new Date(taskDetail.end_at).getTime() / 1000);
let end_at = Math.round($A.Date(taskDetail.end_at).getTime() / 1000);
string+= $A.formatDate('Y/m/d H:i', end_at);
return string;
},
@ -702,7 +702,7 @@ export default {
methods: {
initLanguage() {
const lastSecond = (e) => {
return new Date($A.formatDate("Y-m-d 23:59:29", Math.round(e / 1000)))
return $A.Date($A.formatDate("Y-m-d 23:59:29", Math.round(e / 1000)))
};
this.timeOptions = {
shortcuts: [{
@ -757,7 +757,7 @@ export default {
},
formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000),
let time = Math.round($A.Date(date).getTime() / 1000),
string = '';
if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) {
string = $A.formatDate('H:i', time)

View File

@ -165,7 +165,7 @@ export default {
},
data() {
return {
nowTime: Math.round(new Date().getTime() / 1000),
nowTime: $A.Time(),
nowInterval: null,
taskLoad: {},
@ -174,7 +174,7 @@ export default {
},
mounted() {
this.nowInterval = setInterval(() => {
this.nowTime = Math.round(new Date().getTime() / 1000);
this.nowTime = $A.Time();
}, 1000)
},
@ -198,7 +198,7 @@ export default {
expiresFormat() {
const {nowTime} = this;
return function (date) {
let time = Math.round(new Date(date).getTime() / 1000) - nowTime;
let time = Math.round($A.Date(date).getTime() / 1000) - nowTime;
if (time < 86400 * 4 && time > 0 ) {
return this.formatSeconds(time);
} else if (time <= 0) {
@ -262,7 +262,7 @@ export default {
},
formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000),
let time = Math.round($A.Date(date).getTime() / 1000),
string = '';
if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) {
string = $A.formatDate('H:i', time)

View File

@ -103,7 +103,7 @@ import {mapState} from "vuex";
export default {
data() {
return {
nowTime: Math.round(new Date().getTime() / 1000),
nowTime: $A.Time(),
nowInterval: null,
loadIng: 0,
@ -118,7 +118,7 @@ export default {
mounted() {
this.nowInterval = setInterval(() => {
this.nowTime = Math.round(new Date().getTime() / 1000);
this.nowTime = $A.Time();
}, 1000)
if (!this.isElectron) {
this.getAppInfo();
@ -156,8 +156,8 @@ export default {
list() {
const {dashboard} = this;
const todayStart = new Date($A.formatDate("Y-m-d 00:00:00")),
todayEnd = new Date($A.formatDate("Y-m-d 23:59:59"));
const todayStart = $A.Date($A.formatDate("Y-m-d 00:00:00")),
todayEnd = $A.Date($A.formatDate("Y-m-d 23:59:59"));
let datas = $A.cloneJSON(this.tasks);
datas = datas.filter((data) => {
if (data.complete_at) {
@ -169,8 +169,8 @@ export default {
if (!data.owner) {
return false;
}
const start = new Date(data.start_at),
end = new Date(data.end_at);
const start = $A.Date(data.start_at),
end = $A.Date(data.end_at);
data._start_time = start;
data._end_time = end;
switch (dashboard) {
@ -190,7 +190,7 @@ export default {
expiresFormat() {
const {nowTime} = this;
return function (date) {
let time = Math.round(new Date(date).getTime() / 1000) - nowTime;
let time = Math.round($A.Date(date).getTime() / 1000) - nowTime;
if (time < 86400 * 4 && time > 0 ) {
return this.formatSeconds(time);
} else if (time <= 0) {
@ -327,7 +327,7 @@ export default {
},
formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000),
let time = Math.round($A.Date(date).getTime() / 1000),
string = '';
if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) {
string = $A.formatDate('H:i', time)

View File

@ -244,7 +244,7 @@ export default {
},
formatTime(date) {
let time = Math.round(new Date(date).getTime() / 1000),
let time = Math.round($A.Date(date).getTime() / 1000),
string = '';
if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) {
string = $A.formatDate('H:i', time)

View File

@ -214,7 +214,7 @@ export default {
typeof success === "function" && success(state.userInfo, true);
return;
}
const time = Math.round(new Date().getTime() / 1000);
const time = state.method.Time();
const array = [];
(state.method.isArray(userid) ? userid : [userid]).some((uid) => {
if (state.cacheUserBasic[uid]) {

View File

@ -18,26 +18,22 @@ const method = {
return str
},
date2string(params, format) {
if (params === null) {
return params;
Time(v) {
let time
if (typeof v === "string" && this.strExists(v, "-")) {
v = v.replace(/-/g, '/');
time = new Date(v).getTime();
} else {
time = new Date().getTime();
}
if (typeof format === "undefined") {
format = "Y-m-d H:i:s";
return Math.round(time / 1000)
},
Date(v) {
if (typeof v === "string" && this.strExists(v, "-")) {
v = v.replace(/-/g, '/');
}
if (params instanceof Date) {
params = this.formatDate(format, params);
} else if (this.isJson(params)) {
for (let key in params) {
if (!params.hasOwnProperty(key)) continue;
params[key] = this.date2string(params[key], format);
}
} else if (this.isArray(params)) {
params.forEach((val, index) => {
params[index] = this.date2string(val, format);
});
}
return params;
return new Date(v);
},
zeroFill(str, length, after) {
@ -70,7 +66,7 @@ const method = {
} else if (/^(-)?\d{1,10}$/.test(v)) {
dateObj = new Date(v * 1000);
} else {
dateObj = new Date(v);
dateObj = this.Date(v);
}
}
//
@ -83,6 +79,28 @@ const method = {
return format;
},
date2string(params, format) {
if (params === null) {
return params;
}
if (typeof format === "undefined") {
format = "Y-m-d H:i:s";
}
if (params instanceof Date) {
params = this.formatDate(format, params);
} else if (this.isJson(params)) {
for (let key in params) {
if (!params.hasOwnProperty(key)) continue;
params[key] = this.date2string(params[key], format);
}
} else if (this.isArray(params)) {
params.forEach((val, index) => {
params[index] = this.date2string(val, format);
});
}
return params;
},
setStorage(key, value) {
return this.storage(key, value);
},