fix bug
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, onMounted, onUnmounted } from "vue";
|
import { ref, computed, onMounted, onUnmounted } from "vue";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { X, Calendar, ChevronLeft, ChevronRight, Copy } from "lucide-vue-next";
|
import { X, Calendar, ChevronLeft, ChevronRight, Copy, ArrowDown, ArrowUp } from "lucide-vue-next";
|
||||||
import { currentDate, showToast, getTagName, logicalMinutesToTime, toISODate, mainTags } from "../../store";
|
import { currentDate, showToast, getTagName, logicalMinutesToTime, toISODate, mainTags } from "../../store";
|
||||||
import { DBEvent } from "../../types";
|
import { DBEvent } from "../../types";
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@ const selectedTags = ref<number[]>(mainTags.value.map(t => t.id));
|
|||||||
// 表格数据
|
// 表格数据
|
||||||
const dateList = ref<string[]>([]);
|
const dateList = ref<string[]>([]);
|
||||||
const previewData = ref<Record<string, Record<number, string>>>({});
|
const previewData = ref<Record<string, Record<number, string>>>({});
|
||||||
|
const isDesc = ref(false);
|
||||||
|
const sortedDateList = computed(() => isDesc.value ? [...dateList.value].reverse() : dateList.value);
|
||||||
|
|
||||||
const toggleTag = (id: number) => {
|
const toggleTag = (id: number) => {
|
||||||
if (selectedTags.value.includes(id)) {
|
if (selectedTags.value.includes(id)) {
|
||||||
@@ -141,7 +143,7 @@ const copyToClipboard = async () => {
|
|||||||
const header = ["日期", ...selectedTags.value.map(id => getTagName(id))];
|
const header = ["日期", ...selectedTags.value.map(id => getTagName(id))];
|
||||||
let tsv = header.join("\t") + "\n";
|
let tsv = header.join("\t") + "\n";
|
||||||
|
|
||||||
for (const date of dateList.value) {
|
for (const date of sortedDateList.value) {
|
||||||
let row = [date];
|
let row = [date];
|
||||||
for (const tagId of selectedTags.value) {
|
for (const tagId of selectedTags.value) {
|
||||||
let cellStr = previewData.value[date][tagId] || "";
|
let cellStr = previewData.value[date][tagId] || "";
|
||||||
@@ -243,7 +245,14 @@ const copyToClipboard = async () => {
|
|||||||
<!-- 表格预览区域 -->
|
<!-- 表格预览区域 -->
|
||||||
<div v-if="dateList.length > 0" class="flex-1 flex flex-col border-t border-border-main pt-6">
|
<div v-if="dateList.length > 0" class="flex-1 flex flex-col border-t border-border-main pt-6">
|
||||||
<div class="flex justify-between items-center mb-4 flex-shrink-0">
|
<div class="flex justify-between items-center mb-4 flex-shrink-0">
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
<h3 class="text-sm font-bold text-text-sec flex items-center gap-2">数据预览</h3>
|
<h3 class="text-sm font-bold text-text-sec flex items-center gap-2">数据预览</h3>
|
||||||
|
<button @click="isDesc = !isDesc" class="flex items-center gap-1.5 px-3 py-1.5 bg-bg-input hover:bg-border-main text-text-sec hover:text-text-main rounded-lg text-xs font-bold transition-all active:scale-95">
|
||||||
|
<ArrowDown v-if="!isDesc" :size="14" />
|
||||||
|
<ArrowUp v-else :size="14" />
|
||||||
|
{{ isDesc ? '倒序 (由近及远)' : '正序 (由远及近)' }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<button @click="copyToClipboard" class="flex items-center gap-1.5 px-4 py-2 bg-[#007AFF] hover:bg-[#007AFF]/90 text-white rounded-xl text-xs font-bold transition-all shadow-lg shadow-[#007AFF]/20 active:scale-95">
|
<button @click="copyToClipboard" class="flex items-center gap-1.5 px-4 py-2 bg-[#007AFF] hover:bg-[#007AFF]/90 text-white rounded-xl text-xs font-bold transition-all shadow-lg shadow-[#007AFF]/20 active:scale-95">
|
||||||
<Copy :size="14" /> 一键复制完整表格
|
<Copy :size="14" /> 一键复制完整表格
|
||||||
</button>
|
</button>
|
||||||
@@ -260,7 +269,7 @@ const copyToClipboard = async () => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="bg-bg-card">
|
<tbody class="bg-bg-card">
|
||||||
<tr v-for="date in dateList" :key="date" class="border-b border-border-main/30 hover:bg-bg-input/50 transition-colors">
|
<tr v-for="date in sortedDateList" :key="date" class="border-b border-border-main/30 hover:bg-bg-input/50 transition-colors">
|
||||||
<td class="p-4 font-bold whitespace-nowrap text-text-main align-top">
|
<td class="p-4 font-bold whitespace-nowrap text-text-main align-top">
|
||||||
{{ date }}
|
{{ date }}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user