Files
1Panel/frontend/src/api/interface/file.ts
T
KOMATA af48fed3c2 feat: Add file preview functionality and interface (#11200)
* feat: Add file content preview functionality

- Implemented a new API endpoint for previewing file content.
- Added PreviewContent method in BaseApi to handle requests.
- Introduced GetPreviewContent method in FileService to retrieve file previews.
- Updated frontend to include a TextPreview component for displaying file previews.
- Added localization support for preview-related messages in multiple languages.
- Enhanced file management view to support previewing large files.

* feat: Update file preview functionality and interface

- Added PreviewContentReq interface to define request parameters for file preview.
- Updated getPreviewContent function to use the new PreviewContentReq type.
- Modified text-preview component to align with updated API, removing unnecessary parameters.
2025-12-08 16:37:50 +08:00

254 lines
5.1 KiB
Go

import { CommonModel, ReqPage } from '.';
export namespace File {
export interface File extends CommonModel {
path: string;
name: string;
user: string;
group: string;
uid: number;
gid: number;
content: string;
size: number;
isDir: boolean;
isSymlink: boolean;
isHidden: boolean;
linkPath: string;
type: string;
updateTime: string;
modTime: string;
mode: number;
mimeType: string;
dirSize: number;
items: File[];
extension: string;
itemTotal: number;
favoriteID: number;
}
export interface ReqFile extends ReqPage {
path: string;
search?: string;
expand: boolean;
dir?: boolean;
showHidden?: boolean;
containSub?: boolean;
sortBy?: string;
sortOrder?: string;
isDetail?: boolean;
}
export interface ReqNodeFile extends ReqFile {
node: string;
}
export interface PreviewContentReq {
path: string;
isDetail?: boolean;
}
export interface SearchUploadInfo extends ReqPage {
path: string;
}
export interface UploadInfo {
name: string;
size: number;
createdAt: string;
}
export interface FileTree {
id: string;
name: string;
isDir: boolean;
path: string;
children?: FileTree[];
}
export interface FileCreate {
path: string;
isDir: boolean;
mode?: number;
isLink?: boolean;
isSymlink?: boolean;
linkPath?: boolean;
sub?: boolean;
name?: string;
}
export interface FileDelete {
path: string;
isDir: boolean;
forceDelete: boolean;
}
export interface FileBatchDelete {
isDir: boolean;
paths: Array<string>;
}
export interface FileCompress {
files: string[];
type: string;
dst: string;
name: string;
replace: boolean;
secret: string;
}
export interface FileDeCompress {
path: string;
dst: string;
type: string;
secret: string;
}
export interface FileEdit {
path: string;
content: string;
}
export interface FileRename {
oldName: string;
newName: string;
}
export interface FileOwner {
path: string;
user: string;
group: string;
sub: boolean;
}
export interface FileWget {
path: string;
name: string;
url: string;
ignoreCertificate?: boolean;
}
export interface FileWgetRes {
key: string;
}
export interface FileKeys {
keys: string[];
}
export interface FileMove {
oldPaths: string[];
newPath: string;
type: string;
}
export interface FileDownload {
paths: string[];
name: string;
url: string;
}
export interface FileChunkDownload {
name: string;
path: string;
}
export interface DirSizeReq {
path: string;
}
export interface DirSizeRes {
size: number;
}
export interface DepthDirSizeRes {
size: number;
path: string;
}
export interface FilePath {
path: string;
}
export interface ExistFileInfo {
name: string;
path: string;
size: number;
uploadSize: number;
modTime: string;
isDir: boolean;
}
export interface RecycleBin {
sourcePath: string;
name: string;
isDir: boolean;
size: number;
deleteTime: string;
rName: string;
from: string;
}
export interface RecycleBinReduce {
rName: string;
from: string;
name: string;
}
export interface FileReadByLine {
id?: number;
type: string;
name?: string;
page: number;
pageSize: number;
taskID?: string;
taskType?: string;
taskOperate?: string;
resourceID?: number;
}
export interface Favorite extends CommonModel {
path: string;
isDir: boolean;
isTxt: boolean;
name: string;
}
export interface FileRole {
paths: string[];
mode: number;
user: string;
group: string;
sub: boolean;
}
export interface UserGroupResponse {
users: UserInfo[];
groups: string[];
}
export interface UserInfo {
username: string;
group: string;
}
export interface ConvertFile {
type: string;
path: string;
extension: string;
inputFile: string;
outputFormat: string;
}
export interface ConvertFileRequest {
files: ConvertFile[];
outputPath: string;
deleteSource: boolean;
taskID: string;
}
export interface ConvertLogResponse {
date: string;
type: string;
log: string;
status: string;
message: string;
}
}