优化时间工具

This commit is contained in:
2026-06-10 18:15:06 +08:00
parent 74268a8a07
commit 5e6870049a
5 changed files with 34 additions and 20 deletions
+20 -7
View File
@@ -70,16 +70,29 @@ func buildTimeContext(now time.Time) string {
- 本周:%s 至 %s - 本周:%s 至 %s
- 本月:%s 至 %s - 本月:%s 至 %s
- 今年:%s 至 %s`, - 今年:%s 至 %s`,
now.Format("2006-01-02 15:04:05 MST"), formatDateTimeWithWeek(now, "2006-01-02 15:04:05 MST"),
todayStart.Format("2006-01-02"), todayStart.Format("2006-01-02 15:04:05"), todayStart.AddDate(0, 0, 1).Add(-time.Second).Format("2006-01-02 15:04:05"), formatDateWithWeek(todayStart), formatDateTimeWithWeek(todayStart, "2006-01-02 15:04:05"), formatDateTimeWithWeek(todayStart.AddDate(0, 0, 1).Add(-time.Second), "2006-01-02 15:04:05"),
todayStart.AddDate(0, 0, -1).Format("2006-01-02"), formatDateWithWeek(todayStart.AddDate(0, 0, -1)),
todayStart.AddDate(0, 0, 1).Format("2006-01-02"), formatDateWithWeek(todayStart.AddDate(0, 0, 1)),
weekStart.Format("2006-01-02"), weekStart.AddDate(0, 0, 7).Add(-time.Second).Format("2006-01-02"), formatDateWithWeek(weekStart), formatDateWithWeek(weekStart.AddDate(0, 0, 7).Add(-time.Second)),
monthStart.Format("2006-01-02"), monthStart.AddDate(0, 1, 0).Add(-time.Second).Format("2006-01-02"), formatDateWithWeek(monthStart), formatDateWithWeek(monthStart.AddDate(0, 1, 0).Add(-time.Second)),
yearStart.Format("2006-01-02"), yearStart.AddDate(1, 0, 0).Add(-time.Second).Format("2006-01-02"), formatDateWithWeek(yearStart), formatDateWithWeek(yearStart.AddDate(1, 0, 0).Add(-time.Second)),
) )
} }
func formatDateWithWeek(t time.Time) string {
return formatDateTimeWithWeek(t, "2006-01-02")
}
func formatDateTimeWithWeek(t time.Time, layout string) string {
return fmt.Sprintf("%s%s", t.Format(layout), weekdayName(t.Weekday()))
}
func weekdayName(weekday time.Weekday) string {
names := []string{"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"}
return names[weekday]
}
func dateStart(t time.Time) time.Time { func dateStart(t time.Time) time.Time {
return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location()) return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
} }
@@ -52,13 +52,14 @@ const activeClass = "bg-blue-50 text-blue-600 dark:bg-dk-card dark:text-blue-400
const normalClass = "rounded-md px-3 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-dk-subtle dark:hover:bg-dk-card dark:hover:text-dk-text"; const normalClass = "rounded-md px-3 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-dk-subtle dark:hover:bg-dk-card dark:hover:text-dk-text";
const navItems = computed(() => [ const navItems = computed(() => [
{ label: t("appname.aichat"), to: "/aichat" },
{ label: t("appname.home"), to: "/" }, { label: t("appname.home"), to: "/" },
// { label: t("appname.schedule"), to: "/schedule" }, // { label: t("appname.schedule"), to: "/schedule" },
{ label: t("appname.calendar"), to: "/calendars" }, { label: t("appname.calendar"), to: "/calendars" },
{ label: t("appname.purchase"), to: "/purchase" }, { label: t("appname.purchase"), to: "/purchase" },
{ label: t("appname.work_order"), to: "/work_order" }, { label: t("appname.work_order"), to: "/work_order" },
{ label: t("appname.warehouse"), to: "/warehouse" }, { label: t("appname.warehouse"), to: "/warehouse" },
{ label: t("appname.aichat"), to: "/aichat" },
]); ]);
</script> </script>
+3 -3
View File
@@ -37,11 +37,11 @@
"warehouse_items": "Items Overview", "warehouse_items": "Items Overview",
"work_order": "Work Order", "work_order": "Work Order",
"calendar": "Calendar", "calendar": "Calendar",
"aichat": "AI Chat" "aichat": "AI Assistant"
}, },
"aichat": { "aichat": {
"title": "AI Chat", "title": "AI Assistant",
"subtitle": "Chat with the AI assistant using streaming responses and backend tool traces.", "subtitle": "Chat with the AI assistant using streaming responses.",
"empty_title": "Start an AI chat", "empty_title": "Start an AI chat",
"empty_hint": "Type a question and press Enter to send. Use Shift + Enter for a new line.", "empty_hint": "Type a question and press Enter to send. Use Shift + Enter for a new line.",
"input_placeholder": "Type a message...", "input_placeholder": "Type a message...",
+3 -3
View File
@@ -37,11 +37,11 @@
"warehouse_items": "物品总览", "warehouse_items": "物品总览",
"work_order": "工单", "work_order": "工单",
"calendar": "日历", "calendar": "日历",
"aichat": "AI 对话" "aichat": "AI 助手"
}, },
"aichat": { "aichat": {
"title": "AI 对话", "title": "AI 助手",
"subtitle": "通过流式响应与 AI 助手对话,可显示后端工具执行过程。", "subtitle": "通过流式响应与 AI 助手对话。",
"empty_title": "开始一次 AI 对话", "empty_title": "开始一次 AI 对话",
"empty_hint": "输入问题后按 Enter 发送,Shift + Enter 换行。", "empty_hint": "输入问题后按 Enter 发送,Shift + Enter 换行。",
"input_placeholder": "输入消息...", "input_placeholder": "输入消息...",
@@ -24,9 +24,9 @@ const inputText = ref('')
const selectedImage = ref(null) const selectedImage = ref(null)
const pending = ref(false) const pending = ref(false)
const traces = ref([]) const traces = ref([])
const tracesCollapsed = ref(false) const tracesCollapsed = ref(true)
const reasoning = ref('') const reasoning = ref('')
const reasoningCollapsed = ref(false) const reasoningCollapsed = ref(true)
const stats = ref(null) const stats = ref(null)
const profiles = ref([]) const profiles = ref([])
const activeProfile = ref('') const activeProfile = ref('')
@@ -278,9 +278,9 @@ function bindServerConversation(conversation) {
function resetStreamDetails() { function resetStreamDetails() {
traces.value = [] traces.value = []
tracesCollapsed.value = false tracesCollapsed.value = true
reasoning.value = '' reasoning.value = ''
reasoningCollapsed.value = false reasoningCollapsed.value = true
stats.value = null stats.value = null
clearSelectedImage() clearSelectedImage()
} }
@@ -473,9 +473,9 @@ async function sendMessage() {
inputText.value = '' inputText.value = ''
clearSelectedImage() clearSelectedImage()
traces.value = [] traces.value = []
tracesCollapsed.value = false tracesCollapsed.value = true
reasoning.value = '' reasoning.value = ''
reasoningCollapsed.value = false reasoningCollapsed.value = true
stats.value = null stats.value = null
const userMessage = { role: 'user', content: text } const userMessage = { role: 'user', content: text }