mirror of
https://github.com/TeamWiseFlow/wiseflow.git
synced 2025-01-23 02:20:20 +08:00
page data in utc yyyy-mm-dd, not local date
This commit is contained in:
parent
f3a3e72b0b
commit
5250eb837c
@ -12,7 +12,9 @@ FROM alpine:latest
|
||||
|
||||
ARG PB_VERSION=0.21.1
|
||||
|
||||
RUN apk add --no-cache unzip ca-certificates tzdata
|
||||
RUN apk add --no-cache unzip ca-certificates tzdata && \
|
||||
ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
|
||||
# download and unzip PocketBase
|
||||
ADD https://github.com/pocketbase/pocketbase/releases/download/v${PB_VERSION}/pocketbase_${PB_VERSION}_linux_amd64.zip /tmp/pb.zip
|
||||
|
@ -43,7 +43,7 @@ routerAdd(
|
||||
})
|
||||
)
|
||||
|
||||
$app.dao().db().newQuery("SELECT DISTINCT DATE(created, 'localtime') as created FROM insights").all(result)
|
||||
$app.dao().db().newQuery("SELECT DISTINCT DATE(created) as created FROM insights").all(result)
|
||||
|
||||
return c.json(
|
||||
200,
|
||||
|
@ -66,11 +66,11 @@ function InsightsScreen({}) {
|
||||
const [, navigate] = useLocation()
|
||||
const queryClient = useQueryClient()
|
||||
const mut = useMutation({
|
||||
mutationFn: (data) => {
|
||||
if (data && selectInsight && data.find((insight) => insight.id == selectedInsight).expand.articles.length == 1) {
|
||||
mutationFn: (params) => {
|
||||
if (params && selectedInsight && data.find((insight) => insight.id == selectedInsight).expand.articles.length == 1) {
|
||||
throw new Error("不能删除最后一篇文章")
|
||||
}
|
||||
return unlinkArticle(data)
|
||||
return unlinkArticle(params)
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["insights", currentDate] })
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { clsx } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export const LOCAL_TIME_OFFSITE = "+08:00"
|
||||
|
||||
export function cn(...inputs) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
export function formatDate(date) {
|
||||
var d = new Date(isNaN(date) ? date + "T00:00:00" : date)
|
||||
// var d = new Date(isNaN(date) ? date + "T00:00:00" + LOCAL_TIME_OFFSITE : date) // local
|
||||
var d = new Date(isNaN(date) ? date + "T00:00:00" : date) // utc
|
||||
var iso = d.toISOString()
|
||||
return iso.slice(0, 10) + " " + iso.slice(11, 23) + "Z"
|
||||
// return [d.getFullYear(), (d.getMonth() + 1).padLeft(), d.getDate().padLeft()].join("-") + " " + [d.getHours().padLeft(), d.getMinutes().padLeft(), d.getSeconds().padLeft()].join(":") + ".000Z"
|
||||
|
@ -9,7 +9,7 @@ import { persist } from "zustand/middleware"
|
||||
import axios from "axios"
|
||||
import { nanoid } from "nanoid"
|
||||
|
||||
import { formatDate } from "./lib/utils"
|
||||
import { formatDate, LOCAL_TIME_OFFSITE } from "./lib/utils"
|
||||
|
||||
const DAYS_RANGE = [1, 14]
|
||||
|
||||
@ -211,7 +211,9 @@ export function getArticles(date) {
|
||||
if (!date) return []
|
||||
|
||||
const from = formatDate(date)
|
||||
const to = formatDate(new Date(new Date(date).getTime() + 60 * 60 * 24 * 1000))
|
||||
//const to = formatDate(new Date(new Date(date + "T00:00:00" + LOCAL_TIME_OFFSITE).getTime() + 60 * 60 * 24 * 1000))
|
||||
const to = formatDate(new Date(new Date(date + "T00:00:00").getTime() + 60 * 60 * 24 * 1000))
|
||||
console.log("from/to", from, to)
|
||||
return pb.collection("articles").getFullList({
|
||||
sort: "-created",
|
||||
expand: "translation_result",
|
||||
@ -224,15 +226,15 @@ export function getInsight(id) {
|
||||
}
|
||||
|
||||
export function getInsights(date) {
|
||||
if (!date) return null
|
||||
if (!date) return []
|
||||
|
||||
const from = formatDate(date)
|
||||
//const to = formatDate(new Date(new Date(date + "T00:00:00" + LOCAL_TIME_OFFSITE).getTime() + 60 * 60 * 24 * 1000))
|
||||
const to = formatDate(new Date(new Date(date + "T00:00:00").getTime() + 60 * 60 * 24 * 1000))
|
||||
// console.log("from/to", from, to)
|
||||
|
||||
const f = 'created >= "' + from + '" && created < "' + to + '"'
|
||||
console.log(f)
|
||||
|
||||
// console.log(f)
|
||||
return pb.collection("insights").getFullList({
|
||||
sort: "-created",
|
||||
expand: "articles, articles.translation_result",
|
||||
@ -250,7 +252,7 @@ export async function getInsightDates() {
|
||||
Authorization: "Bearer " + pb.authStore?.token,
|
||||
},
|
||||
})
|
||||
// return data.map((d) => new Date(d + "T00:00:00Z").toLocaleDateString().split("/").join("-"))
|
||||
//return data.map((d) => new Date(d + "T00:00:00" + LOCAL_TIME_OFFSITE).toISOString().slice(0, 10))
|
||||
return data
|
||||
}
|
||||
|
||||
@ -263,6 +265,7 @@ export async function getArticleDates() {
|
||||
Authorization: "Bearer " + pb.authStore?.token,
|
||||
},
|
||||
})
|
||||
//return data.map((d) => new Date(d + "T00:00:00" + LOCAL_TIME_OFFSITE).toISOString().slice(0, 10))
|
||||
return data
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user