refactor: timestamp

This commit is contained in:
zerosoul
2022-06-10 20:24:50 +08:00
parent 07d72d9aeb
commit d0b20055b9
9 changed files with 299 additions and 288 deletions
+3 -3
View File
@@ -76,7 +76,7 @@ function Send({
for await (const msg of msgs) {
console.log("send msg", msg);
const { type: content_type, content, properties = {} } = msg;
properties.local_id = properties.local_id ?? new Date().getTime();
properties.local_id = properties.local_id ?? +new Date();
await sendMessage({
id,
reply_mid: replying_mid,
@@ -90,7 +90,7 @@ function Send({
// send files
if (uploadFiles && uploadFiles.length !== 0) {
uploadFiles.forEach((fileInfo) => {
const ts = new Date().getTime();
const ts = +new Date();
const { url, name, size, type } = fileInfo;
const tmpMsg = {
mid: ts,
@@ -118,7 +118,7 @@ function Send({
type: "markdown",
content,
from_uid,
properties: { local_id: new Date().getTime() },
properties: { local_id: +new Date() },
});
};
const toggleMode = () => {
+1 -1
View File
@@ -64,7 +64,7 @@ export default function useStreaming() {
if (initialized || initializing) return;
// 如果token快要过期,先renew
const {
authData: { token, expireTime = new Date().getTime(), refreshToken },
authData: { token, expireTime = +new Date(), refreshToken },
} = store.getState();
let api_token = token;
const tokenAlmostExpire = dayjs().isAfter(new Date(expireTime - 20 * 1000));
+1 -1
View File
@@ -44,7 +44,7 @@ export default function useUploadFile(props = {}) {
if (!file) return;
setData(null);
const {
name = `rustchat-${new Date().getTime()}.${file.type.split("/")[1]}`,
name = `rustchat-${+new Date()}.${file.type.split("/")[1]}`,
type: file_type,
size: file_size,
} = file;