file.tsx 720 B

12345678910111213141516171819202122232425262728293031
  1. "use client";
  2. import { initDB } from "react-indexed-db-hook";
  3. import { StoreKey } from "@/app/constant";
  4. import { useIndexedDB } from "react-indexed-db-hook";
  5. export const FileDbConfig = {
  6. name: "@chatgpt-next-web/file",
  7. version: 1,
  8. objectStoresMeta: [
  9. {
  10. store: StoreKey.File,
  11. storeConfig: { keyPath: "id", autoIncrement: true },
  12. storeSchema: [
  13. { name: "data", keypath: "data", options: { unique: false } },
  14. {
  15. name: "created_at",
  16. keypath: "created_at",
  17. options: { unique: false },
  18. },
  19. ],
  20. },
  21. ],
  22. };
  23. export function FileDbInit() {
  24. initDB(FileDbConfig);
  25. }
  26. export function useFileDB() {
  27. return useIndexedDB(StoreKey.File);
  28. }