finish auth
This commit is contained in:
1 parent
f7d93c3abf
commit
903e7040f0
163 files changed
+34
-16975
No files matched your search
@@ -1,18 +1,18 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../../instance';
|
||||
import { IWechatQRCode, IWechatQRCodeResponse, IWechatLoginStatusResponse } from './types';
|
||||
import { IWechatQRCodeResponse, IWechatLoginStatusResponse } from './types';
|
||||
|
||||
class WechatService {
|
||||
key = 'wechat';
|
||||
|
||||
async createQRCode4Login(): Promise<AxiosResponse<IWechatQRCodeResponse>> {
|
||||
return await httpClient.post(`/${this.key}/qrcode/`, {
|
||||
return await httpClient.post(`/${this.key}/qrcode`, {
|
||||
scene: 'login'
|
||||
});
|
||||
}
|
||||
|
||||
async getLoginStatus(ticket: string): Promise<AxiosResponse<IWechatLoginStatusResponse>> {
|
||||
return httpClient.post(`/${this.key}/auth/`, {
|
||||
return httpClient.post(`/${this.key}/authenticate`, {
|
||||
ticket: ticket
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import { DEFAULT_LIMIT } from '@/settings/article';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../../instance';
|
||||
import { IArticle, IArticleDetailResponse, IArticleListResponse } from './types';
|
||||
|
||||
class ArticleService {
|
||||
key = 'articles';
|
||||
|
||||
async getAll(offset: number = 0, limit: number = DEFAULT_LIMIT): Promise<AxiosResponse<IArticleListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/?limit=${limit}&offset=${offset}`);
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
return httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IArticle): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
return httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: string, data: IArticle): Promise<AxiosResponse<IArticleDetailResponse>> {
|
||||
return httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default new ArticleService();
|
||||
@@ -1,15 +0,0 @@
|
||||
export interface IArticle {
|
||||
id?: string;
|
||||
title?: string | undefined;
|
||||
cover?: string | undefined;
|
||||
summary?: string | undefined;
|
||||
content?: string | undefined;
|
||||
updated_at?: string | undefined;
|
||||
}
|
||||
|
||||
export interface IArticleListResponse {
|
||||
count: number;
|
||||
results: IArticle[];
|
||||
}
|
||||
|
||||
export interface IArticleDetailResponse extends IArticle {}
|
||||
@@ -1,29 +0,0 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../../instance';
|
||||
import { IPlatform, IPlatformDetailResponse, IPlatformListResponse } from './types';
|
||||
|
||||
class PlatformService {
|
||||
key = 'platforms';
|
||||
|
||||
async getAll(): Promise<AxiosResponse<IPlatformListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IPlatformDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IPlatform): Promise<AxiosResponse<IPlatformDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IPlatform): Promise<AxiosResponse<IPlatformDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default new PlatformService();
|
||||
@@ -1,13 +0,0 @@
|
||||
export interface IPlatform {
|
||||
id: number;
|
||||
name: string;
|
||||
alias: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface IPlatformListResponse {
|
||||
count: number;
|
||||
results: IPlatform[];
|
||||
}
|
||||
|
||||
export interface IPlatformDetailResponse extends IPlatform {}
|
||||
@@ -1,11 +0,0 @@
|
||||
export const PUBLICATION_STATE_PENDING = 'pending';
|
||||
export const PUBLICATION_STATE_RUNNING = 'running';
|
||||
export const PUBLICATION_STATE_FINISHED = 'finished';
|
||||
|
||||
export const PUBLICATION_STATE_MAP: {
|
||||
[key: string]: string;
|
||||
} = {
|
||||
Pending: PUBLICATION_STATE_PENDING,
|
||||
Running: PUBLICATION_STATE_RUNNING,
|
||||
Finished: PUBLICATION_STATE_FINISHED
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
import { DEFAULT_LIMIT } from '@/settings/article';
|
||||
import { AxiosResponse } from 'axios';
|
||||
import httpClient from '../../instance';
|
||||
import { IPublication, IPublicationDetailResponse, IPublicationListResponse, IPublicationCreateRequest } from './types';
|
||||
|
||||
class PublicationService {
|
||||
key = 'publications';
|
||||
|
||||
async getAll(offset: number = 0, limit: number = DEFAULT_LIMIT): Promise<AxiosResponse<IPublicationListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/?limit=${limit}&offset=${offset}`);
|
||||
}
|
||||
|
||||
async get(id: number): Promise<AxiosResponse<IPublicationDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
}
|
||||
|
||||
async create(data: IPublicationCreateRequest): Promise<AxiosResponse<IPublicationDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
}
|
||||
|
||||
async update(id: number, data: IPublication): Promise<AxiosResponse<IPublicationDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
}
|
||||
|
||||
async delete(id: number): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default new PublicationService();
|
||||
@@ -1,28 +0,0 @@
|
||||
import { IArticle } from '../article/types';
|
||||
import { IPlatform } from '../platform/types';
|
||||
|
||||
export interface IPublication {
|
||||
id: number;
|
||||
name: string;
|
||||
state: string;
|
||||
platform: IPlatform;
|
||||
article: IArticle;
|
||||
}
|
||||
|
||||
export const CREDENTIAL_TYPE_COOKIES = 'Cookies';
|
||||
export const CREDENTIAL_TYPE_TOKEN = 'Token';
|
||||
|
||||
export interface IPublicationCreateRequest {
|
||||
article: string;
|
||||
platform: number;
|
||||
credential: string;
|
||||
state?: string;
|
||||
credentialType?: typeof CREDENTIAL_TYPE_COOKIES | typeof CREDENTIAL_TYPE_TOKEN;
|
||||
}
|
||||
|
||||
export interface IPublicationListResponse {
|
||||
count: number;
|
||||
results: IPublication[];
|
||||
}
|
||||
|
||||
export type IPublicationDetailResponse = IPublication;
|
||||
@@ -1,5 +0,0 @@
|
||||
import ArticleService from './content/article/service';
|
||||
import PlatformService from './content/platform/service';
|
||||
import PublicationService from './content/publication/service';
|
||||
|
||||
export { ArticleService, PlatformService, PublicationService };
|
||||
Reference in new issue
Block a user