637 lines
19 KiB
TypeScript
637 lines
19 KiB
TypeScript
import { defineStore, storeToRefs } from 'pinia';
|
||
import http from './http';
|
||
import { ref, watch } from 'vue';
|
||
import { Response } from '@/types';
|
||
|
||
// import { RouteOption } from '@/router/interface';
|
||
// import { addRoutes, removeRoute } from '@/router/dynamicRoutes';
|
||
// import { useSettingStore } from './setting';
|
||
// import { RouteRecordRaw, RouteMeta } from 'vue-router';
|
||
// import { useAuthStore } from '@/plugins';
|
||
// import router from '@/router';
|
||
|
||
// export interface MenuProps {
|
||
// id?: number;
|
||
// name: string;
|
||
// path: string;
|
||
// title?: string;
|
||
// icon?: string;
|
||
// badge?: number | string;
|
||
// target?: '_self' | '_blank';
|
||
// link?: string;
|
||
// component: string;
|
||
// renderMenu?: boolean;
|
||
// permission?: string;
|
||
// parent?: string;
|
||
// children?: MenuProps[];
|
||
// cacheable?: boolean;
|
||
// view?: string;
|
||
// }
|
||
|
||
export const useApiStore = defineStore('coreapi', () => {
|
||
|
||
|
||
async function apiGetConfig() {
|
||
return http.request<any, Response<any>>('/api/config/GetConfig', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
// //获取配置
|
||
// async function apiGetConfig() {
|
||
// return http
|
||
// .request<any, Response<any>>('/api/config/GetConfig', 'GET')
|
||
// .then((res) => {
|
||
// return res;
|
||
// })
|
||
// .finally(() => {
|
||
|
||
// });
|
||
// }
|
||
//修改配置
|
||
async function apiUpdateConfig(request: object) {
|
||
return http
|
||
.request<any, Response<any>>('/api/config/UpdateConfig', 'post_json', request)
|
||
.then((res) => {
|
||
console.log(res)
|
||
return res;
|
||
})
|
||
.finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
async function StorageConfig() {
|
||
return http.request<any, Response<any>>('/api/storage/config', 'get');
|
||
}
|
||
|
||
async function StorageInventory() {
|
||
return http.request<any, Response<any>>('/api/storage/inventory', 'get');
|
||
}
|
||
|
||
async function TestStorage(request: object) {
|
||
return http.request<any, Response<any>>('/api/storage/test', 'post_json', request);
|
||
}
|
||
|
||
async function OpenListDirectories(request: object) {
|
||
return http.request<any, Response<any>>('/api/storage/openlist/directories', 'post_json', request);
|
||
}
|
||
|
||
async function UpdateStorage(request: object) {
|
||
return http.request<any, Response<any>>('/api/storage/config', 'put_json', request);
|
||
}
|
||
|
||
async function EmailConfig() {
|
||
return http.request<any, Response<any>>('/api/email/config', 'get');
|
||
}
|
||
|
||
async function UpdateEmailConfig(request: object) {
|
||
return http.request<any, Response<any>>('/api/email/config', 'put_json', request);
|
||
}
|
||
|
||
async function TestEmailConfig(request: object) {
|
||
return http.request<any, Response<any>>('/api/email/test', 'post_json', request);
|
||
}
|
||
|
||
async function StorageMigrationPreflight() {
|
||
return http.request<any, Response<any>>('/api/storage/migrations/preflight', 'post_json', { verifyCapabilities: true });
|
||
}
|
||
|
||
async function CreateStorageMigration(request: object) {
|
||
return http.request<any, Response<any>>('/api/storage/migrations', 'post_json', request);
|
||
}
|
||
|
||
async function LatestStorageMigration() {
|
||
return http.request<any, Response<any>>('/api/storage/migrations/latest', 'get');
|
||
}
|
||
|
||
async function StorageMigrationDetail(id: string) {
|
||
return http.request<any, Response<any>>(`/api/storage/migrations/${id}`, 'get');
|
||
}
|
||
|
||
async function StorageMigrationItems(id: string, pageIndex: number, pageSize: number, stage?: number) {
|
||
const filter = stage === undefined ? '' : `&stage=${stage}`;
|
||
return http.request<any, Response<any>>(`/api/storage/migrations/${id}/items?pageIndex=${pageIndex}&pageSize=${pageSize}${filter}`, 'get');
|
||
}
|
||
|
||
async function StorageMigrationAction(id: string, action: string) {
|
||
return http.request<any, Response<any>>(`/api/storage/migrations/${id}/${action}`, 'post_json', {});
|
||
}
|
||
|
||
async function StorageMigrationFailedRecordsPreview() {
|
||
return http.request<any, Response<any>>('/api/storage/migrations/failed-records/preview', 'get');
|
||
}
|
||
|
||
async function RemoveStorageMigrationFailedRecords(confirmationToken: string) {
|
||
return http.request<any, Response<any>>('/api/storage/migrations/failed-records/remove', 'post_json', { confirmationToken });
|
||
}
|
||
|
||
async function ArchiveStorageMigrationHistory() {
|
||
return http.request<any, Response<any>>('/api/storage/migrations/history/archive', 'post_json', {});
|
||
}
|
||
|
||
async function OpenListDirectoryRepairPreflight(logicalPath = '/collect/Kk') {
|
||
return http.request<any, Response<any>>('/api/storage/openlist/directory-repairs/preflight', 'post_json', { logicalPath });
|
||
}
|
||
|
||
async function CreateOpenListDirectoryRepair(request: object) {
|
||
return http.request<any, Response<any>>('/api/storage/openlist/directory-repairs', 'post_json', request);
|
||
}
|
||
|
||
async function OpenListDirectoryRepairDetail(id: string) {
|
||
return http.request<any, Response<any>>(`/api/storage/openlist/directory-repairs/${id}`, 'get');
|
||
}
|
||
|
||
async function ConfirmOpenListDirectoryRepair(id: string, confirmationToken: string) {
|
||
return http.request<any, Response<any>>(`/api/storage/openlist/directory-repairs/${id}/confirm-cleanup`, 'post_json', { confirmationToken });
|
||
}
|
||
|
||
async function TaskSummary() {
|
||
return http.request<any, Response<any>>('/api/tasks/summary', 'get');
|
||
}
|
||
|
||
async function TaskList(params: Record<string, any> = {}) {
|
||
const query = new URLSearchParams();
|
||
Object.entries(params).forEach(([key, value]) => {
|
||
if (value !== undefined && value !== null && value !== '') query.set(key, String(value));
|
||
});
|
||
return http.request<any, Response<any>>(`/api/tasks?${query.toString()}`, 'get');
|
||
}
|
||
|
||
async function TaskDetail(type: number, id: string) {
|
||
return http.request<any, Response<any>>(`/api/tasks/${type}/${id}`, 'get');
|
||
}
|
||
|
||
async function TaskItems(type: number, id: string, params: Record<string, any> = {}) {
|
||
const query = new URLSearchParams();
|
||
Object.entries(params).forEach(([key, value]) => {
|
||
if (value !== undefined && value !== null && value !== '') query.set(key, String(value));
|
||
});
|
||
return http.request<any, Response<any>>(`/api/tasks/${type}/${id}/items?${query.toString()}`, 'get');
|
||
}
|
||
|
||
async function RetryTaskFailed(type: number, id: string) {
|
||
return http.request<any, Response<any>>(`/api/tasks/${type}/${id}/retry-failed`, 'post_json', {});
|
||
}
|
||
|
||
async function RetryTaskItem(type: number, taskId: string, itemId: string) {
|
||
return http.request<any, Response<any>>(`/api/tasks/${type}/${taskId}/items/${itemId}/retry`, 'post_json', {});
|
||
}
|
||
|
||
async function RetryTaskItemCleanup(type: number, taskId: string, itemId: string) {
|
||
return http.request<any, Response<any>>(`/api/tasks/${type}/${taskId}/items/${itemId}/retry-cleanup`, 'post_json', {});
|
||
}
|
||
|
||
async function TaskAction(type: number, id: string, action: string) {
|
||
return http.request<any, Response<any>>(`/api/tasks/${type}/${id}/actions/${action}`, 'post_json', {});
|
||
}
|
||
|
||
async function ProbeTaskStorage() {
|
||
return http.request<any, Response<any>>('/api/tasks/storage-health/probe', 'post_json', {});
|
||
}
|
||
|
||
async function StartTaskSync(videoType?: string | number) {
|
||
const query = videoType === undefined || videoType === null || videoType === ''
|
||
? ''
|
||
: `?videoType=${encodeURIComponent(String(videoType))}`;
|
||
return http.request<any, Response<any>>(`/api/tasks/sync${query}`, 'post_json', {});
|
||
}
|
||
|
||
async function VideoExclusions(params: Record<string, any> = {}) {
|
||
const query = new URLSearchParams();
|
||
Object.entries(params).forEach(([key, value]) => {
|
||
if (value !== undefined && value !== null && value !== '') query.set(key, String(value));
|
||
});
|
||
return http.request<any, Response<any>>(`/api/video/exclusions?${query.toString()}`, 'get');
|
||
}
|
||
|
||
async function UnexcludeVideos(ids: string[], createDownloadTask: boolean) {
|
||
return http.request<any, Response<any>>('/api/video/exclusions/unexclude', 'post_json', { ids, createDownloadTask });
|
||
}
|
||
//后台日志
|
||
async function apiGetLogs(param: string) {
|
||
return http.request<any, Response<any>>('/api/logs/GetLog/' + param, 'get').then(r => {
|
||
// console.log(r)
|
||
return r.data;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//用户信息-头像
|
||
async function apiUserInfo() {
|
||
return http.request<any, Response<any>>('/api/auth/GetUserAvatar', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//密码修改
|
||
async function apiChangePwd(param: object) {
|
||
return http.request<any, Response<any>>('/api/auth/UpdatePwd', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//StartJobNow
|
||
async function StartJobNow() {
|
||
return http.request<any, Response<any>>('/api/config/ExecuteJobNow', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//视频统计
|
||
async function VideoStatics() {
|
||
return http.request<any, Response<any>>('/api/video/statics', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//视频曲线
|
||
async function VideoChart(day: number) {
|
||
return http.request<any, Response<any>>(`/api/video/chart/${day}`, 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
//视频查询
|
||
async function VideoPageList(param: object) {
|
||
return http.request<any, Response<any>>('/api/video/paged', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//cookies
|
||
async function CookiePageList(param: object) {
|
||
return http.request<any, Response<any>>('/api/config/paged', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
async function CookieList() {
|
||
return http.request<any, Response<any>>('/api/config/list', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
|
||
async function UpdateConfig(param: object) {
|
||
return http.request<any, Response<any>>('/api/config/update', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
async function DeskInitAsync(param: object) {
|
||
return http.request<any, Response<any>>('/api/config/deskinit', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
async function AppisInit() {
|
||
return http.request<any, Response<any>>('/api/config/isInit', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
|
||
async function deleteCookie(id: string) {
|
||
return http.request<any, Response<any>>('/api/config/delete?id=' + id, 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//follows
|
||
async function FollowList(param: object) {
|
||
return http.request<any, Response<any>>('/api/follow/paged', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//同步关注列表
|
||
async function SyncFollow() {
|
||
return http.request<any, Response<any>>('/api/follow/sync', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//更新同步关注者状态
|
||
async function OpenOrCloseSync(param: object) {
|
||
return http.request<any, Response<any>>('/api/follow/openOrCloseSync', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//更新同步关注者状态
|
||
async function OpenOrCloseFullSync(param: object) {
|
||
return http.request<any, Response<any>>('/api/follow/openOrCloseFullSync', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
async function UpdateFollowLiveMonitor(param: object) {
|
||
return http.request<any, Response<any>>('/api/follow/live-monitor', 'post_json', param).then(r => r);
|
||
}
|
||
async function RefreshFollowLiveStatus(param: object) {
|
||
return http.request<any, Response<any>>('/api/follow/live-status/refresh', 'post_json', param).then(r => r);
|
||
}
|
||
async function QueryFollowLiveStatus(param: object) {
|
||
return http.request<any, Response<any>>('/api/follow/live-status/query', 'post_json', param).then(r => r);
|
||
}
|
||
async function UpdateFollowLiveEmail(param: object) {
|
||
return http.request<any, Response<any>>('/api/follow/live-email', 'post_json', param).then(r => r);
|
||
}
|
||
//重新下载
|
||
async function ReDownViedos(param: object) {
|
||
return http.request<any, Response<any>>('/api/video/redown', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//批量删除
|
||
async function BathRealDelete(param: object) {
|
||
return http.request<any, Response<any>>('/api/video/vdelete/batch', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//删除
|
||
async function DeleteVideo(param: string) {
|
||
return http.request<any, Response<any>>('/api/video/vdelete/' + param, 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//查询已删除
|
||
async function GetDeleteViedos() {
|
||
return http.request<any, Response<any>>('/api/video/vdelete/get', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//删除博主全部视频
|
||
async function DeleteByAuthor(param: string) {
|
||
return http.request<any, Response<any>>('/api/video/vdelete/byauthor/' + param, 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
//检查版本
|
||
async function getVer() {
|
||
return http.request<any, Response<any>>('/api/config/mytag', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//检查版本
|
||
async function CheckTag() {
|
||
return http.request<any, Response<any>>('/api/config/checktag', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
async function mp3List() {
|
||
return http.request<any, Response<any>>('/api/config/mp3List', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
|
||
//快速停止或启动cookie配置
|
||
async function SwitchCookieStatus(param: object) {
|
||
return http.request<any, Response<any>>('/api/config/switch', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
//添加非关注的博主
|
||
async function AddFollow(param: object) {
|
||
return http.request<any, Response<any>>('/api/follow/add', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
// 使用抖音资料页展示的抖音号查找博主,确认结果后再调用 AddFollow
|
||
async function ResolveFollowByDouyinNo(param: { cookieId: string; douyinNo: string }) {
|
||
return http.request<any, Response<any>>('/api/follow/resolve-by-douyin-no', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//删除非关注的博主
|
||
async function DelFollow(param: object) {
|
||
return http.request<any, Response<any>>('/api/follow/delete', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
//导出配置
|
||
async function ExportConf() {
|
||
return http.request<any, Response<any>>('/api/config/exportConf', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//导入配置
|
||
async function ImportConf(param: object) {
|
||
return http.request<any, Response<any>>('/api/config/importConf', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
//移动端获取日志列表
|
||
async function MobileLogs() {
|
||
return http.request<any, Response<any>>('/api/logs/list', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
//移动端获取日志详情
|
||
async function LogDetail(type: string, date: string) {
|
||
return http.request<any, Response<any>>('/api/logs/content?type=' + type + "&Date=" + date, 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
//TOP
|
||
async function TopVideo(param: number) {
|
||
return http.request<any, Response<any>>('/api/Video/top' + param, 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
//Renfo
|
||
async function Renfo() {
|
||
return http.request<any, Response<any>>('/api/Video/renfo', 'get').then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
//合集、自定义收藏夹、短剧列表
|
||
async function CatePageList(param: object) {
|
||
return http.request<any, Response<any>>('/api/cate/paged', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
//批量修改 合集、自定义收藏夹、短剧
|
||
async function BatchSaveCate(param: object) {
|
||
return http.request<any, Response<any>>('/api/cate/BatchSave', 'post_json', param).then(r => {
|
||
return r;
|
||
}).finally(() => {
|
||
|
||
});
|
||
}
|
||
|
||
// // 音频文件上传接口
|
||
// async function apiUploadAudio(formData: FormData, options?: { onUploadProgress?: (progressEvent: ProgressEvent) => void }) {
|
||
// return http
|
||
// .request<any, Response<any>>(
|
||
// '/api/config/UploadAudio', // 请求地址
|
||
// 'post_form', // 使用新增的 post_form 类型
|
||
// formData, // FormData 参数(文件+其他参数)
|
||
// {
|
||
// onUploadProgress: options?.onUploadProgress, // 上传进度回调(原生 ProgressEvent)
|
||
// timeout: 120000 // 上传文件超时时间设为2分钟(可选)
|
||
// }
|
||
// )
|
||
// .then((res) => {
|
||
// // console.log('音频上传结果:', res);
|
||
// // 适配你的响应格式(如果响应是包裹层,取 data)
|
||
// return res;
|
||
// })
|
||
// .catch((err) => {
|
||
// console.error('音频上传失败:', err);
|
||
// throw err; // 抛出错误让前端捕获
|
||
// });
|
||
// }
|
||
|
||
return {
|
||
StorageConfig,
|
||
StorageInventory,
|
||
TestStorage,
|
||
OpenListDirectories,
|
||
UpdateStorage,
|
||
EmailConfig,
|
||
UpdateEmailConfig,
|
||
TestEmailConfig,
|
||
StorageMigrationPreflight,
|
||
CreateStorageMigration,
|
||
LatestStorageMigration,
|
||
StorageMigrationDetail,
|
||
StorageMigrationItems,
|
||
StorageMigrationAction,
|
||
StorageMigrationFailedRecordsPreview,
|
||
RemoveStorageMigrationFailedRecords,
|
||
ArchiveStorageMigrationHistory,
|
||
OpenListDirectoryRepairPreflight,
|
||
CreateOpenListDirectoryRepair,
|
||
OpenListDirectoryRepairDetail,
|
||
ConfirmOpenListDirectoryRepair,
|
||
TaskSummary,
|
||
TaskList,
|
||
TaskDetail,
|
||
TaskItems,
|
||
RetryTaskFailed,
|
||
RetryTaskItem,
|
||
RetryTaskItemCleanup,
|
||
TaskAction,
|
||
ProbeTaskStorage,
|
||
StartTaskSync,
|
||
VideoExclusions,
|
||
UnexcludeVideos,
|
||
VideoChart,
|
||
BatchSaveCate,
|
||
CatePageList,
|
||
getVer,
|
||
mp3List,
|
||
BathRealDelete,
|
||
DeleteByAuthor,
|
||
Renfo,
|
||
// apiUploadAudio,
|
||
AppisInit,
|
||
DeskInitAsync,
|
||
SwitchCookieStatus,
|
||
TopVideo,
|
||
LogDetail,
|
||
MobileLogs,
|
||
ExportConf,
|
||
ImportConf,
|
||
GetDeleteViedos,
|
||
DelFollow,
|
||
AddFollow,
|
||
ResolveFollowByDouyinNo,
|
||
CheckTag,
|
||
deleteCookie,
|
||
UpdateConfig,
|
||
apiGetConfig,
|
||
apiUpdateConfig,
|
||
apiGetLogs,
|
||
apiUserInfo,
|
||
apiChangePwd,
|
||
StartJobNow,
|
||
VideoStatics,
|
||
VideoPageList,
|
||
CookiePageList,
|
||
CookieList,
|
||
FollowList,
|
||
SyncFollow,
|
||
OpenOrCloseSync,
|
||
OpenOrCloseFullSync,
|
||
UpdateFollowLiveMonitor,
|
||
RefreshFollowLiveStatus,
|
||
QueryFollowLiveStatus,
|
||
UpdateFollowLiveEmail,
|
||
ReDownViedos,
|
||
DeleteVideo
|
||
};
|
||
});
|