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>('/api/config/GetConfig', 'GET') .then((res) => { console.log(res) return res; }) .finally(() => { }); } //修改配置 async function apiUpdateConfig(request: object) { return http .request>('/api/config/UpdateConfig', 'post_json', request) .then((res) => { console.log(res) return res; }) .finally(() => { }); } //后台日志 async function apiGetLogs(param: string) { return http.request>('/api/logs/GetLog?' + param, 'get').then(r => { // console.log(r) return r.data; }).finally(() => { }); } //用户信息-头像 async function apiUserInfo() { return http.request>('/api/auth/GetUserAvatar', 'get').then(r => { return r; }).finally(() => { }); } //密码修改 async function apiChangePwd(param: object) { return http.request>('/api/auth/UpdatePwd', 'post_json', param).then(r => { return r; }).finally(() => { }); } //StartJobNow async function StartJobNow() { return http.request>('/api/config/ExecuteJobNow', 'get').then(r => { return r; }).finally(() => { }); } async function VideoStatics() { return http.request>('/api/video/statics', 'get').then(r => { return r; }).finally(() => { }); } //视频查询 async function VideoPageList(param: object) { return http.request>('/api/video/paged', 'post_json', param).then(r => { return r; }).finally(() => { }); } //cookies async function CookiePageList(param: object) { return http.request>('/api/config/paged', 'post_json', param).then(r => { return r; }).finally(() => { }); } async function CookieList() { return http.request>('/api/config/list', 'get').then(r => { return r; }).finally(() => { }); } async function UpdateConfig(param: object) { return http.request>('/api/config/update', 'post_json', param).then(r => { return r; }).finally(() => { }); } async function DeskInitAsync(param: object) { return http.request>('/api/config/deskinit', 'post_json', param).then(r => { return r; }).finally(() => { }); } async function AppisInit() { return http.request>('/api/config/isInit', 'get').then(r => { return r; }).finally(() => { }); } async function GetAppPort() { return http.request>('/api/config/appport', 'get').then(r => { return r; }).finally(() => { }); } async function deleteCookie(id: string) { return http.request>('/api/config/delete?id=' + id, 'get').then(r => { return r; }).finally(() => { }); } //follows async function FollowList(param: object) { return http.request>('/api/follow/paged', 'post_json', param).then(r => { return r; }).finally(() => { }); } //同步关注列表 async function SyncFollow() { return http.request>('/api/follow/sync', 'get').then(r => { return r; }).finally(() => { }); } //更新同步关注者状态 async function OpenOrCloseSync(param: object) { return http.request>('/api/follow/openOrCloseSync', 'post_json', param).then(r => { return r; }).finally(() => { }); } //更新同步关注者状态 async function OpenOrCloseFullSync(param: object) { return http.request>('/api/follow/openOrCloseFullSync', 'post_json', param).then(r => { return r; }).finally(() => { }); } //重新下载 async function ReDownViedos(param: object) { return http.request>('/api/video/redown', 'post_json', param).then(r => { return r; }).finally(() => { }); } //删除 async function DeleteVideo(param: string) { return http.request>('/api/video/vdelete/' + param, 'get').then(r => { return r; }).finally(() => { }); } //删除 async function GetDeleteViedos() { return http.request>('/api/video/vdelete/get', 'get').then(r => { return r; }).finally(() => { }); } //检查版本 async function CheckTag() { return http.request>('/api/config/checktag', 'get').then(r => { return r; }).finally(() => { }); } //快速停止或启动cookie配置 async function SwitchCookieStatus(param: object) { return http.request>('/api/config/switch', 'post_json', param).then(r => { return r; }).finally(() => { }); } //添加非关注的博主 async function AddFollow(param: object) { return http.request>('/api/follow/add', 'post_json', param).then(r => { return r; }).finally(() => { }); } //删除非关注的博主 async function DelFollow(param: object) { return http.request>('/api/follow/delete', 'post_json', param).then(r => { return r; }).finally(() => { }); } //导出配置 async function ExportConf() { return http.request>('/api/config/exportConf', 'get').then(r => { return r; }).finally(() => { }); } //导入配置 async function ImportConf(param: object) { return http.request>('/api/config/importConf', 'post_json', param).then(r => { return r; }).finally(() => { }); } //移动端获取日志列表 async function MobileLogs() { return http.request>('/api/logs/list', 'get').then(r => { return r; }).finally(() => { }); } //移动端获取日志详情 async function LogDetail(type: string, date: string) { return http.request>('/api/logs/content?type=' + type + "&Date=" + date, 'get').then(r => { return r; }).finally(() => { }); } //TOP async function TopVideo(param: number) { return http.request>('/api/Video/top' + param, 'get').then(r => { return r; }).finally(() => { }); } return { GetAppPort, AppisInit, DeskInitAsync, SwitchCookieStatus, TopVideo, LogDetail, MobileLogs, ExportConf, ImportConf, GetDeleteViedos, DelFollow, AddFollow, CheckTag, deleteCookie, UpdateConfig, apiGetConfig, apiUpdateConfig, apiGetLogs, apiUserInfo, apiChangePwd, StartJobNow, VideoStatics, VideoPageList, CookiePageList, CookieList, FollowList, SyncFollow, OpenOrCloseSync, OpenOrCloseFullSync, ReDownViedos, DeleteVideo }; });