mirror of
https://github.com/Nezumi-2711/next-gdrive-index.git
synced 2026-09-23 04:10:03 +00:00
Add Next SEO and clean some code
This commit is contained in:
@@ -33,44 +33,6 @@ export function buildQuery({
|
||||
return query.join(" and ");
|
||||
}
|
||||
|
||||
export async function _checkProtected(id: string) {
|
||||
try {
|
||||
const files = await drive.files.list({
|
||||
q: id ? buildQuery({ id }) : buildQuery({}),
|
||||
fields: "files(id)",
|
||||
});
|
||||
|
||||
return {
|
||||
protected: files.data.files?.length,
|
||||
id: files.data.files?.[0].id || null,
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
protected: false,
|
||||
id: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function _validateFolderPassword(
|
||||
passwordFileId: string,
|
||||
password: string,
|
||||
) {
|
||||
try {
|
||||
const folderPassword = await drive.files.get(
|
||||
{
|
||||
fileId: passwordFileId,
|
||||
alt: "media",
|
||||
},
|
||||
{ responseType: "text" },
|
||||
);
|
||||
|
||||
return folderPassword.data === password;
|
||||
} catch (error: any) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function validateProtected(
|
||||
fileId: string | TFileParent[],
|
||||
passwordHash?: string,
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
BsBoxFill,
|
||||
BsDatabaseFill,
|
||||
BsFileEarmarkBinaryFill,
|
||||
BsFileEarmarkBreakFill,
|
||||
BsFileEarmarkCodeFill,
|
||||
BsFileEarmarkFill,
|
||||
BsFileEarmarkFontFill,
|
||||
@@ -13,14 +12,11 @@ import {
|
||||
BsFileEarmarkPdfFill,
|
||||
BsFileEarmarkPlayFill,
|
||||
BsFileEarmarkRichtextFill,
|
||||
BsFileEarmarkRuledFill,
|
||||
BsFileEarmarkSlidesFill,
|
||||
BsFileEarmarkSpreadsheetFill,
|
||||
BsFileEarmarkTextFill,
|
||||
BsFileEarmarkWordFill,
|
||||
BsFileEarmarkZipFill,
|
||||
BsFillDatabaseFill,
|
||||
BsFolderFill,
|
||||
} from "react-icons/bs";
|
||||
import ModelPreview from "@components/FilePreview/ModelPreview";
|
||||
import AudioPreview from "@components/FilePreview/AudioPreview";
|
||||
@@ -33,7 +29,7 @@ import CodePreview from "@components/FilePreview/CodePreview";
|
||||
import TextPreview from "@components/FilePreview/TextPreview";
|
||||
import VideoPreview from "@components/FilePreview/VideoPreview";
|
||||
|
||||
export default function findMimeType(extension: string): string {
|
||||
function findMimeType(extension: string): string {
|
||||
return mime.lookup(extension) || "application/octet-stream";
|
||||
}
|
||||
|
||||
|
||||
@@ -4,17 +4,6 @@ import { FilesResponse } from "@/types/googleapis";
|
||||
const fetcher = async <T>(url: string, headers: Record<string, string> = {}) =>
|
||||
axios.get<T>(url, { headers }).then((res) => res.data);
|
||||
|
||||
function getNextKey(
|
||||
pageIndex: number,
|
||||
previousPageData: FilesResponse,
|
||||
): string | null {
|
||||
if (previousPageData && !previousPageData.nextPageToken) {
|
||||
return null;
|
||||
}
|
||||
const pageToken = previousPageData ? previousPageData.nextPageToken : "";
|
||||
return `/api/files?pageToken=${pageToken}`;
|
||||
}
|
||||
|
||||
export function buildNextKey(apiURL: string) {
|
||||
return (pageIndex: number, previousPageData: FilesResponse) => {
|
||||
if (previousPageData && !previousPageData.nextPageToken) {
|
||||
|
||||
Reference in New Issue
Block a user