perf: 优化时间组件

This commit is contained in:
kuaifan 2024-09-20 19:44:09 +03:00
parent e2fd37fe24
commit a7bd0e0dac
47 changed files with 342 additions and 807 deletions

View File

@ -1078,7 +1078,7 @@ autoUpdater.on('update-downloaded', info => {
*/
ipcMain.on('updateCheckAndDownload', (event, args) => {
event.returnValue = "ok"
if (autoUpdating + 3600 > utils.Time()) {
if (autoUpdating + 3600 > utils.dayjs().unix()) {
return // 限制1小时仅执行一次
}
if (args.provider) {
@ -1094,11 +1094,11 @@ ipcMain.on('updateCheckAndDownload', (event, args) => {
if (args.apiVersion) {
if (utils.compareVersion(info.updateInfo.version, args.apiVersion) <= 0) {
// 客户端版本 <= 接口版本
autoUpdating = utils.Time()
autoUpdating = utils.dayjs().unix()
autoUpdater.downloadUpdate().then(_ => {}).catch(_ => {})
}
} else {
autoUpdating = utils.Time()
autoUpdating = utils.dayjs().unix()
autoUpdater.downloadUpdate().then(_ => {}).catch(_ => {})
}
})

View File

@ -41,6 +41,7 @@
"dependencies": {
"axios": "^1.6.2",
"crc": "^3.8.0",
"dayjs": "^1.11.13",
"electron-config": "^2.0.0",
"electron-log": "^5.1.1",
"electron-screenshots-tool": "^1.1.2",

36
electron/utils.js vendored
View File

@ -1,7 +1,26 @@
const fs = require("fs");
const dayjs = require("dayjs");
const {shell, dialog, session} = require("electron");
module.exports = {
/**
* 时间对象
* @param v
* @returns {*|dayjs.Dayjs}
*/
dayjs(v = undefined) {
if (/^\d{13,}$/.test(v)) {
return dayjs(Number(v));
}
if (/^\d{10,}$/.test(v)) {
return dayjs(Number(v) * 1000);
}
if (v === null) {
v = 0
}
return dayjs(v);
},
/**
* 是否数组
* @param obj
@ -253,23 +272,6 @@ module.exports = {
return ((domain != null && domain.length > 0) ? domain[2] : "");
},
/**
* 返回10位数时间戳
* @param v
* @returns {number}
* @constructor
*/
Time(v = undefined) {
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 win

View File

@ -27,6 +27,7 @@
"codemirror": "^5.65.16",
"cross-env": "^7.0.3",
"css-loader": "^6.7.2",
"dayjs": "^1.11.13",
"dexie": "^3.2.3",
"echarts": "^5.2.2",
"element-sea": "^2.15.10-7",
@ -43,7 +44,6 @@
"lodash": "^4.17.21",
"markdown-it": "^13.0.1",
"markdown-it-link-attributes": "^4.0.1",
"moment": "^2.29.1",
"node-sass": "^9.0.0",
"notification-koro1": "^1.1.1",
"openpgp_hi": "^5.7.0-1",

View File

@ -49,7 +49,7 @@ export default {
return {
routePath: null,
appInter: null,
countDown: Math.min(30, 60 - $A.Date(true).getSeconds()),
countDown: Math.min(30, 60 - $A.dayjs().second()),
}
},
@ -167,7 +167,7 @@ export default {
//
this.countDown--
if (this.countDown <= 0) {
this.countDown = Math.min(30, 60 - $A.Date(true).getSeconds())
this.countDown = Math.min(30, 60 - $A.dayjs().second())
this.$store.dispatch("todayAndOverdue")
}
},

View File

@ -152,7 +152,7 @@ export default {
mouseDown(e) {
this.record = {
time: new Date().getTime(),
time: $A.dayjs().valueOf(),
top: this.floatDrag.offsetTop,
left: this.floatDrag.offsetLeft,
x: e.clientX - this.floatDrag.offsetLeft,
@ -183,7 +183,7 @@ export default {
this.checkDraggablePosition();
this.floatDrag.style.transition = "all 0.3s";
//
if ((Math.abs(this.record.top - this.floatDrag.offsetTop) < 5 && Math.abs(this.record.left - this.floatDrag.offsetLeft) < 5) || new Date().getTime() - this.record.time < 200) {
if ((Math.abs(this.record.top - this.floatDrag.offsetTop) < 5 && Math.abs(this.record.left - this.floatDrag.offsetLeft) < 5) || $A.dayjs().valueOf() - this.record.time < 200) {
this.$emit("on-click")
}
}

View File

@ -133,20 +133,19 @@ export default {
const {mouseWidth, dateWidth} = this;
return function(index) {
let mouseDay = mouseWidth == 0 ? 0 : mouseWidth / dateWidth;
let date = new Date();
//00:00:00
let nowDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
let nowDay = $A.dayjs().startOf('day');
//
let curDay = new Date(nowDay.getTime() + mouseDay * 86400000);
let curDay = nowDay.clone().add(mouseDay, 'day');
//
let lastDay = new Date(curDay.getFullYear(), curDay.getMonth() + 1, 0, 23, 59, 59);
let lastDay = curDay.clone().endOf('month');
//
let diffDay = (lastDay - curDay) / 1000 / 60 / 60 / 24;
//
let width = dateWidth * diffDay;
if (index > 0) {
lastDay = new Date(curDay.getFullYear(), curDay.getMonth() + 1 + index, 0);
width = lastDay.getDate() * dateWidth;
lastDay = curDay.clone().add(index + 1, 'month').endOf('month');
width = lastDay.date() * dateWidth;
}
return {
width: width + 'px',
@ -157,16 +156,15 @@ export default {
const {mouseWidth, dateWidth} = this;
return function(index) {
let mouseDay = mouseWidth == 0 ? 0 : mouseWidth / dateWidth;
let date = new Date();
//00:00:00
let nowDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
let nowDay = $A.dayjs().startOf('day');
//
let curDay = new Date(nowDay.getTime() + mouseDay * 86400000);
let curDay = nowDay.clone().add(mouseDay, 'day');
//
if (index > 0) {
curDay = new Date(curDay.getFullYear(), curDay.getMonth() + 1 + index, 0);
curDay = curDay.add(index + 1, 'month');
}
return $A.formatDate("Y-m", curDay)
return curDay.format('YYYY-MM')
}
},
dateNum() {
@ -184,8 +182,8 @@ export default {
mouseData--;
}
let j = mouseWidth == 0 ? index - 1 : mouseData;
let date = new Date(new Date().getTime() + j * 86400000);
if ([0, 6].indexOf(date.getDay()) !== -1) {
let date = $A.dayjs().add(j, 'day');
if ([0, 6].indexOf(date.day()) !== -1) {
style.backgroundColor = '#f9fafb';
}
//
@ -206,11 +204,11 @@ export default {
mouseData--;
}
let j = mouseWidth == 0 ? index - 1 : mouseData;
let date = new Date(new Date().getTime() + j * 86400000)
let date = $A.dayjs().add(j, 'day');
if (type == 'day') {
return date.getDate();
return date.date();
} else if (type == 'week') {
return this.$L(`星期${'日一二三四五六'.charAt(date.getDay())}`);
return this.$L(`星期${'日一二三四五六'.charAt(date.day())}`);
} else {
return date;
}
@ -221,9 +219,8 @@ export default {
return function(item) {
const {start, end} = item.time;
const {style, moveX, moveW} = item;
let date = new Date();
//00:00:00
let nowTime = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0).getTime();
let nowTime = $A.dayjs().startOf('day').valueOf();
//
let diffStartDay = (start - nowTime) / 1000 / 60 / 60 / 24;
let diffEndDay = (end - nowTime) / 1000 / 60 / 60 / 24;
@ -421,9 +418,8 @@ export default {
}
},
scrollPosition(pos) {
let date = new Date();
//00:00:00
let nowDay = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
let nowDay = $A.dayjs().startOf('day').valueOf();
//
let oneWidthTime = 86400000 / this.dateWidth;
//

View File

@ -190,7 +190,7 @@ export default {
let key = "cacheAppdown::" + this.apiVersion
let cache = await $A.IDBJson(key);
let timeout = 600;
if (cache.time && cache.time + timeout > Math.round(new Date().getTime() / 1000)) {
if (cache.time && cache.time + timeout > $A.dayjs().unix()) {
this.downloadUrl = cache.data.html_url;
return;
}
@ -202,7 +202,7 @@ export default {
axios.get(`https://api.github.com/repos/${publish.owner}/${publish.repo}/releases`).then(({status, data}) => {
this.loadIng--;
if (status === 200 && $A.isArray(data)) {
cache.time = Math.round(new Date().getTime() / 1000)
cache.time = $A.dayjs().unix()
cache.data = data.find(({tag_name}) => this.compareVersion(this.tagVersion(tag_name), this.apiVersion) === 0) || {}
$A.IDBSave(key, cache);
this.downloadUrl = cache.data.html_url;

View File

@ -109,9 +109,9 @@ export default {
if (this.user.online || this.$store.state.userId === this.userid) {
this.$emit('update:online', true)
} else {
const now = $A.Time()
const line = $A.Time(this.user.line_at)
const seconds = now - line
const now = $A.dayjs()
const line = $A.dayjs(this.user.line_at)
const seconds = now.unix() - line.unix()
let stats = '最后在线于很久以前';
if (seconds < 60) {
stats = `最后在线于刚刚`
@ -120,12 +120,12 @@ export default {
} else if (seconds < 3600 * 6) {
stats = `最后在线于 ${Math.floor(seconds / 3600)} 小时前`
} else {
const nowYmd = $A.formatDate('Y-m-d', now)
const lineYmd = $A.formatDate('Y-m-d', line)
const lineHi = $A.formatDate('H:i', line)
const nowYmd = now.format('YYYY-MM-DD')
const lineYmd = line.format('YYYY-MM-DD')
const lineHi = line.format('HH:mm')
if (nowYmd === lineYmd) {
stats = `最后在线于今天 ${lineHi}`
} else if ($A.formatDate('Y-m-d', now - 86400) === lineYmd) {
} else if (now.clone().subtract(1, 'day').format('YYYY-MM-DD') === lineYmd) {
stats = `最后在线于昨天 ${lineHi}`
} else if (seconds < 3600 * 24 * 365) {
stats = `最后在线于 ${lineYmd}`

View File

@ -485,12 +485,12 @@ export default {
return this.showDialog || dialog.type === 'user'
}).sort((a, b) => {
if (a.top_at || b.top_at) {
return $A.Date(b.top_at) - $A.Date(a.top_at);
return $A.dayjs(b.top_at) - $A.dayjs(a.top_at);
}
if (a.todo_num > 0 || b.todo_num > 0) {
return b.todo_num - a.todo_num;
}
return $A.Date(b.last_at) - $A.Date(a.last_at);
return $A.dayjs(b.last_at) - $A.dayjs(a.last_at);
}).map(({id, name, type, group_type, avatar, dialog_user}) => {
return {
name,
@ -536,7 +536,7 @@ export default {
this.contacts = data
//
const index = this.searchCache.findIndex(item => item.key == key);
const tmpData = {type: 'contact', key, data, time: $A.Time()};
const tmpData = {type: 'contact', key, data, time: $A.dayjs().unix()};
if (index > -1) {
this.searchCache.splice(index, 1, tmpData)
} else {
@ -583,7 +583,7 @@ export default {
this.projects = data
//
const index = this.searchCache.findIndex(item => item.key == key);
const tmpData = {type: 'project', key, data, time: $A.Time()};
const tmpData = {type: 'project', key, data, time: $A.dayjs().unix()};
if (index > -1) {
this.searchCache.splice(index, 1, tmpData)
} else {

View File

@ -12,7 +12,7 @@ export default {
start: e => {
e.preventDefault();
touchData.move = false;
touchData.time = new Date().getTime();
touchData.time = $A.dayjs().valueOf();
touchData.x = e.touches ? e.touches[0].clientX : e.clientX;
touchData.y = e.touches ? e.touches[0].clientY : e.clientY;
},
@ -27,7 +27,7 @@ export default {
},
end: _ => {
if (touchData.time > 0) {
if (!touchData.move && new Date().getTime() - touchData.time < 300) {
if (!touchData.move && $A.dayjs().valueOf() - touchData.time < 300) {
binding.value();
}
touchData.time = 0;

View File

@ -1,4 +1,7 @@
const localforage = require("localforage");
const dayjs = require("dayjs");
const utc = require("dayjs/plugin/utc")
const timezone = require("dayjs/plugin/timezone");
/**
* 基础函数
@ -8,12 +11,33 @@ const localforage = require("localforage");
window.modalTransferIndex = 1000;
localforage.config({name: 'DooTask', storeName: 'common'});
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.tz.setDefault("Asia/Shanghai");
/**
* =============================================================================
* ******************************* 基础函数类 *******************************
* =============================================================================
*/
$.extend({
/**
* 时间对象
* @param v
* @returns {*|dayjs.Dayjs}
*/
dayjs(v = undefined) {
if (/^\d{13,}$/.test(v)) {
return dayjs(Number(v));
}
if (/^\d{10,}$/.test(v)) {
return dayjs(Number(v) * 1000);
}
if (v === null) {
v = 0
}
return dayjs(v);
},
/**
* 是否数组
* @param obj
@ -249,62 +273,6 @@ const localforage = require("localforage");
return _s;
},
/**
* 返回10位数时间戳
* @param v
* @returns {number}
* @constructor
*/
Time(v = undefined) {
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
* @param cm 使用当前的毫秒
* @returns {number}
* @constructor
*/
TimeM(v = undefined, cm = true) {
let time
if (typeof v === "string" && this.strExists(v, "-")) {
v = v.replace(/-/g, '/');
time = new Date(v).getTime();
if (cm && v.indexOf('.') === -1) {
time = parseInt(`${Math.round(time / 1000)}${new Date().getMilliseconds()}`)
}
} else {
time = new Date().getTime();
}
return time
},
/**
* 返回 时间对象|时间戳
* @param v 支持时间戳|时间格式字符串|时间对象|boolean(当前时间)
* @param timestamp 是否返回时间戳
* @returns {Date|number}
* @constructor
*/
Date(v, timestamp = false) {
if (typeof v === "string" && this.strExists(v, "-")) {
v = v.replace(/-/g, '/');
}
const d = typeof v === "boolean" ? new Date() : new Date(v);
if (timestamp === true) {
return Math.round(d.getTime() / 1000)
}
return d;
},
/**
* 补零
* @param str
@ -329,47 +297,6 @@ const localforage = require("localforage");
return _ret;
},
/**
* 时间戳转时间格式
* @param format
* @param v
* @returns {string}
*/
formatDate(format, v) {
if (typeof format === 'undefined' || format === '') {
format = 'Y-m-d H:i:s';
}
let dateObj;
if (v instanceof Date) {
dateObj = v;
}else {
if (typeof v === 'undefined') {
v = new Date().getTime();
}else if (/^(-)?\d{1,10}$/.test(v)) {
v = v * 1000;
} else if (/^(-)?\d{1,13}$/.test(v)) {
v = v * 1000;
} else if (/^(-)?\d{1,14}$/.test(v)) {
v = v * 100;
} else if (/^(-)?\d{1,15}$/.test(v)) {
v = v * 10;
} else if (/^(-)?\d{1,16}$/.test(v)) {
v = v * 1;
} else {
return v;
}
dateObj = $A.Date(v);
}
//
format = format.replace(/Y/g, dateObj.getFullYear());
format = format.replace(/m/g, this.zeroFill(dateObj.getMonth() + 1, 2));
format = format.replace(/d/g, this.zeroFill(dateObj.getDate(), 2));
format = format.replace(/H/g, this.zeroFill(dateObj.getHours(), 2));
format = format.replace(/i/g, this.zeroFill(dateObj.getMinutes(), 2));
format = format.replace(/s/g, this.zeroFill(dateObj.getSeconds(), 2));
return format;
},
/**
* 租用时间差(不够1个小时算一个小时)
* @param s
@ -378,7 +305,7 @@ const localforage = require("localforage");
*/
timeDiff(s, e) {
if (typeof e === 'undefined') {
e = $A.Time();
e = $A.dayjs().unix();
}
let d = e - s;
if (d > 86400) {
@ -793,7 +720,7 @@ const localforage = require("localforage");
let url = window.location.href;
let key = '_='
let reg = new RegExp(key + '\\d+');
let timestamp = this.Time();
let timestamp = $A.dayjs().valueOf();
if (url.indexOf(key) > -1) {
url = url.replace(reg, key + timestamp);
} else {
@ -1117,7 +1044,7 @@ const localforage = require("localforage");
/**
* 对象中有Date格式的转成指定格式
* @param params
* @param format 默认格式Y-m-d H:i:s
* @param format 默认格式YYYY-MM-DD HH:mm:ss
* @returns {*}
*/
date2string(params, format) {
@ -1125,10 +1052,12 @@ const localforage = require("localforage");
return params;
}
if (typeof format === "undefined") {
format = "Y-m-d H:i:s";
format = "YYYY-MM-DD HH:mm:ss";
}
if (params instanceof Date) {
params = $A.formatDate(format, params);
if (params instanceof dayjs) {
params = params.format(format);
} else if (params instanceof Date) {
params = $A.dayjs(params).format(format);
} else if ($A.isJson(params)) {
params = Object.assign({}, params)
for (let key in params) {
@ -1375,7 +1304,7 @@ const localforage = require("localforage");
async IDBTest() {
try {
if ($A.isIos()) {
await localforage.setItem('__test__', $A.Time())
await localforage.setItem('__test__', $A.dayjs().valueOf())
}
$A.openLog && console.log('IDBTest OK')
} catch (error) {

View File

@ -92,7 +92,7 @@ import {MarkdownPreview} from "../store/markdown";
* @returns {*}
*/
onlinePreviewUrl(name, key) {
return $A.mainUrl(`online/preview/${name}?key=${key}&version=${window.systemInfo.version}&__=${new Date().getTime()}`)
return $A.mainUrl(`online/preview/${name}?key=${key}&version=${window.systemInfo.version}&__=${$A.dayjs().valueOf()}`)
},
/**
@ -120,18 +120,18 @@ import {MarkdownPreview} from "../store/markdown";
* @returns {*|string}
*/
formatTime(date) {
let now = $A.Time(),
time = $A.Date(date, true);
if ($A.formatDate('Ymd', now) === $A.formatDate('Ymd', time)) {
return $A.formatDate('H:i', time)
let now = $A.dayjs(),
time = $A.dayjs(date);
if (now.format("YYYY-MM-DD") === time.format("YYYY-MM-DD")) {
return time.format("HH:mm")
}
if ($A.formatDate('Ymd', now - 86400) === $A.formatDate('Ymd', time)) {
return `${$A.L('昨天')} ${$A.formatDate('H:i', time)}`
if (now.clone().subtract(1, 'day').format('YYYY-MM-DD') === time.format("YYYY-MM-DD")) {
return `${$A.L('昨天')} ${time.format("HH:mm")}`
}
if ($A.formatDate('Y', now) === $A.formatDate('Y', time)) {
return $A.formatDate('m-d', time)
if (now.year() === time.year()) {
return time.format("MM-DD")
}
return $A.formatDate('Y-m-d', time) || '';
return time.format("YYYY-MM-DD") || '';
},
/**
@ -174,7 +174,7 @@ import {MarkdownPreview} from "../store/markdown";
* @returns {string|*}
*/
countDownFormat(date, nowTime) {
let time = Math.round(this.Date(date).getTime() / 1000) - nowTime;
let time = $A.dayjs(date).unix() - nowTime;
if (time < 86400 * 7 && time > 0 ) {
return this.formatSeconds(time);
} else if (time < 0) {
@ -185,439 +185,46 @@ import {MarkdownPreview} from "../store/markdown";
return this.formatTime(date)
},
/**
* 时间工具
*/
dateRangeUtil: {
/***
* 获得当前时间
*/
getCurrentDate() {
return new Date();
},
/***
* 获得本周起止时间
*/
getCurrentWeek() {
//起止日期数组
let startStop = [];
//获取当前时间
let currentDate = this.getCurrentDate();
//返回date是一周中的某一天
let week = currentDate.getDay();
//一天的毫秒数
let millisecond = 1000 * 60 * 60 * 24;
//减去的天数
let minusDay = week != 0 ? week - 1 : 6;
//alert(minusDay);
//本周 周一
let monday = new Date(currentDate.getTime() - (minusDay * millisecond));
//本周 周日
let sunday = new Date(monday.getTime() + (6 * millisecond));
//添加本周时间
startStop.push(monday); //本周起始时间
//添加本周最后一天时间
startStop.push(sunday); //本周终止时间
//返回
return startStop;
},
/***
* 获得本月的起止时间
*/
getCurrentMonth() {
//起止日期数组
let startStop = [];
//获取当前时间
let currentDate = this.getCurrentDate();
//获得当前月份0-11
let currentMonth = currentDate.getMonth();
//获得当前年份4位年
let currentYear = currentDate.getFullYear();
//求出本月第一天
let firstDay = new Date(currentYear, currentMonth, 1);
//当为12月的时候年份需要加1
//月份需要更新为0 也就是下一年的第一个月
if (currentMonth == 11) {
currentYear++;
currentMonth = 0; //就为
} else {
//否则只是月份增加,以便求的下一月的第一天
currentMonth++;
}
//一天的毫秒数
let millisecond = 1000 * 60 * 60 * 24;
//下月的第一天
let nextMonthDayOne = new Date(currentYear, currentMonth, 1);
//求出上月的最后一天
let lastDay = new Date(nextMonthDayOne.getTime() - millisecond);
//添加至数组中返回
startStop.push(firstDay);
startStop.push(lastDay);
//返回
return startStop;
},
/**
* 得到本季度开始的月份
* @param month 需要计算的月份
***/
getQuarterSeasonStartMonth(month) {
let spring = 0; //春
let summer = 3; //夏
let fall = 6; //秋
let winter = 9; //冬
//月份从0-11
if (month < 3) {
return spring;
}
if (month < 6) {
return summer;
}
if (month < 9) {
return fall;
}
return winter;
},
/**
* 获得该月的天数
* @param year 年份
* @param month 月份
* */
getMonthDays(year, month) {
//本月第一天 1-31
let relativeDate = new Date(year, month, 1);
//获得当前月份0-11
let relativeMonth = relativeDate.getMonth();
//获得当前年份4位年
let relativeYear = relativeDate.getFullYear();
//当为12月的时候年份需要加1
//月份需要更新为0 也就是下一年的第一个月
if (relativeMonth == 11) {
relativeYear++;
relativeMonth = 0;
} else {
//否则只是月份增加,以便求的下一月的第一天
relativeMonth++;
}
//一天的毫秒数
let millisecond = 1000 * 60 * 60 * 24;
//下月的第一天
let nextMonthDayOne = new Date(relativeYear, relativeMonth, 1);
//返回得到上月的最后一天,也就是本月总天数
return new Date(nextMonthDayOne.getTime() - millisecond).getDate();
},
/**
* 获得本季度的起止日期
*/
getCurrentSeason() {
//起止日期数组
let startStop = [];
//获取当前时间
let currentDate = this.getCurrentDate();
//获得当前月份0-11
let currentMonth = currentDate.getMonth();
//获得当前年份4位年
let currentYear = currentDate.getFullYear();
//获得本季度开始月份
let quarterSeasonStartMonth = this.getQuarterSeasonStartMonth(currentMonth);
//获得本季度结束月份
let quarterSeasonEndMonth = quarterSeasonStartMonth + 2;
//获得本季度开始的日期
let quarterSeasonStartDate = new Date(currentYear, quarterSeasonStartMonth, 1);
//获得本季度结束的日期
let quarterSeasonEndDate = new Date(currentYear, quarterSeasonEndMonth, this.getMonthDays(currentYear, quarterSeasonEndMonth));
//加入数组返回
startStop.push(quarterSeasonStartDate);
startStop.push(quarterSeasonEndDate);
//返回
return startStop;
},
/***
* 得到本年的起止日期
*
*/
getCurrentYear() {
//起止日期数组
let startStop = [];
//获取当前时间
let currentDate = this.getCurrentDate();
//获得当前年份4位年
let currentYear = currentDate.getFullYear();
//本年第一天
let currentYearFirstDate = new Date(currentYear, 0, 1);
//本年最后一天
let currentYearLastDate = new Date(currentYear, 11, 31);
//添加至数组
startStop.push(currentYearFirstDate);
startStop.push(currentYearLastDate);
//返回
return startStop;
},
/**
* 返回上一个月的第一天Date类型
* @param year
* @param month
**/
getPriorMonthFirstDay(year, month) {
//年份为0代表,是本年的第一月,所以不能减
if (month == 0) {
month = 11; //月份为上年的最后月份
year--; //年份减1
return new Date(year, month, 1);
}
//否则,只减去月份
month--;
return new Date(year, month, 1);
},
/**
* 获得上一月的起止日期
* ***/
getPreviousMonth() {
//起止日期数组
let startStop = [];
//获取当前时间
let currentDate = this.getCurrentDate();
//获得当前月份0-11
let currentMonth = currentDate.getMonth();
//获得当前年份4位年
let currentYear = currentDate.getFullYear();
//获得上一个月的第一天
let priorMonthFirstDay = this.getPriorMonthFirstDay(currentYear, currentMonth);
//获得上一月的最后一天
let priorMonthLastDay = new Date(priorMonthFirstDay.getFullYear(), priorMonthFirstDay.getMonth(), this.getMonthDays(priorMonthFirstDay.getFullYear(), priorMonthFirstDay.getMonth()));
//添加至数组
startStop.push(priorMonthFirstDay);
startStop.push(priorMonthLastDay);
//返回
return startStop;
},
/**
* 获得上一周的起止日期
* **/
getPreviousWeek() {
//起止日期数组
let startStop = [];
//获取当前时间
let currentDate = this.getCurrentDate();
//返回date是一周中的某一天
let week = currentDate.getDay();
//一天的毫秒数
let millisecond = 1000 * 60 * 60 * 24;
//减去的天数
let minusDay = week != 0 ? week - 1 : 6;
//获得当前周的第一天
let currentWeekDayOne = new Date(currentDate.getTime() - (millisecond * minusDay));
//上周最后一天即本周开始的前一天
let priorWeekLastDay = new Date(currentWeekDayOne.getTime() - millisecond);
//上周的第一天
let priorWeekFirstDay = new Date(priorWeekLastDay.getTime() - (millisecond * 6));
//添加至数组
startStop.push(priorWeekFirstDay);
startStop.push(priorWeekLastDay);
return startStop;
},
/**
* 得到上季度的起始日期
* year 这个年应该是运算后得到的当前本季度的年份
* month 这个应该是运算后得到的当前季度的开始月份
* */
getPriorSeasonFirstDay(year, month) {
let spring = 0; //春
let summer = 3; //夏
let fall = 6; //秋
let winter = 9; //冬
//月份从0-11
switch (month) {//季度的其实月份
case spring:
//如果是第一季度则应该到去年的冬季
year--;
month = winter;
break;
case summer:
month = spring;
break;
case fall:
month = summer;
break;
case winter:
month = fall;
break;
}
return new Date(year, month, 1);
},
/**
* 得到上季度的起止日期
* **/
getPreviousSeason() {
//起止日期数组
let startStop = [];
//获取当前时间
let currentDate = this.getCurrentDate();
//获得当前月份0-11
let currentMonth = currentDate.getMonth();
//获得当前年份4位年
let currentYear = currentDate.getFullYear();
//上季度的第一天
let priorSeasonFirstDay = this.getPriorSeasonFirstDay(currentYear, currentMonth);
//上季度的最后一天
let priorSeasonLastDay = new Date(priorSeasonFirstDay.getFullYear(), priorSeasonFirstDay.getMonth() + 2, this.getMonthDays(priorSeasonFirstDay.getFullYear(), priorSeasonFirstDay.getMonth() + 2));
//添加至数组
startStop.push(priorSeasonFirstDay);
startStop.push(priorSeasonLastDay);
return startStop;
},
/**
* 得到去年的起止日期
* **/
getPreviousYear() {
//起止日期数组
let startStop = [];
//获取当前时间
let currentDate = this.getCurrentDate();
//获得当前年份4位年
let currentYear = currentDate.getFullYear();
currentYear--;
let priorYearFirstDay = new Date(currentYear, 0, 1);
let priorYearLastDay = new Date(currentYear, 11, 1);
//添加至数组
startStop.push(priorYearFirstDay);
startStop.push(priorYearLastDay);
return startStop;
}
},
/**
* 获取一些指定时间
* @param str
* @param retDate
* @returns {*|string}
*/
getSpecifyDate(str, retDate = false) {
let time = new Date().getTime();
switch (str) {
case '昨天':
time -= 86400 * 1000;
break;
case '前天':
time -= 86400 * 2000;
break;
case '本周':
time = $A.dateRangeUtil.getCurrentWeek()[0].getTime();
break;
case '本周结束':
time = $A.dateRangeUtil.getCurrentWeek()[1].getTime();
break;
case '上周':
time = $A.dateRangeUtil.getPreviousWeek()[0].getTime();
break;
case '上周结束':
time = $A.dateRangeUtil.getPreviousWeek()[1].getTime();
break;
case '本月':
time = $A.dateRangeUtil.getCurrentMonth()[0].getTime();
break;
case '本月结束':
time = $A.dateRangeUtil.getCurrentMonth()[1].getTime();
break;
case '上个月':
time = $A.dateRangeUtil.getPreviousMonth()[0].getTime();
break;
case '上个月结束':
time = $A.dateRangeUtil.getPreviousMonth()[1].getTime();
break;
case '本季度':
time = $A.dateRangeUtil.getCurrentSeason()[0].getTime();
break;
case '本季度结束':
time = $A.dateRangeUtil.getCurrentSeason()[1].getTime();
break;
}
time = $A.formatDate("Y-m-d", Math.floor(time / 1000))
if (retDate === true) {
return new Date(time);
}
return time
},
/**
* 获取日期选择器的 shortcuts 模板参数
* @returns {(*)[]|[{text, value(): [Date,*]},{text, value(): [Date,*]},{text, value(): [*,*]},{text, value(): [*,*]},{text, value(): [Date,*]},null,null]|(Date|*)[]}
*/
timeOptionShortcuts() {
const startSecond = $A.Date($A.formatDate("Y-m-d 00:00:00", Math.round(new Date().getTime() / 1000)));
const lastSecond = (e) => {
return $A.Date($A.formatDate("Y-m-d 00:00:00", Math.round(e / 1000)))
};
const startSecond = $A.dayjs().startOf('day').toDate();
return [{
text: $A.L('今天'),
value() {
return [startSecond, lastSecond(new Date().getTime())];
return [startSecond, $A.dayjs().endOf('day').toDate()];
}
}, {
text: $A.L('明天'),
value() {
let e = new Date();
e.setDate(e.getDate() + 1);
return [startSecond, lastSecond(e.getTime())];
return [startSecond, $A.dayjs().add(1, 'day').endOf('day').toDate()];
}
}, {
text: $A.L('本周'),
value() {
return [startSecond, lastSecond($A.getSpecifyDate('本周结束', true).getTime())];
return [startSecond, $A.dayjs().endOf('week').toDate()];
}
}, {
text: $A.L('本月'),
value() {
return [startSecond, lastSecond($A.getSpecifyDate('本月结束', true).getTime())];
return [startSecond, $A.dayjs().endOf('month').toDate()];
}
}, {
text: $A.L('3天'),
value() {
let e = new Date();
e.setDate(e.getDate() + 2);
return [startSecond, lastSecond(e.getTime())];
return [startSecond, $A.dayjs().add(2, 'day').endOf('day').toDate()];
}
}, {
text: $A.L('5天'),
value() {
let e = new Date();
e.setDate(e.getDate() + 4);
return [startSecond, lastSecond(e.getTime())];
return [startSecond, $A.dayjs().add(4, 'day').endOf('day').toDate()];
}
}, {
text: $A.L('7天'),
value() {
let e = new Date();
e.setDate(e.getDate() + 6);
return [startSecond, lastSecond(e.getTime())];
return [startSecond, $A.dayjs().add(6, 'day').endOf('day').toDate()];
}
}];
},

View File

@ -8,10 +8,10 @@ export default {
"en": "English",
"ko": "한국어",
"ja": "日本語",
"ru": "俄语",
"de": "Deutsch",
"fr": "Français",
"id": "Indonesia",
"ru": "Русский язык",
},
/**

View File

@ -660,7 +660,7 @@ export default {
const {projectKeyValue, cacheProjects} = this;
const data = $A.cloneJSON(cacheProjects).sort((a, b) => {
if (a.top_at || b.top_at) {
return $A.Date(b.top_at) - $A.Date(a.top_at);
return $A.dayjs(b.top_at) - $A.dayjs(a.top_at);
}
return b.id - a.id;
});

View File

@ -281,8 +281,7 @@ export default {
},
//
getTimeAgo(time, type) {
const currentTime = new Date();
const timeDiff = (currentTime - new Date((time + '').replace(/-/g, "/"))) / 1000; // convert to seconds
const timeDiff = $A.dayjs().unix() - $A.dayjs(time).unix(); // convert to seconds
if (timeDiff < 60) {
return type == 2 ? "0" + this.$L('分钟') : this.$L('刚刚');
} else if (timeDiff < 3600) {
@ -301,23 +300,23 @@ export default {
},
//
getWeekday(dateString) {
return ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][new Date(dateString).getDay()];
return ['周日', '周一', '周二', '周三', '周四', '周五', '周六'][$A.dayjs(dateString).day()];
},
//
getTimeDifference(startTime, endTime) {
const currentTime = new Date((endTime + '').replace(/-/g, "/"));
const endTimes = new Date((startTime + '').replace(/-/g, "/"));
const timeDiff = (currentTime - endTimes) / 1000; // convert to seconds
const currentTime = $A.dayjs(endTime);
const endTimes = $A.dayjs(startTime);
const timeDiff = currentTime.unix() - endTimes.unix(); // convert to seconds
if (timeDiff < 60) {
return {time: timeDiff, unit: this.$L('秒')};
} else if (timeDiff < 3600) {
const minutes = Math.floor(timeDiff / 60);
return {time: minutes, unit: this.$L('分钟')};
} else if (timeDiff < 3600 * 24) {
const hours = (currentTime - endTimes) / (1000 * 60 * 60);
const hours = Math.floor(timeDiff / 60 / 60);
return {time: hours, unit: this.$L('小时')};
} else {
const days = Math.floor(timeDiff / 3600 / 24);
const days = Math.floor(timeDiff / 60 / 60 / 24);
return {time: days + 1, unit: this.$L('天')};
}
},

View File

@ -262,10 +262,6 @@ export default {
isShowIcon: false,
modalTransferIndex: window.modalTransferIndex,
minDate: new Date(2020, 0, 1),
maxDate: new Date(2025, 10, 1),
currentDate: new Date(2021, 0, 17),
procdefList: [],
page: 1,
pageSize: 10,
@ -408,7 +404,7 @@ export default {
this.getUnreadList();
}
this.addData.department_id = this.userInfo.department[0] || 0;
this.addData.startTime = this.addData.endTime = this.getCurrentDate();
this.addData.startTime = this.addData.endTime = $A.dayjs().format('YYYY-MM-DD');
this.isShowIcon = this.windowWidth < 515
},
@ -432,15 +428,6 @@ export default {
});
},
//
getCurrentDate() {
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0');
const date = String(today.getDate()).padStart(2, '0');
return `${year}-${month}-${date}`;
},
// tab
tabsClick(val, time = 1000) {
if (!val && this.__tabsClick && time > 0) {

View File

@ -46,7 +46,6 @@
<script>
import {mapState, mapGetters} from "vuex";
import Calendar from "./components/Calendar";
import moment from "moment";
import {Store} from "le5le-store";
import TaskMenu from "./components/TaskMenu";
import {addLanguage} from "../../language";
@ -172,8 +171,8 @@ export default {
body: data.desc,
isAllDay: isAllday,
category: isAllday ? 'allday' : 'time',
start: $A.Date(data.start_at).toISOString(),
end: $A.Date(data.end_at).toISOString(),
start: $A.dayjs(data.start_at).toISOString(),
end: $A.dayjs(data.end_at).toISOString(),
color: "#515a6e",
bgColor: data.color || '#E3EAFD',
borderColor: data.p_color,
@ -283,34 +282,39 @@ export default {
(!options.month.visibleWeeksCount || options.month.visibleWeeksCount > 4)) {
html.push(this.currentCalendarDate('YYYY.MM'));
} else {
html.push(moment(cal.getDateRangeStart().getTime()).format('YYYY.MM.DD'));
html.push($A.dayjs(cal.getDateRangeStart().getTime()).format('YYYY.MM.DD'));
html.push(' ~ ');
html.push(moment(cal.getDateRangeEnd().getTime()).format(' MM.DD'));
html.push($A.dayjs(cal.getDateRangeEnd().getTime()).format(' MM.DD'));
}
this.rangeText = html.join('');
this.rangeTime = [moment(cal.getDateRangeStart().getTime()).format('YYYY-MM-DD'), moment(cal.getDateRangeEnd().getTime()).format('YYYY-MM-DD')];
this.rangeTime = [$A.dayjs(cal.getDateRangeStart().getTime()).format('YYYY-MM-DD'), $A.dayjs(cal.getDateRangeEnd().getTime()).format('YYYY-MM-DD')];
})
},
currentCalendarDate(format) {
const cal = this.$refs.cal.getInstance();
let currentDate = moment([cal.getDate().getFullYear(), cal.getDate().getMonth(), cal.getDate().getDate()]);
let currentDate = $A.dayjs([cal.getDate().getFullYear(), cal.getDate().getMonth(), cal.getDate().getDate()]);
return currentDate.format(format);
},
onBeforeCreateSchedule({start, end, isAllDay, guide}) {
if (isAllDay || this.calendarView == 'month') {
start = $A.date2string(start.toDate(), "Y-m-d 00:00:00")
end = $A.date2string(end.toDate(), "Y-m-d 23:59:59")
start = $A.dayjs(start.toDate()).startOf('day')
end = $A.dayjs(end.toDate()).endOf('day')
} else {
start = $A.date2string(start.toDate(), "Y-m-d H:i:s")
end = $A.date2string(end.toDate(), "Y-m-d H:i:s")
start = $A.dayjs(start.toDate())
end = $A.dayjs(end.toDate())
}
Store.set('addTask', {
times: [start, end],
owner: [this.userId],
beforeClose: () => guide.clearGuideElement()
});
this.$store.dispatch("taskDefaultTime", [
start.format('YYYY-MM-DD HH:mm:ss'),
end.format('YYYY-MM-DD HH:mm:ss')
]).then(times => {
Store.set('addTask', {
times,
owner: [this.userId],
beforeClose: () => guide.clearGuideElement()
});
})
},
onBeforeClickSchedule(event) {

View File

@ -86,9 +86,15 @@ export default {
methods: {
dateShortcuts(act) {
if (act === 'prev') {
return [$A.getSpecifyDate('上个月'), $A.getSpecifyDate('上个月结束')];
return [
$A.dayjs().subtract(1, 'month').startOf('month').format('YYYY-MM-DD'),
$A.dayjs().subtract(1, 'month').endOf('month').format('YYYY-MM-DD'),
];
} else if (act === 'this') {
return [$A.getSpecifyDate('本月'), $A.getSpecifyDate('本月结束')]
return [
$A.dayjs().startOf('month').format('YYYY-MM-DD'),
$A.dayjs().endOf('month').format('YYYY-MM-DD'),
]
}
},

View File

@ -1565,7 +1565,7 @@ export default {
let dataA = this.$store.getters.transforTasks(this.$store.getters.dashboardTask['all']);
if (dataA.length > 0) {
dataA = dataA.sort((a, b) => {
return $A.Date(a.end_at || "2099-12-31 23:59:59") - $A.Date(b.end_at || "2099-12-31 23:59:59");
return $A.dayjs(a.end_at || "2099-12-31 23:59:59") - $A.dayjs(b.end_at || "2099-12-31 23:59:59");
}).splice(0, 100)
this.taskList.push({
label: [{id: 0, value: this.$L('我的待完成任务'), disabled: true}],
@ -1581,7 +1581,7 @@ export default {
let dataB = this.$store.getters.assistTask;
if (dataB.length > 0) {
dataB = dataB.sort((a, b) => {
return $A.Date(a.end_at || "2099-12-31 23:59:59") - $A.Date(b.end_at || "2099-12-31 23:59:59");
return $A.dayjs(a.end_at || "2099-12-31 23:59:59") - $A.dayjs(b.end_at || "2099-12-31 23:59:59");
}).splice(0, 100)
this.taskList.push({
label: [{id: 0, value: this.$L('我协助的任务'), disabled: true}],
@ -1607,7 +1607,7 @@ export default {
&& task.parent_id === 0
&& !task.archived_at
}).sort((a, b) => {
return $A.Date(b.complete_at || "2099-12-31 23:59:59") - $A.Date(a.complete_at || "2099-12-31 23:59:59")
return $A.dayjs(b.complete_at || "2099-12-31 23:59:59") - $A.dayjs(a.complete_at || "2099-12-31 23:59:59")
})
if (tasks.length > 0) {
taskCallback(tasks)

View File

@ -75,9 +75,9 @@ export default {
};
},
created() {
const today = new Date()
this.year = today.getFullYear();
this.month = today.getMonth() + 1;
const today = $A.dayjs()
this.year = today.year();
this.month = today.month() + 1;
this.generateCalendar();
},
@ -100,7 +100,8 @@ export default {
computed: {
hasNextMonth() {
const {year, month} = this;
return parseInt(year) != $A.formatDate("Y") || parseInt(month) < $A.formatDate("m");
const today = $A.dayjs()
return parseInt(year) != today.year() || parseInt(month) < today.month() + 1;
}
},
methods: {
@ -120,20 +121,20 @@ export default {
}).join('<br/>')
},
generateCalendar() {
let today = new Date($A.formatDate("Y/m/d"))
let one = new Date(this.year, this.month - 1, 1)
let calcTime = one.getTime() - one.getDay() * 86400 * 1000
let today = $A.dayjs().startOf('day')
let one = $A.dayjs([this.year, this.month, 1])
let calcTime = one.valueOf() - one.day() * 86400 * 1000
let array = []
for (let i = 0; i < 6; i++) {
array[i] = []
for (let j = 0; j < 7; j++) {
let curDate = new Date(calcTime)
let curMonth = curDate.getMonth() + 1
let curDate = $A.dayjs(calcTime)
let curMonth = curDate.month() + 1
array[i][j] = {
day: curDate.getDate(),
date: `${curDate.getFullYear()}/${curMonth}/${curDate.getDate()}`,
today: today.getTime() == curDate.getTime(),
future: today.getTime() < curDate.getTime(),
day: curDate.date(),
date: `${curDate.year()}/${curMonth}/${curDate.date()}`,
today: today.unix() == curDate.unix(),
future: today.unix() < curDate.unix(),
month: curMonth == this.month
}
calcTime += 86400 * 1000
@ -165,8 +166,9 @@ export default {
this.$emit('changeMonth', this.ym())
},
nowMonth() {
this.year = parseInt($A.formatDate("Y"));
this.month = parseInt($A.formatDate("m"));
const today = $A.dayjs()
this.year = today.year();
this.month = today.month() + 1;
this.generateCalendar();
this.$emit('changeMonth', this.ym())
}

View File

@ -94,9 +94,15 @@ export default {
methods: {
dateShortcuts(act) {
if (act === 'prev') {
return [$A.getSpecifyDate('上个月'), $A.getSpecifyDate('上个月结束')];
return [
$A.dayjs().subtract(1, 'month').startOf('day').format('YYYY-MM-DD'),
$A.dayjs().subtract(1, 'month').endOf('day').format('YYYY-MM-DD'),
];
} else if (act === 'this') {
return [$A.getSpecifyDate('本月'), $A.getSpecifyDate('本月结束')]
return [
$A.dayjs().startOf('day').format('YYYY-MM-DD'),
$A.dayjs().endOf('day').format('YYYY-MM-DD'),
]
}
},

View File

@ -124,7 +124,7 @@ export default {
if (a.userid === dialogData.owner_id || b.userid === dialogData.owner_id) {
return (a.userid === dialogData.owner_id ? 0 : 1) - (b.userid === dialogData.owner_id ? 0 : 1);
}
return $A.Date(a.created_at) - $A.Date(b.created_at);
return $A.dayjs(a.created_at) - $A.dayjs(b.created_at);
})
}
},

View File

@ -916,12 +916,12 @@ export default {
return !(dialog.name === undefined || dialog.dialog_delete === 1);
}).sort((a, b) => {
if (a.top_at || b.top_at) {
return $A.Date(b.top_at) - $A.Date(a.top_at);
return $A.dayjs(b.top_at) - $A.dayjs(a.top_at);
}
if (a.todo_num > 0 || b.todo_num > 0) {
return b.todo_num - a.todo_num;
}
return $A.Date(b.last_at) - $A.Date(a.last_at);
return $A.dayjs(b.last_at) - $A.dayjs(a.last_at);
});
},
@ -1329,7 +1329,7 @@ export default {
dialogMsgTransfer: {
handler({time, msgFile, msgRecord, msgText, dialogId}) {
if (time > $A.Time() && dialogId == this.dialogId) {
if (time > $A.dayjs().unix() && dialogId == this.dialogId) {
this.$store.state.dialogMsgTransfer.time = 0;
this.$nextTick(() => {
if ($A.isArray(msgFile) && msgFile.length > 0) {
@ -1962,7 +1962,7 @@ export default {
}).then(({data}) => {
this.$store.dispatch("saveDialogTodo", {
id: this.todoViewId,
done_at: $A.formatDate("Y-m-d H:i:s")
done_at: $A.dayjs().format("YYYY-MM-DD HH:mm:ss")
})
this.$store.dispatch("saveDialog", {
id: this.dialogId,

View File

@ -246,7 +246,7 @@ export default {
if (this.value && data.id == this.fileId) {
$A.modalConfirm({
title: "更新提示",
content: '团队成员(' + info.nickname + ')更新了内容,<br/>更新时间:' + $A.formatDate("Y-m-d H:i:s", info.time) + '。<br/><br/>点击【确定】加载最新内容。',
content: '团队成员(' + info.nickname + ')更新了内容,<br/>更新时间:' + $A.dayjs(info.time).format("YYYY-MM-DD HH:mm:ss") + '。<br/><br/>点击【确定】加载最新内容。',
onOk: () => {
this.getContent();
}
@ -528,7 +528,7 @@ export default {
only_update_at: 'yes'
},
}).then(({data}) => {
resolve(`${data.id}-${$A.Time(data.update_at)}`)
resolve(`${data.id}-${$A.dayjs(data.update_at).unix()}`)
}).catch((res) => {
reject(res)
});

View File

@ -141,7 +141,7 @@ export default {
only_update_at: 'yes'
},
}).then(({data}) => {
resolve(`${data.id}-${$A.Time(data.update_at)}`)
resolve(`${data.id}-${$A.dayjs(data.update_at).unix()}`)
}).catch((res) => {
reject(res)
});

View File

@ -80,8 +80,8 @@ export default {
return h('div', {
style: {},
}, [
h('div', $A.formatDate('Y-m-d H:i', Math.round(row.baktime.start / 1000))),
h('div', $A.formatDate('Y-m-d H:i', Math.round(row.baktime.end / 1000)))
h('div', $A.dayjs(row.baktime.start).format("YYYY-MM-DD HH:mm")),
h('div', $A.dayjs(row.baktime.end).format("YYYY-MM-DD HH:mm"))
]);
}
}, {
@ -92,8 +92,8 @@ export default {
return h('div', {
style: {},
}, [
h('div', $A.formatDate('Y-m-d H:i', Math.round(row.newTime.start / 1000))),
h('div', $A.formatDate('Y-m-d H:i', Math.round(row.newTime.end / 1000)))
h('div', $A.dayjs(row.newTime.start).format("YYYY-MM-DD HH:mm")),
h('div', $A.dayjs(row.newTime.end).format("YYYY-MM-DD HH:mm"))
]);
}
}
@ -242,8 +242,8 @@ export default {
let task = this.lists.find(({id}) => id == item.id)
if (save) {
this.editLoad++;
let timeStart = $A.formatDate('Y-m-d H:i', Math.round(item.newTime.start / 1000));
let timeEnd = $A.formatDate('Y-m-d H:i', Math.round(item.newTime.end / 1000));
let timeStart = $A.dayjs(item.newTime.start).format("YYYY-MM-DD HH:mm");
let timeEnd = $A.dayjs(item.newTime.end).format("YYYY-MM-DD HH:mm");
let dataJson = {
task_id: item.id,
times: [timeStart, timeEnd],
@ -265,15 +265,15 @@ export default {
},
getTimeObj(taskData) {
let start = $A.Time(taskData.start_at) || $A.Time(taskData.created_at);
let end = $A.Time(taskData.end_at) || ($A.Time(taskData.created_at) + 86400);
if (end == start) {
end = Math.round(new Date($A.formatDate('Y-m-d 23:59:59', end)).getTime() / 1000);
let start = taskData.start_at ? $A.dayjs(taskData.start_at) : $A.dayjs(taskData.created_at).startOf('day');
let end = taskData.end_at ? $A.dayjs(taskData.end_at) : start.clone();
if (end.unix() == start.unix()) {
end = end.endOf('day');
}
end = Math.max(end, start + 60);
start *= 1000;
end *= 1000;
return {start, end};
return {
start: start.valueOf(),
end: Math.max(end.valueOf(), start.valueOf() + 60000)
};
},
onSwitchColumn(e) {

View File

@ -94,26 +94,13 @@ export default {
const {projectKeyValue, cacheProjects} = this;
const data = $A.cloneJSON(cacheProjects).sort((a, b) => {
if (a.top_at || b.top_at) {
return $A.Date(b.top_at) - $A.Date(a.top_at);
return $A.dayjs(b.top_at) - $A.dayjs(a.top_at);
}
return b.id - a.id;
});
if (projectKeyValue) {
return data.filter(item => $A.strExists(`${item.name} ${item.desc}`, projectKeyValue));
}
/*return data.map(item => {
if (!$A.isArray(item.user_simple)) {
const arr = (item.user_simple || "").split("|");
if (arr.length > 1) {
item.user_count = arr[0];
item.user_simple = arr[1].split(",");
} else {
item.user_count = 0;
item.user_simple = [];
}
}
return item;
});*/
return data;
},
},

View File

@ -93,7 +93,7 @@ export default {
methods: {
logDate(itemA) {
let md = $A.formatDate("m-d");
let md = $A.dayjs().format("MM-DD");
return md == itemA.ymd ? (itemA.ymd + ' ' + this.$L('今天')) : itemA.key;
},

View File

@ -506,7 +506,7 @@ export default {
return {
loading: false,
nowTime: $A.Time(),
nowTime: $A.dayjs().unix(),
nowInterval: null,
columnLoad: {},
@ -555,7 +555,7 @@ export default {
mounted() {
this.nowInterval = setInterval(() => {
this.nowTime = $A.Time();
this.nowTime = $A.dayjs().unix();
}, 1000);
},
@ -686,7 +686,7 @@ export default {
return task.column_id == column.id;
})).sort((a, b) => {
if (a.complete_at || b.complete_at) {
return $A.Date(a.complete_at) - $A.Date(b.complete_at);
return $A.dayjs(a.complete_at) - $A.dayjs(b.complete_at);
}
if (a.sort != b.sort) {
return a.sort - b.sort;
@ -717,7 +717,7 @@ export default {
if (a.end_at == b.end_at) {
return a.p_level - b.p_level;
}
return $A.Date(a.end_at || "2099-12-31 23:59:59") - $A.Date(b.end_at || "2099-12-31 23:59:59");
return $A.dayjs(a.end_at || "2099-12-31 23:59:59") - $A.dayjs(b.end_at || "2099-12-31 23:59:59");
}
});
},
@ -742,7 +742,7 @@ export default {
if (a.end_at == b.end_at) {
return a.p_level - b.p_level;
}
return $A.Date(a.end_at || "2099-12-31 23:59:59") - $A.Date(b.end_at || "2099-12-31 23:59:59");
return $A.dayjs(a.end_at || "2099-12-31 23:59:59") - $A.dayjs(b.end_at || "2099-12-31 23:59:59");
}
});
},
@ -773,7 +773,7 @@ export default {
if (a.end_at == b.end_at) {
return a.p_level - b.p_level;
}
return $A.Date(a.end_at || "2099-12-31 23:59:59") - $A.Date(b.end_at || "2099-12-31 23:59:59");
return $A.dayjs(a.end_at || "2099-12-31 23:59:59") - $A.dayjs(b.end_at || "2099-12-31 23:59:59");
}
});
},
@ -795,9 +795,7 @@ export default {
return task.complete_at;
});
return array.sort((a, b) => {
let at1 = $A.Date(a.complete_at),
at2 = $A.Date(b.complete_at);
return at2 - at1;
return $A.dayjs(b.complete_at) - $A.dayjs(a.complete_at);
});
},

View File

@ -155,7 +155,7 @@
clearable
@on-clear="addData.subtasks.splice(key, 1)"/>
</Col>
<Col span="8" :title="formatDate(item.times)">
<Col span="8" :title="timeTitle(item.times)">
<DatePicker
v-model="item.times"
:options="timeOptions"
@ -282,9 +282,9 @@ export default {
taskDays() {
const {times} = this.addData;
let temp = $A.date2string(times, "Y-m-d H:i");
const temp = $A.date2string(times, "YYYY-MM-DD HH:mm");
if (temp[0] && temp[1]) {
let d = Math.ceil(($A.Date(temp[1], true) - $A.Date(temp[0], true)) / 86400);
const d = Math.ceil($A.dayjs(temp[1]).diff(temp[0], 'day', true));
if (d > 0) {
return d;
}
@ -327,7 +327,7 @@ export default {
initCascaderData() {
const data = $A.cloneJSON(this.cacheProjects).sort((a, b) => {
if (a.top_at || b.top_at) {
return $A.Date(b.top_at) - $A.Date(a.top_at);
return $A.dayjs(b.top_at) - $A.dayjs(a.top_at);
}
return b.id - a.id;
});
@ -384,8 +384,8 @@ export default {
},
async taskTimeChange(data) {
const times = $A.date2string(data.times, "Y-m-d H:i");
if ($A.rightExists(times[0], '00:00') && $A.rightExists(times[1], '00:00')) {
const times = $A.date2string(data.times, "YYYY-MM-DD HH:mm");
if ($A.rightExists(times[0], '00:00') && $A.rightExists(times[1], '23:59')) {
this.$set(data, 'times', await this.$store.dispatch("taskDefaultTime", times))
}
},
@ -394,7 +394,7 @@ export default {
this.taskTimeOpen = val;
},
formatDate(value) {
timeTitle(value) {
return value ? $A.date2string(value) : null
},
@ -428,10 +428,10 @@ export default {
},
async choosePriority(item) {
const start = new Date();
const start = $A.dayjs();
const days = $A.runNum(item.days);
if (days > 0) {
const end = new Date(new Date().setDate(start.getDate() + days));
const end = start.clone().add(days, 'day');
this.$set(this.addData, 'times', await this.$store.dispatch("taskDefaultTime", $A.date2string([start, end])))
} else {
this.$set(this.addData, 'times', [])

View File

@ -240,8 +240,8 @@ export default {
choosePriority(item) {
if ($A.runNum(item.days) > 0) {
let start = new Date();
let end = new Date(new Date().setDate(start.getDate() + $A.runNum(item.days)));
let start = $A.dayjs();
let end = start.clone().add($A.runNum(item.days), 'day');
this.$set(this.addData, 'times', $A.date2string([start, end]))
} else {
this.$set(this.addData, 'times', [])

View File

@ -239,8 +239,10 @@
<div v-if="!taskDetail.end_at" @click="timeOpen = true" class="time">{{taskDetail.end_at ? cutTime : '--'}}</div>
<div v-else @click="showAtDropdown" class="time">{{taskDetail.end_at ? cutTime : '--'}}</div>
<template v-if="!taskDetail.complete_at && taskDetail.end_at">
<Tag v-if="within24Hours(taskDetail.end_at)" color="blue"><i class="taskfont">&#xe71d;</i>{{expiresFormat(taskDetail.end_at)}}</Tag>
<Tag v-if="isOverdue(taskDetail)" color="red">{{$L('超期未完成')}}</Tag>
<Tag v-if="within24Hours(taskDetail.end_at)" :color="tagColor(taskDetail)">
<i class="taskfont">&#xe71d;</i>{{expiresFormat(taskDetail.end_at)}}
</Tag>
<Tag v-if="taskDetail.overdue" color="red">{{$L('超期未完成')}}</Tag>
</template>
</div>
</DatePicker>
@ -595,7 +597,7 @@ export default {
loopForce: false,
nowTime: $A.Time(),
nowTime: $A.dayjs().unix(),
nowInterval: null,
msgText: '',
@ -657,7 +659,7 @@ export default {
mounted() {
this.nowInterval = setInterval(() => {
this.nowTime = $A.Time();
this.nowTime = $A.dayjs().unix();
}, 1000);
//
this.receiveTaskSubscribe = Store.subscribe('receiveTask', () => {
@ -774,16 +776,16 @@ export default {
cutTime() {
const {taskDetail} = this;
let start_at = $A.Date(taskDetail.start_at, true);
let end_at = $A.Date(taskDetail.end_at, true);
let start_at = $A.dayjs(taskDetail.start_at);
let end_at = $A.dayjs(taskDetail.end_at);
let string = "";
if ($A.formatDate('Y/m/d', start_at) == $A.formatDate('Y/m/d', end_at)) {
string = $A.formatDate('Y/m/d H:i', start_at) + " ~ " + $A.formatDate('H:i', end_at)
} else if ($A.formatDate('Y', start_at) == $A.formatDate('Y', end_at)) {
string = $A.formatDate('Y/m/d H:i', start_at) + " ~ " + $A.formatDate('m/d H:i', end_at)
if (start_at.format('YYYY/MM/DD') == end_at.format('YYYY/MM/DD')) {
string = start_at.format('YYYY/MM/DD HH:mm') + " ~ " + end_at.format('HH:mm')
} else if (start_at.year() == end_at.year()) {
string = start_at.format('YYYY/MM/DD HH:mm') + " ~ " + end_at.format('MM/DD HH:mm')
string = string.replace(/( 00:00| 23:59)/g, "")
} else {
string = $A.formatDate('Y/m/d H:i', start_at) + " ~ " + $A.formatDate('Y/m/d H:i', end_at)
string = start_at.format('YYYY/MM/DD HH:mm') +end_at.format('YYYY/MM/DD HH:mm')
string = string.replace(/( 00:00| 23:59)/g, "")
}
return string
@ -948,18 +950,21 @@ export default {
methods: {
within24Hours(date) {
return $A.Date(date, true) - this.nowTime < 86400
return ($A.dayjs(date).unix() - this.nowTime) < 86400
},
expiresFormat(date) {
return $A.countDownFormat(date, this.nowTime)
},
isOverdue(taskDetail) {
tagColor(taskDetail) {
if (taskDetail.overdue) {
return true;
return 'red';
}
return $A.Date(taskDetail.end_at, true) < this.nowTime;
if (taskDetail.today) {
return 'orange';
}
return 'blue'
},
loopLabel(loop) {
@ -1038,7 +1043,7 @@ export default {
case 'times':
if (this.taskDetail.start_at
&& (Math.abs($A.Time(this.taskDetail.start_at) - $A.Time(params.start_at)) > 60 || Math.abs($A.Time(this.taskDetail.end_at) - $A.Time(params.end_at)) > 60)
&& (Math.abs($A.dayjs(this.taskDetail.start_at).unix() - $A.dayjs(params.start_at).unix()) > 60 || Math.abs($A.dayjs(this.taskDetail.end_at).unix() - $A.dayjs(params.end_at).unix()) > 60)
&& typeof params.desc === "undefined") {
$A.modalInput({
title: `修改${this.taskDetail.parent_id > 0 ? '子任务' : '任务'}时间`,
@ -1179,8 +1184,8 @@ export default {
},
async taskTimeChange() {
const times = $A.date2string(this.timeValue, "Y-m-d H:i");
if ($A.rightExists(times[0], '00:00') && $A.rightExists(times[1], '00:00')) {
const times = $A.date2string(this.timeValue, "YYYY-MM-DD HH:mm");
if ($A.rightExists(times[0], '00:00') && $A.rightExists(times[1], '23:59')) {
this.timeValue = await this.$store.dispatch("taskDefaultTime", times)
}
},
@ -1197,7 +1202,7 @@ export default {
$A.messageError("任务已被领取");
return;
}
const times = $A.date2string(this.timeValue, "Y-m-d H:i");
const times = $A.date2string(this.timeValue, "YYYY-MM-DD HH:mm");
if (!(times[0] && times[1])) {
$A.messageError("请设置计划时间");
return;
@ -1295,7 +1300,7 @@ export default {
},
timeOk() {
const times = $A.date2string(this.timeValue, "Y-m-d H:i");
const times = $A.date2string(this.timeValue, "YYYY-MM-DD HH:mm");
this.updateData('times', {
start_at: times[0],
end_at: times[1],
@ -1448,7 +1453,7 @@ export default {
if (this.windowPortrait) {
$A.onBlur();
const transferData = {
time: $A.Time() + 10,
time: $A.dayjs().unix() + 10,
msgRecord: this.msgRecord,
msgFile: this.msgFile,
msgText: typeof msgText === 'string' && msgText ? msgText : this.msgText,
@ -1755,22 +1760,22 @@ export default {
},
onDelay(){
this.$refs['formDelayTaskRef'].validate((valid) => {
this.$refs.formDelayTaskRef.validate((valid) => {
if (!valid) {
return;
}
this.delayTaskLoading = true;
let date = new Date(this.taskDetail.end_at);
let date = $A.dayjs(this.taskDetail.end_at);
if (this.delayTaskForm.type === 'day') {
date.setDate(date.getDate() + Number(this.delayTaskForm.time));
date = date.add(this.delayTaskForm.time, 'day');
} else {
date.setHours(date.getHours() + Number(this.delayTaskForm.time));
date = date.add(this.delayTaskForm.time, 'hour');
}
this.$store.dispatch("taskUpdate", {
task_id: this.taskDetail.id,
times: [
this.taskDetail.start_at,
$A.formatDate('Y-m-d H:i:s', date),
date.format('YYYY-MM-DD HH:mm:ss'),
this.delayTaskForm.remark,
],
}).then(({msg}) => {

View File

@ -47,23 +47,22 @@ export default {
},
methods: {
onAdd() {
this.$emit('onAdd', {})
this.show = false;
},
getCutTime(item) {
let start_at = $A.Date(item.start_at, true);
let end_at = $A.Date(item.end_at, true);
let start_at = $A.dayjs(item.start_at);
let end_at = $A.dayjs(item.end_at);
let string = "";
if ($A.formatDate('Y/m/d', start_at) == $A.formatDate('Y/m/d', end_at)) {
string = $A.formatDate('Y/m/d H:i', start_at) + " ~ " + $A.formatDate('H:i', end_at)
} else if ($A.formatDate('Y', start_at) == $A.formatDate('Y', end_at)) {
string = $A.formatDate('Y/m/d H:i', start_at) + " ~ " + $A.formatDate('m/d H:i', end_at)
if (start_at.format('YYYY/MM/DD') == end_at.format('YYYY/MM/DD')) {
string = start_at.format('YYYY/MM/DD HH:mm') + " ~ " + end_at.format('HH:mm')
} else if (start_at.year() == end_at.year()) {
string = start_at.format('YYYY/MM/DD HH:mm') + " ~ " + end_at.format('MM/DD HH:mm')
string = string.replace(/( 00:00| 23:59)/g, "")
} else {
string = $A.formatDate('Y/m/d H:i', start_at) + " ~ " + $A.formatDate('Y/m/d H:i', end_at)
string = start_at.format('YYYY/MM/DD HH:mm') +end_at.format('YYYY/MM/DD HH:mm')
string = string.replace(/( 00:00| 23:59)/g, "")
}
return string

View File

@ -86,9 +86,15 @@ export default {
methods: {
dateShortcuts(act) {
if (act === 'prev') {
return [$A.getSpecifyDate('上个月'), $A.getSpecifyDate('上个月结束')];
return [
$A.dayjs().subtract(1, 'month').startOf('day').format('YYYY-MM-DD'),
$A.dayjs().subtract(1, 'month').endOf('day').format('YYYY-MM-DD'),
];
} else if (act === 'this') {
return [$A.getSpecifyDate('本月'), $A.getSpecifyDate('本月结束')]
return [
$A.dayjs().startOf('day').format('YYYY-MM-DD'),
$A.dayjs().endOf('day').format('YYYY-MM-DD'),
]
}
},

View File

@ -207,7 +207,7 @@ export default {
//
const data = $A.cloneJSON(this.cacheProjects).sort((a, b) => {
if (a.top_at || b.top_at) {
return $A.Date(b.top_at) - $A.Date(a.top_at);
return $A.dayjs(b.top_at) - $A.dayjs(a.top_at);
}
return b.id - a.id;
});

View File

@ -257,7 +257,7 @@ export default {
completeTemp(true)
}
this.updateTask({
complete_at: $A.formatDate("Y-m-d H:i:s")
complete_at: $A.dayjs().format('YYYY-MM-DD HH:mm:ss')
}).then(() => {
completeTemp(true)
}).catch(() => {

View File

@ -142,7 +142,7 @@ export default {
},
data() {
return {
nowTime: $A.Time(),
nowTime: $A.dayjs().unix(),
nowInterval: null,
taskLoad: {},
@ -151,7 +151,7 @@ export default {
},
mounted() {
this.nowInterval = setInterval(() => {
this.nowTime = $A.Time();
this.nowTime = $A.dayjs().unix();
}, 1000)
},
@ -267,11 +267,11 @@ export default {
},
completeAtFormat(date) {
let time = $A.Date(date, true);
if ($A.formatDate('Y') === $A.formatDate('Y', time)) {
return $A.formatDate('m-d H:i', time)
let time = $A.dayjs(date);
if ($A.dayjs().year() === time.year()) {
return time.format('MM-DD HH:mm')
} else {
return $A.formatDate('Y-m-d', time)
return time.format('YYYY-MM-DD')
}
}
}

View File

@ -679,7 +679,7 @@ export default {
{
text: '12:00',
value () {
return $A.Date($A.formatDate("Y-m-d 12:00:00"));
return $A.dayjs().startOf('day').add(12, 'hour').toDate();
},
onClick: (picker) => {
picker.handlePickSuccess();
@ -688,7 +688,7 @@ export default {
{
text: '17:00',
value () {
return $A.Date($A.formatDate("Y-m-d 17:00:00"));
return $A.dayjs().startOf('day').add(17, 'hour').toDate();
},
onClick: (picker) => {
picker.handlePickSuccess();
@ -697,7 +697,7 @@ export default {
{
text: '18:00',
value () {
return $A.Date($A.formatDate("Y-m-d 18:00:00"));
return $A.dayjs().startOf('day').add(18, 'hour').toDate();
},
onClick: (picker) => {
picker.handlePickSuccess();
@ -706,7 +706,7 @@ export default {
{
text: '19:00',
value () {
return $A.Date($A.formatDate("Y-m-d 19:00:00"));
return $A.dayjs().startOf('day').add(19, 'hour').toDate();
},
onClick: (picker) => {
picker.handlePickSuccess();
@ -715,7 +715,7 @@ export default {
{
text: this.$L('现在'),
value () {
return new Date();
return $A.dayjs().toDate();
},
onClick: (picker) => {
picker.handlePickSuccess();

View File

@ -102,7 +102,7 @@ export default {
components: {TaskMenu},
data() {
return {
nowTime: $A.Time(),
nowTime: $A.dayjs().unix(),
nowInter: null,
licenseTimer: null,
@ -146,7 +146,7 @@ export default {
title: this.getTitle(type),
hidden: hiddenColumns.includes(type),
list: data.sort((a, b) => {
return $A.Date(a.end_at || "2099-12-31 23:59:59") - $A.Date(b.end_at || "2099-12-31 23:59:59");
return $A.dayjs(a.end_at || "2099-12-31 23:59:59") - $A.dayjs(b.end_at || "2099-12-31 23:59:59");
})
})
})
@ -155,7 +155,7 @@ export default {
title: this.getTitle('assist'),
hidden: hiddenColumns.includes('assist'),
list: this.assistTask.sort((a, b) => {
return $A.Date(a.end_at || "2099-12-31 23:59:59") - $A.Date(b.end_at || "2099-12-31 23:59:59");
return $A.dayjs(a.end_at || "2099-12-31 23:59:59") - $A.dayjs(b.end_at || "2099-12-31 23:59:59");
})
})
return list;
@ -242,7 +242,7 @@ export default {
return
}
this.nowInter = setInterval(_ => {
this.nowTime = $A.Time()
this.nowTime = $A.dayjs().unix()
}, 1000)
},

View File

@ -605,7 +605,7 @@ export default {
tabActive: {
handler(val) {
if (val == 'contacts') {
if ($A.Time() - this.contactsLastTime > 24 * 3600) {
if ($A.dayjs().unix() - this.contactsLastTime > 24 * 3600) {
this.contactsData = null; // 24
}
if (this.contactsData === null) {
@ -721,7 +721,7 @@ export default {
dialogSort(a, b) {
//
if (a.top_at || b.top_at) {
return $A.Date(b.top_at) - $A.Date(a.top_at);
return $A.dayjs(b.top_at) - $A.dayjs(a.top_at);
}
//
if (a.todo_num > 0 || b.todo_num > 0) {
@ -732,7 +732,7 @@ export default {
return b.extra_draft_has - a.extra_draft_has;
}
//
return $A.Date(b.last_at) - $A.Date(a.last_at);
return $A.dayjs(b.last_at) - $A.dayjs(a.last_at);
},
userClass(user) {
@ -798,22 +798,22 @@ export default {
if (['project', 'task'].includes(dialog.group_type) && $A.isJson(dialog.group_info)) {
if (dialog.group_type == 'task' && dialog.group_info.complete_at) {
// 5
let time = Math.max($A.Date(dialog.last_at, true), $A.Date(dialog.group_info.complete_at, true))
if (5 * 86400 + time < $A.Time()) {
let time = Math.max($A.dayjs(dialog.last_at).unix(), $A.dayjs(dialog.group_info.complete_at).unix())
if (5 * 86400 + time < $A.dayjs().unix()) {
return false
}
}
if (dialog.group_info.deleted_at) {
// 2
let time = Math.max($A.Date(dialog.last_at, true), $A.Date(dialog.group_info.deleted_at, true))
if (2 * 86400 + time < $A.Time()) {
let time = Math.max($A.dayjs(dialog.last_at).unix(), $A.dayjs(dialog.group_info.deleted_at).unix())
if (2 * 86400 + time < $A.dayjs().unix()) {
return false
}
}
if (dialog.group_info.archived_at) {
// 3
let time = Math.max($A.Date(dialog.last_at, true), $A.Date(dialog.group_info.archived_at, true))
if (3 * 86400 + time < $A.Time()) {
let time = Math.max($A.dayjs(dialog.last_at).unix(), $A.dayjs(dialog.group_info.archived_at).unix())
if (3 * 86400 + time < $A.dayjs().unix()) {
return false
}
}
@ -921,7 +921,7 @@ export default {
this.contactsHasMorePages = false;
}).finally(_ => {
this.contactsLoad--;
this.contactsLastTime = $A.Time()
this.contactsLastTime = $A.dayjs().unix()
});
},
@ -955,7 +955,7 @@ export default {
}
});
}).finally(_ => {
this.contactsLastTime = $A.Time()
this.contactsLastTime = $A.dayjs().unix()
});
}
}, timeout)

View File

@ -163,7 +163,7 @@ export default {
this.$store.dispatch("call", {
url: 'users/checkin/list',
data: {
ym: $A.formatDate("Y-m"),
ym: $A.dayjs().format("YYYY-MM"),
before: 1
}
}).then(({data}) => {
@ -174,10 +174,9 @@ export default {
},
latelyFormat(data) {
const time = $A.Time();
this.latelyData = [];
for (let i = 0; i < 5; i++) {
const ymd = $A.formatDate("Y-m-d", time - i * 86400)
const ymd = $A.dayjs().subtract(i, 'day').format("YYYY-MM-DD")
const item = data.find(({date}) => date == ymd) || {date: ymd, section: []}
this.latelyData.push(item)
}
@ -205,7 +204,7 @@ export default {
}
this.calendarData = data;
//
if (ym == $A.formatDate("Y-m")) {
if (ym == $A.dayjs().format("YYYY-MM")) {
this.latelyFormat(data)
}
}).catch(({msg}) => {

View File

@ -176,7 +176,7 @@ export default {
only_update_at: 'yes'
},
}).then(({data}) => {
resolve(`${data.id}-${$A.Time(data.update_at)}`)
resolve(`${data.id}-${$A.dayjs(data.update_at).unix()}`)
}).catch((res) => {
reject(res)
});

View File

@ -163,7 +163,7 @@ export default {
only_update_at: 'yes'
},
}).then(({data}) => {
resolve(`${data.id}-${$A.Time(data.update_at)}`)
resolve(`${data.id}-${$A.dayjs(data.update_at).unix()}`)
}).catch((res) => {
reject(res)
});

View File

@ -541,7 +541,7 @@ export default {
return
}
//
const tmpKey = state.userId + $A.Time()
const tmpKey = state.userId + $A.dayjs().unix()
if (window.__getBasicDataKey === tmpKey) {
return
}
@ -694,7 +694,7 @@ export default {
return;
}
//
let time = $A.Time();
let time = $A.dayjs().unix();
let list = $A.cloneJSON(state.cacheUserWait);
if (data && data.userid) {
list.push(data)
@ -729,7 +729,7 @@ export default {
},
skipAuthError: true
}).then(result => {
time = $A.Time();
time = $A.dayjs().unix();
array.forEach(value => {
let data = result.data.find(({userid}) => userid == value.userid) || Object.assign(value, {email: ""});
data._time = time;
@ -1197,7 +1197,7 @@ export default {
if (ids.includes(state.projectId)) {
const project = $A.cloneJSON(state.cacheProjects).sort((a, b) => {
if (a.top_at || b.top_at) {
return $A.Date(b.top_at) - $A.Date(a.top_at);
return $A.dayjs(b.top_at) - $A.dayjs(a.top_at);
}
return b.id - a.id;
}).find(({id}) => id && id != project_id);
@ -1513,7 +1513,7 @@ export default {
dispatch("saveTask", task)
});
} else if ($A.isJson(data)) {
data._time = $A.Time();
data._time = $A.dayjs().unix();
if (data.flow_item_name && data.flow_item_name.indexOf("|") !== -1) {
[data.flow_item_status, data.flow_item_name] = data.flow_item_name.split("|")
}
@ -1617,19 +1617,21 @@ export default {
* @param dispatch
*/
todayAndOverdue({state, dispatch}) {
const now = $A.dayjs();
const today = now.format("YYYY-MM-DD");
state.cacheTasks.some(task => {
if (!task.end_at) {
return false;
}
const data = {today: false, overdue: false};
const endAt = $A.Date(task.end_at, true)
if (!task.today) {
data.today = $A.formatDate('Y-m-d', endAt) == $A.formatDate('Y-m-d')
const data = {};
const endAt = $A.dayjs(task.end_at)
if (!task.today && endAt.format("YYYY-MM-DD") == today) {
data.today = true
}
if (!task.overdue) {
data.overdue = endAt < $A.Time();
if (!task.overdue && endAt < now) {
data.overdue = true;
}
if (data.today || data.overdue) {
if (Object.keys(data).length > 0) {
dispatch("saveTask", Object.assign(task, data));
}
})
@ -2188,10 +2190,10 @@ export default {
content = "主任务没有设置时间,设置子任务将同步设置主任务"
return true;
}
let n1 = $A.Date(post.times[0], true),
n2 = $A.Date(post.times[1], true),
o1 = $A.Date(parentTask.start_at, true),
o2 = $A.Date(parentTask.end_at, true);
let n1 = $A.dayjs(post.times[0]).unix(),
n2 = $A.dayjs(post.times[1]).unix(),
o1 = $A.dayjs(parentTask.start_at).unix(),
o2 = $A.dayjs(parentTask.end_at).unix();
if (n1 < o1) {
content = "新设置的子任务开始时间在主任务时间之外,修改后将同步修改主任务" // 子任务开始时间 < 主任务开始时间
return true;
@ -2211,12 +2213,12 @@ export default {
if (!subTask.end_at) {
return false;
}
let n1 = $A.Date(post.times[0], true),
n2 = $A.Date(post.times[1], true),
c1 = $A.Date(currentTask.start_at, true),
c2 = $A.Date(currentTask.end_at, true),
o1 = $A.Date(subTask.start_at, true),
o2 = $A.Date(subTask.end_at, true);
let n1 = $A.dayjs(post.times[0]).unix(),
n2 = $A.dayjs(post.times[1]).unix(),
c1 = $A.dayjs(currentTask.start_at).unix(),
c2 = $A.dayjs(currentTask.end_at).unix(),
o1 = $A.dayjs(subTask.start_at).unix(),
o2 = $A.dayjs(subTask.end_at).unix();
if (c1 == o1 && c2 == o2) {
return false;
}
@ -2513,7 +2515,7 @@ export default {
const updateData = {
id: data.dialog_id,
last_msg: data,
last_at: data.created_at || $A.formatDate("Y-m-d H:i:s")
last_at: data.created_at || $A.dayjs().format("YYYY-MM-DD HH:mm:ss")
}
if (data.mtype == 'tag') {
updateData.has_tag = true;
@ -2622,7 +2624,7 @@ export default {
*/
async getDialogBeyonds({state, dispatch}) {
const key = await $A.IDBString("dialogBeyond")
const val = $A.formatDate("Y-m-d H")
const val = $A.dayjs().format("YYYY-MM-DD HH")
if (key == val) {
return // 一小时取一次
}
@ -2632,7 +2634,7 @@ export default {
return state.cacheDialogs
.filter(func)
.sort((a, b) => {
return $A.Date(a.last_at) - $A.Date(b.last_at);
return $A.dayjs(a.last_at) - $A.dayjs(b.last_at);
})
.find(({id}) => id > 0)
}
@ -2646,8 +2648,8 @@ export default {
dispatch("call", {
url: 'dialog/beyond',
data: {
unread_at: unreadDialog ? unreadDialog.last_at : $A.Time(),
todo_at: todoDialog ? todoDialog.last_at : $A.Time()
unread_at: unreadDialog ? unreadDialog.last_at : $A.dayjs().unix(),
todo_at: todoDialog ? todoDialog.last_at : $A.dayjs().unix()
}
}).then(({data}) => {
dispatch("saveDialog", data);
@ -3132,7 +3134,7 @@ export default {
if ($A.isJson(resData.dialog)) {
const ids = resData.list.map(({id}) => id)
state.dialogMsgs = state.dialogMsgs.filter(item => {
return item.dialog_id != data.dialog_id || ids.includes(item.id) || $A.Time(item.created_at) >= resData.time
return item.dialog_id != data.dialog_id || ids.includes(item.id) || $A.dayjs(item.created_at).unix() >= resData.time
});
$A.IDBSave("dialogMsgs", state.dialogMsgs, 600)
dispatch("saveDialog", resData.dialog)
@ -3230,7 +3232,7 @@ export default {
if ($A.isJson(data)) {
if (data.userid == state.userId) return;
if (data.read_at) return;
data.read_at = $A.formatDate();
data.read_at = $A.dayjs().format("YYYY-MM-DD HH:mm:ss");
state.readWaitData[data.id] = state.readWaitData[data.id] || 0
//
const dialog = state.cacheDialogs.find(({id}) => id == data.dialog_id);
@ -3277,7 +3279,7 @@ export default {
if (ids.hasOwnProperty(id) && /^\d+$/.test(ids[id])) {
state.dialogMsgs.some(item => {
if (item.dialog_id == ids[id] && item.id >= id) {
item.read_at = $A.formatDate()
item.read_at = $A.dayjs().format("YYYY-MM-DD HH:mm:ss")
}
})
}
@ -3332,7 +3334,7 @@ export default {
if (typeof data.after_msg_id !== "undefined") {
state.dialogMsgs.some(item => {
if (item.dialog_id == data.dialog_id && item.id >= data.after_msg_id) {
item.read_at = $A.formatDate()
item.read_at = $A.dayjs().format("YYYY-MM-DD HH:mm:ss")
}
})
}
@ -3385,7 +3387,7 @@ export default {
break;
}
})
state.dialogSseList.push({sse, streamUrl, time: $A.Time()})
state.dialogSseList.push({sse, streamUrl, time: $A.dayjs().unix()})
if (state.dialogSseList.length > 10) {
state.dialogSseList.shift().sse.close()
}
@ -3553,7 +3555,7 @@ export default {
//
state.ws = new WebSocket(url);
state.ws.onopen = async (e) => {
wgLog && console.log("[WS] Open", e, $A.formatDate())
wgLog && console.log("[WS] Open", e, $A.dayjs().format("YYYY-MM-DD HH:mm:ss"))
state.wsOpenNum++;
//
if (window.systemInfo.debug === "yes" || state.systemConfig.e2e_message !== 'open') {
@ -3568,7 +3570,7 @@ export default {
})
};
state.ws.onclose = async (e) => {
wgLog && console.log("[WS] Close", e, $A.formatDate())
wgLog && console.log("[WS] Close", e, $A.dayjs().format("YYYY-MM-DD HH:mm:ss"))
state.ws = null;
//
clearTimeout(state.wsTimeout);
@ -3577,7 +3579,7 @@ export default {
}, 3000);
};
state.ws.onerror = async (e) => {
wgLog && console.log("[WS] Error", e, $A.formatDate())
wgLog && console.log("[WS] Error", e, $A.dayjs().format("YYYY-MM-DD HH:mm:ss"))
state.ws = null;
//
clearTimeout(state.wsTimeout);

View File

@ -114,9 +114,9 @@ export default {
* @returns {{overdue: *, today: *,all:*}}
*/
dashboardTask(state) {
const todayStart = $A.Date($A.formatDate("Y-m-d 00:00:00")),
todayEnd = $A.Date($A.formatDate("Y-m-d 23:59:59")),
todayNow = $A.Date($A.formatDate("Y-m-d H:i:s"));
const todayStart = $A.dayjs().startOf('day'),
todayEnd = $A.dayjs().endOf('day'),
todayNow = $A.dayjs();
const filterTask = (task, chackCompleted = true) => {
if (task.archived_at) {
return false;
@ -124,7 +124,7 @@ export default {
if (task.complete_at && chackCompleted === true) {
return false;
}
if (task.start_at && $A.Date(task.start_at) > todayNow) {
if (task.start_at && $A.dayjs(task.start_at) > todayNow) {
return false;
}
return task.owner == 1;
@ -140,11 +140,11 @@ export default {
}
}
const todayTasks = array.filter(task => {
const end = $A.Date(task.end_at);
const end = $A.dayjs(task.end_at);
return todayStart <= end && end <= todayEnd;
})
const overdueTasks = array.filter(task => {
return task.end_at && $A.Date(task.end_at) <= todayNow;
return task.end_at && $A.dayjs(task.end_at) <= todayNow;
})
const result = {
today: todayTasks,

View File

@ -41,7 +41,7 @@ function __callData(key, requestData, state) {
return new Promise(resolve => {
if (current_page === 1) {
let hasUpdate = false
const time = $A.Time()
const time = $A.dayjs().unix()
if (total > 0) {
callData.updated = time
hasUpdate = true