import styles from "./DuplicateFile.module.less"; import { Col, Row, Button, message, Table, Select, Space, Input, Progress, Pagination, PaginationProps, } from "antd"; import { useEffect, useState } from "react"; const { Option } = Select; import { historyListType, insertSearchFilesPasamsType } from "@/types/files"; import { CopyText } from "@/components/Table/CopyText"; import type { FixedType } from "rc-table/lib/interface"; import FileInfoEditer from "./FileInfoEditer"; import { FileInfoType } from "@/types/files"; import { get_all_history, get_info_by_path, insertSeletedFileHistory } from "@/services"; import dayjs from "dayjs"; import { DEFAULT_TIME_FORMAT } from "@/config"; import Database from "tauri-plugin-sql-api"; import { createSql } from "@/databases/createTableSql"; const db = await Database.load("sqlite:test.db"); const { Search } = Input; const { TextArea } = Input; export default function DuplicateFile() { const [total, setTotal] = useState(20); // 页数 const [current, setCurrent] = useState(1); // 页码 const [usePath, setUsePath] = useState(); const [historyList, setHistoryList] = useState([]); const [fileList, setFileList] = useState([ { id: 1, path: "D:/code/wb_project/bar_association_app", time: "2024-01-23", progress: 80, }, { id: 2, path: "D:/code/wb_project/bar_association_app", time: "2024-01-23", progress: 20, }, { id: 3, path: "D:/code/wb_project/bar_association_app", time: "2024-01-23", progress: 90, }, ]); const [isModalOpen, setIsModalOpen] = useState(false); const [fileInfo, setFileInfo] = useState({}); const [fileInfoSource, setFileInfoSource] = useState({}); const columns = [ { title: "ID", dataIndex: "id", key: "id", width: 30, render: (text: string, record: { id: number }) => ( ), }, { title: "路径", dataIndex: "path", key: "path", width: 300, render: (text: string, record: { path: string }) => ( ), }, { title: "时间", dataIndex: "time", key: "time", width: 100, render: (text: string, record: { time: string }) => ( ), }, { title: "进度", dataIndex: "time", key: "time", with: 200, render: (text: string, record: { progress: number }) => (
), }, { title: "操作", dataIndex: "actions", key: "actions", fixed: "right" as FixedType, width: 220, render: () => ( ), }, ]; useEffect(() => { getFileList() }, []) async function handleOk(newFileInfo: FileInfoType) { console.log(180, newFileInfo); const res = await insertSeletedFileHistory(newFileInfo.path, newFileInfo); console.log(133, res); } function handleCancel() { setFileInfo({}); setIsModalOpen(false); } async function openModal(info?: FileInfoType) { initDB() // setIsModalOpen(true); // const res = await insertSeletedFileHistory('/Users/sysadmin/Downloads'); // console.log(133, res); // const res = await get_info_by_path('/Users/sysadmin/Downloads') // console.log(135, res) /* setIsModalOpen(true); setFileInfoSource({ path: "/Users/sysadmin/Downloads", checkedTypeValues: ["音频", "图片"], checkedSizeValues: ["巨大(4GB+)", "大(128MB ~ 1GB-)"], addType: "2131231231231" }); */ /* {path: "/Users/sysadmin/Downloads", checkedTypeValues: ["音频", "图片"], checkedSizeValues: ["巨大(4GB+)", "大(128MB ~ 1GB-)"]} [Log] 180 (FileInfoEditer.tsx, line 69) Object addType: "2131231231231" checkedSizeValues: ["巨大(4GB+)", "大(128MB ~ 1GB-)", "中(1MB ~ 128MB-)"] (3) checkedTypeValues: ["音频", "图片"] (2) path: "/Users/sysadmin/Downloads" Object Prototype */ } async function getFileList() { const {data, total: localeTotal} = await get_all_history(current, total); console.log(173, data); const newFileList = data.map(item => { return { ...item, time: dayjs(item.time).format(DEFAULT_TIME_FORMAT) } }) setFileList(newFileList) setTotal(localeTotal) } async function initDB() { try { const result = await db.execute(createSql.search_files); console.log(179, result); } catch (error) { console.log(182, error); } } const onPaginationChange: PaginationProps['onChange'] = (page) => { console.log(page); setCurrent(page); }; return (

); }