fix: move services types to common/interface

This commit is contained in:
shuai 2022-09-29 10:46:30 +08:00
parent 0144033216
commit 158402b9c8
46 changed files with 378 additions and 365 deletions

View File

@ -7,3 +7,302 @@ export interface FormValue<T = any> {
export interface FormDataType {
[prop: string]: FormValue;
}
export interface Paging {
page: number;
page_size?: number;
}
export type ReportType = 'question' | 'answer' | 'comment' | 'user';
export type ReportAction = 'close' | 'flag' | 'review';
export interface ReportParams {
type: ReportType;
action: ReportAction;
}
export interface TagBase {
display_name: string;
slug_name: string;
}
export interface Tag extends TagBase {
main_tag_slug_name?: string;
original_text?: string;
parsed_text?: string;
}
export interface SynonymsTag extends Tag {
tag_id: string;
tag?: string;
}
export interface TagInfo extends TagBase {
tag_id: string;
original_text: string;
parsed_text: string;
follow_count: number;
question_count: number;
is_follower: boolean;
member_actions;
created_at?;
updated_at?;
main_tag_slug_name?: string;
excerpt?;
}
export interface QuestionParams {
title: string;
content: string;
html: string;
tags: Tag[];
}
export interface ListResult<T = any> {
count: number;
list: T[];
}
export interface AnswerParams {
content: string;
html: string;
question_id: string;
id: string;
}
export interface LoginReqParams {
e_mail: string;
/** password */
pass: string;
captcha_id?: string;
captcha_code?: string;
}
export interface RegisterReqParams extends LoginReqParams {
name: string;
}
export interface ModifyPassReq {
old_pass: string;
pass: string;
}
/** User */
export interface ModifyUserReq {
display_name: string;
username?: string;
avatar: string;
bio: string;
bio_html?: string;
location: string;
website: string;
}
export interface UserInfoBase {
avatar: string;
username: string;
display_name: string;
rank: number;
website: string;
location: string;
ip_info?: string;
/** 'forbidden' | 'normal' | 'delete'
*/
status?: string;
/** roles */
is_admin?: true;
}
export interface UserInfoRes extends UserInfoBase {
bio: string;
bio_html: string;
create_time?: string;
/** value = 1 active; value = 2 inactivated
*/
mail_status: number;
e_mail?: string;
[prop: string]: any;
}
export interface AvatarUploadReq {
file: FormData;
}
export interface ImgCodeReq {
captcha_id?: string;
captcha_code?: string;
}
export interface ImgCodeRes {
captcha_id: string;
captcha_img: string;
verify: boolean;
}
export interface PssRetReq extends ImgCodeReq {
e_mail: string;
}
export interface CheckImgReq {
action: 'login' | 'e_mail' | 'find_pass';
}
export interface NoticeSetReq {
notice_switch: boolean;
}
export interface QuDetailRes {
id: string;
title: string;
content: string;
html: string;
tags: any[];
view_count: number;
unique_view_count?: number;
answer_count: number;
favorites_count: number;
follow_counts: 0;
accepted_answer_id: string;
last_answer_id: string;
create_time: string;
update_time: string;
user_info: UserInfoBase;
answered: boolean;
collected: boolean;
[prop: string]: any;
}
export interface AnswersReq extends Paging {
order?: 'default' | 'updated';
question_id: string;
}
export interface AnswerItem {
id: string;
question_id: string;
content: string;
html: string;
create_time: string;
update_time: string;
user_info: UserInfoBase;
[prop: string]: any;
}
export interface PostAnswerReq {
content: string;
html: string;
question_id: string;
}
export interface PageUser {
id;
displayName;
userName?;
avatar_url?;
}
export interface LangsType {
label: string;
value: string;
}
/**
* @description interface for Question
*/
export type QuestionOrderBy =
| 'newest'
| 'active'
| 'frequent'
| 'score'
| 'unanswered';
export interface QueryQuestionsReq extends Paging {
order: QuestionOrderBy;
tags?: string[];
}
export type AdminQuestionStatus = 'available' | 'closed' | 'deleted';
export type AdminContentsFilterBy = 'normal' | 'closed' | 'deleted';
export interface AdminContentsReq extends Paging {
status: AdminContentsFilterBy;
}
/**
* @description interface for Answer
*/
export type AdminAnswerStatus = 'available' | 'deleted';
/**
* @description interface for Users
*/
export type UserFilterBy = 'all' | 'inactive' | 'suspended' | 'deleted';
/**
* @description interface for Flags
*/
export type FlagStatus = 'pending' | 'completed';
export type FlagType = 'all' | 'question' | 'answer' | 'comment';
export interface AdminFlagsReq extends Paging {
status: FlagStatus;
object_type: FlagType;
}
/**
* @description interface for Admin Settings
*/
export interface AdminSettingsGeneral {
name: string;
short_description: string;
description: string;
}
export interface AdminSettingsInterface {
logo: string;
language: string;
theme: string;
}
export interface SiteSettings {
general: AdminSettingsGeneral;
interface: AdminSettingsInterface;
}
/**
* @description interface for Activity
*/
export interface FollowParams {
is_cancel: boolean;
object_id: string;
}
/**
* @description search request params
*/
export interface SearchParams {
q: string;
order: string;
page: number;
size?: number;
}
/**
* @description search response data
*/
export interface SearchResItem {
object_type: string;
object: {
id: string;
title: string;
excerpt: string;
created_at: number;
user_info: UserInfoBase;
vote_count: number;
answer_count: number;
accepted: boolean;
tags: TagBase[];
};
}
export interface SearchRes extends ListResult<SearchResItem> {
extra: any;
}

View File

@ -7,6 +7,7 @@ import classNames from 'classnames';
import { unionBy } from 'lodash';
import { marked } from 'marked';
import * as Types from '@answer/common/interface';
import {
useQueryComments,
addComment,
@ -16,7 +17,6 @@ import {
} from '@answer/api';
import { Modal } from '@answer/components';
import { usePageUsers, useReportModal } from '@answer/hooks';
import * as Types from '@answer/services/types';
import { matchedUsers, parseUserInfo, isLogin } from '@answer/utils';
import { Form, ActionBar, Reply } from './components';

View File

@ -1,7 +1,7 @@
import React, { useEffect, useRef, useState, FC } from 'react';
import { Dropdown } from 'react-bootstrap';
import * as Types from '@answer/services/types';
import * as Types from '@answer/common/interface';
interface IProps {
children: React.ReactNode;

View File

@ -3,8 +3,11 @@ import { Modal, Form, Button, InputGroup } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { Icon } from '@answer/components';
import type { FormValue, FormDataType } from '@answer/common/interface';
import type { ImgCodeRes } from '@answer/services/types';
import type {
FormValue,
FormDataType,
ImgCodeRes,
} from '@answer/common/interface';
interface IProps {
/** control visible */

View File

@ -4,7 +4,7 @@ import { NavLink, useParams, useSearchParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { useQuestionList } from '@answer/api';
import type * as Type from '@answer/services/types';
import type * as Type from '@answer/common/interface';
import { Icon, Tag, Pagination, FormatTime, Empty } from '@answer/components';
const QuestionOrderKeys: Type.QuestionOrderBy[] = [

View File

@ -8,7 +8,7 @@ import classNames from 'classnames';
import { Icon } from '@answer/components';
import { useTagModal } from '@answer/hooks';
import { queryTags } from '@answer/api';
import type * as Type from '@answer/services/types';
import type * as Type from '@answer/common/interface';
import './index.scss';

View File

@ -4,8 +4,11 @@ import { Trans, useTranslation } from 'react-i18next';
import { emailReSend, checkImgCode } from '@answer/api';
import { PicAuthCodeModal } from '@answer/components/Modal';
import type { ImgCodeRes, ImgCodeReq } from '@answer/services/types';
import type { FormDataType } from '@answer/common/interface';
import type {
ImgCodeRes,
ImgCodeReq,
FormDataType,
} from '@answer/common/interface';
import { userInfoStore } from '@answer/stores';
interface IProps {

View File

@ -2,7 +2,7 @@ import { useState } from 'react';
import { uniqBy } from 'lodash';
import * as Types from '@answer/services/types';
import * as Types from '@answer/common/interface';
let globalUsers: Types.PageUser[] = [];
const usePageUsers = () => {

View File

@ -6,7 +6,7 @@ import ReactDOM from 'react-dom/client';
import { reportList, postReport, closeQuestion, putReport } from '@answer/api';
import { useToast } from '@answer/hooks';
import type * as Type from '@answer/services/types';
import type * as Type from '@answer/common/interface';
interface Params {
isBackend?: boolean;

View File

@ -21,8 +21,7 @@ import {
import { ADMIN_LIST_STATUS } from '@answer/common/constants';
import { useEditStatusModal } from '@answer/hooks';
import { useAnswerSearch, changeAnswerStatus } from '@answer/api';
import * as Type from '@/services/types';
import * as Type from '@answer/common/interface';
import '../index.scss';

View File

@ -10,7 +10,7 @@ import {
Pagination,
} from '@answer/components';
import { useReportModal } from '@answer/hooks';
import * as Type from '@answer/services/types';
import * as Type from '@answer/common/interface';
import { useFlagSearch } from '@answer/api';
import '../index.scss';

View File

@ -2,13 +2,11 @@ import React, { FC, useEffect, useState } from 'react';
import { Form, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import type * as Type from '@answer/services/types';
import type * as Type from '@answer/common/interface';
import { useToast } from '@answer/hooks';
import { siteInfoStore } from '@answer/stores';
import { useGeneralSetting, updateGeneralSetting } from '@answer/api';
import { FormDataType } from '@/common/interface';
import '../index.scss';
const General: FC = () => {
@ -19,7 +17,7 @@ const General: FC = () => {
const updateSiteInfo = siteInfoStore((state) => state.update);
const { data: setting } = useGeneralSetting();
const [formData, setFormData] = useState<FormDataType>({
const [formData, setFormData] = useState<Type.FormDataType>({
name: {
value: '',
isInvalid: false,
@ -101,7 +99,7 @@ const General: FC = () => {
if (!formData[fieldName]) {
return;
}
const fieldData: FormDataType = {
const fieldData: Type.FormDataType = {
[fieldName]: {
value: fieldValue,
isInvalid: false,

View File

@ -3,9 +3,11 @@ import { Form, Button, Image, Stack } from 'react-bootstrap';
import { Trans, useTranslation } from 'react-i18next';
import { useToast } from '@answer/hooks';
import * as Type from '@answer/services/types';
import { LangsType } from '@answer/services/types';
import { FormDataType } from '@answer/common/interface';
import {
LangsType,
FormDataType,
AdminSettingsInterface,
} from '@answer/common/interface';
import {
languages,
uploadAvatar,
@ -110,7 +112,7 @@ const Interface: FC = () => {
if (checkValidated() === false) {
return;
}
const reqParams: Type.AdminSettingsInterface = {
const reqParams: AdminSettingsInterface = {
logo: formData.logo.value,
theme: formData.theme.value,
language: formData.language.value,

View File

@ -25,8 +25,7 @@ import {
changeQuestionStatus,
questionDelete,
} from '@answer/api';
import * as Type from '@/services/types';
import * as Type from '@answer/common/interface';
import '../index.scss';

View File

@ -10,7 +10,7 @@ import {
BaseUserCard,
Empty,
} from '@answer/components';
import * as Type from '@answer/services/types';
import * as Type from '@answer/common/interface';
import { useChangeModal } from '@answer/hooks';
import '../index.scss';

View File

@ -15,7 +15,7 @@ import {
postAnswer,
useQueryQuestionByTitle,
} from '@answer/api';
import type * as Type from '@/services/types';
import type * as Type from '@answer/common/interface';
import SearchQuestion from './components/SearchQuestion';

View File

@ -12,8 +12,7 @@ import {
} from '@answer/components';
import { acceptanceAnswer } from '@answer/api';
import { scrollTop } from '@answer/utils';
import { AnswerItem } from '@/services/types';
import { AnswerItem } from '@answer/common/interface';
interface Props {
data: AnswerItem;

View File

@ -6,8 +6,7 @@ import { marked } from 'marked';
import { Editor, Modal } from '@answer/components';
import { postAnswer } from '@answer/api';
import { FormDataType } from '@/common/interface';
import { FormDataType } from '@answer/common/interface';
interface Props {
visible?: boolean;

View File

@ -7,6 +7,11 @@ import { Pagination, PageTitle } from '@answer/components';
import { userInfoStore } from '@answer/stores';
import { scrollTop } from '@answer/utils';
import { usePageUsers } from '@answer/hooks';
import type {
ListResult,
QuDetailRes,
AnswerItem,
} from '@answer/common/interface';
import {
Question,
@ -17,8 +22,6 @@ import {
Alert,
} from './components';
import type { ListResult, QuDetailRes, AnswerItem } from '@/services/types';
import './index.scss';
const Index = () => {

View File

@ -12,7 +12,7 @@ import {
modifyAnswer,
useQueryRevisions,
} from '@answer/api';
import type * as Type from '@/services/types';
import type * as Type from '@answer/common/interface';
import './index.scss';

View File

@ -2,7 +2,7 @@ import { memo, FC } from 'react';
import { ListGroupItem, Badge } from 'react-bootstrap';
import { Icon, Tag, FormatTime } from '@answer/components';
import type { SearchResItem } from '@answer/services/types';
import type { SearchResItem } from '@answer/common/interface';
import { formatCount } from '@answer/utils';
interface Props {

View File

@ -3,7 +3,7 @@ import { Container, Row, Col, Button } from 'react-bootstrap';
import { useParams, Link, useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import * as Type from '@/services/types';
import * as Type from '@answer/common/interface';
import { PageTitle, FollowingTags } from '@answer/components';
import { useTagInfo, useFollow } from '@answer/api';

View File

@ -3,8 +3,12 @@ import { Form, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { passRetrieve, checkImgCode } from '@answer/api';
import type { FormDataType } from '@/common/interface';
import type { ImgCodeRes, PssRetReq } from '@/services/types';
import type {
ImgCodeRes,
PssRetReq,
FormDataType,
} from '@answer/common/interface';
import { PicAuthCodeModal } from '@/components/Modal';
interface IProps {

View File

@ -3,13 +3,17 @@ import { Container, Form, Button, Col } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next';
import type { FormDataType } from '@/common/interface';
import { login, checkImgCode } from '@answer/api';
import type { LoginReqParams, ImgCodeRes } from '@/services/types';
import type {
LoginReqParams,
ImgCodeRes,
FormDataType,
} from '@answer/common/interface';
import { PageTitle, Unactivate } from '@answer/components';
import { PicAuthCodeModal } from '@/components/Modal';
import { userInfoStore } from '@answer/stores';
import { isLogin, getQueryString } from '@answer/utils';
import { PicAuthCodeModal } from '@/components/Modal';
import Storage from '@/utils/storage';
const Index: React.FC = () => {

View File

@ -3,12 +3,12 @@ import { Container, Col, Form, Button } from 'react-bootstrap';
import { Link } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import type { FormDataType } from '@/common/interface';
import { passRetrieveSet } from '@answer/api';
import { userInfoStore } from '@answer/stores';
import Storage from '@/utils/storage';
import { getQueryString, isLogin } from '@answer/utils';
import type { FormDataType } from '@answer/common/interface';
import Storage from '@/utils/storage';
import { PageTitle } from '@/components';
const Index: React.FC = () => {

View File

@ -3,7 +3,7 @@ import { Badge, OverlayTrigger, Tooltip } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import { Avatar, Icon } from '@answer/components';
import type { UserInfoRes } from '@/services/types';
import type { UserInfoRes } from '@answer/common/interface';
interface Props {
data: UserInfoRes;

View File

@ -4,7 +4,8 @@ import { Link } from 'react-router-dom';
import { Trans, useTranslation } from 'react-i18next';
import { register } from '@answer/api';
import type { FormDataType } from '@/common/interface';
import type { FormDataType } from '@answer/common/interface';
import userStore from '@/stores/userInfo';
interface Props {

View File

@ -2,8 +2,7 @@ import React, { FC, FormEvent, useEffect, useState } from 'react';
import { Form, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import type { FormDataType } from '@/common/interface';
import type * as Type from '@/services/types';
import type * as Type from '@answer/common/interface';
import { getUserInfo, changeEmail } from '@answer/api';
import { useToast } from '@answer/hooks';
@ -14,7 +13,7 @@ const Index: FC = () => {
keyPrefix: 'settings.account',
});
const [step, setStep] = useState(1);
const [formData, setFormData] = useState<FormDataType>({
const [formData, setFormData] = useState<Type.FormDataType>({
e_mail: {
value: '',
isInvalid: false,
@ -29,7 +28,7 @@ const Index: FC = () => {
});
}, []);
const handleChange = (params: FormDataType) => {
const handleChange = (params: Type.FormDataType) => {
setFormData({ ...formData, ...params });
};

View File

@ -2,9 +2,9 @@ import React, { FC, FormEvent, useState } from 'react';
import { Form, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import type { FormDataType } from '@/common/interface';
import { modifyPassword } from '@answer/api';
import { useToast } from '@answer/hooks';
import type { FormDataType } from '@answer/common/interface';
const Index: FC = () => {
const { t } = useTranslation('translation', {

View File

@ -7,9 +7,9 @@ import en from 'dayjs/locale/en';
import zh from 'dayjs/locale/zh-cn';
import { languages } from '@answer/api';
import type { FormDataType } from '@/common/interface';
import type { LangsType } from '@/services/types';
import type { LangsType, FormDataType } from '@answer/common/interface';
import { useToast } from '@answer/hooks';
import Storage from '@/utils/storage';
const Index = () => {

View File

@ -2,7 +2,7 @@ import React, { useState, FormEvent, useEffect } from 'react';
import { Form, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import type { FormDataType } from '@/common/interface';
import type { FormDataType } from '@answer/common/interface';
import { noticeSet, getUserInfo } from '@answer/api';
import { useToast } from '@answer/hooks';

View File

@ -5,7 +5,7 @@ import { Trans, useTranslation } from 'react-i18next';
import { marked } from 'marked';
import { modifyUserInfo, uploadAvatar, getUserInfo } from '@answer/api';
import type { FormDataType } from '@/common/interface';
import type { FormDataType } from '@answer/common/interface';
import { UploadImg, Avatar } from '@answer/components';
import { userInfoStore } from '@answer/stores';
import { useToast } from '@answer/hooks';

View File

@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next';
import { Outlet } from 'react-router-dom';
import { getUserInfo } from '@answer/api';
import type { FormDataType } from '@/common/interface';
import type { FormDataType } from '@answer/common/interface';
import Nav from './components/Nav';

View File

@ -2,7 +2,7 @@ import useSWR from 'swr';
import qs from 'qs';
import request from '@answer/utils/request';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const useAnswerSearch = (params: Type.AdminContentsReq) => {
const apiUrl = `/answer/admin/api/answer/page?${qs.stringify(params)}`;

View File

@ -2,7 +2,7 @@ import useSWR from 'swr';
import qs from 'qs';
import request from '@answer/utils/request';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const putReport = (params) => {
return request.instance.put('/answer/admin/api/report', params);

View File

@ -2,7 +2,7 @@ import qs from 'qs';
import useSWR from 'swr';
import request from '@answer/utils/request';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const changeUserStatus = (params) => {
return request.put('/answer/admin/api/user/status', params);

View File

@ -1,7 +1,7 @@
import useSWR from 'swr';
import request from '@answer/utils/request';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const useGeneralSetting = () => {
const apiUrl = `/answer/admin/api/siteinfo/general`;

View File

@ -1,7 +1,7 @@
import useSWR from 'swr';
import request from '@answer/utils/request';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const useFollow = (params?: Type.FollowParams) => {
const apiUrl = '/answer/api/v1/follow';

View File

@ -3,7 +3,7 @@ import qs from 'qs';
import request from '@answer/utils/request';
import { isLogin } from '@answer/utils';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const useQueryNotifications = (params) => {
const apiUrl = `/answer/api/v1/notification/page?${qs.stringify(params, {

View File

@ -2,7 +2,7 @@ import useSWR from 'swr';
import qs from 'qs';
import request from '@answer/utils/request';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const usePersonalInfoByName = (username: string) => {
const apiUrl = '/answer/api/v1/personal/user/info';

View File

@ -2,7 +2,7 @@ import useSWR from 'swr';
import qs from 'qs';
import request from '@answer/utils/request';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const useQuestionList = (params: Type.QueryQuestionsReq) => {
const apiUrl = `/answer/api/v1/question/page?${qs.stringify(params)}`;

View File

@ -2,7 +2,7 @@ import useSWR from 'swr';
import qs from 'qs';
import request from '@answer/utils/request';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const useSearch = (params?: Type.SearchParams) => {
const apiUrl = '/answer/api/v1/search';

View File

@ -2,7 +2,7 @@ import useSWR from 'swr';
import request from '@answer/utils/request';
import { isLogin } from '@answer/utils';
import type * as Type from '../types';
import type * as Type from '@answer/common/interface';
export const deleteTag = (id) => {
return request.delete('/answer/api/v1/tag', {

View File

@ -2,8 +2,7 @@ import qs from 'qs';
import useSWR from 'swr';
import request from '@answer/utils/request';
import type * as Type from './types';
import type * as Type from '@answer/common/interface';
export const uploadImage = (file) => {
const form = new FormData();

View File

@ -1,298 +0,0 @@
export interface Paging {
page: number;
page_size?: number;
}
export type ReportType = 'question' | 'answer' | 'comment' | 'user';
export type ReportAction = 'close' | 'flag' | 'review';
export interface ReportParams {
type: ReportType;
action: ReportAction;
}
export interface TagBase {
display_name: string;
slug_name: string;
}
export interface Tag extends TagBase {
main_tag_slug_name?: string;
original_text?: string;
parsed_text?: string;
}
export interface SynonymsTag extends Tag {
tag_id: string;
tag?: string;
}
export interface TagInfo extends TagBase {
tag_id: string;
original_text: string;
parsed_text: string;
follow_count: number;
question_count: number;
is_follower: boolean;
member_actions;
created_at?;
updated_at?;
main_tag_slug_name?: string;
excerpt?;
}
export interface QuestionParams {
title: string;
content: string;
html: string;
tags: Tag[];
}
export interface ListResult<T = any> {
count: number;
list: T[];
}
export interface AnswerParams {
content: string;
html: string;
question_id: string;
id: string;
}
export interface LoginReqParams {
e_mail: string;
/** password */
pass: string;
captcha_id?: string;
captcha_code?: string;
}
export interface RegisterReqParams extends LoginReqParams {
name: string;
}
export interface ModifyPassReq {
old_pass: string;
pass: string;
}
/** User */
export interface ModifyUserReq {
display_name: string;
username?: string;
avatar: string;
bio: string;
bio_html?: string;
location: string;
website: string;
}
export interface UserInfoBase {
avatar: string;
username: string;
display_name: string;
rank: number;
website: string;
location: string;
ip_info?: string;
/** 'forbidden' | 'normal' | 'delete'
*/
status?: string;
/** roles */
is_admin?: true;
}
export interface UserInfoRes extends UserInfoBase {
bio: string;
bio_html: string;
create_time?: string;
/** value = 1 active; value = 2 inactivated
*/
mail_status: number;
e_mail?: string;
[prop: string]: any;
}
export interface AvatarUploadReq {
file: FormData;
}
export interface ImgCodeReq {
captcha_id?: string;
captcha_code?: string;
}
export interface ImgCodeRes {
captcha_id: string;
captcha_img: string;
verify: boolean;
}
export interface PssRetReq extends ImgCodeReq {
e_mail: string;
}
export interface CheckImgReq {
action: 'login' | 'e_mail' | 'find_pass';
}
export interface NoticeSetReq {
notice_switch: boolean;
}
export interface QuDetailRes {
id: string;
title: string;
content: string;
html: string;
tags: any[];
view_count: number;
unique_view_count?: number;
answer_count: number;
favorites_count: number;
follow_counts: 0;
accepted_answer_id: string;
last_answer_id: string;
create_time: string;
update_time: string;
user_info: UserInfoBase;
answered: boolean;
collected: boolean;
[prop: string]: any;
}
export interface AnswersReq extends Paging {
order?: 'default' | 'updated';
question_id: string;
}
export interface AnswerItem {
id: string;
question_id: string;
content: string;
html: string;
create_time: string;
update_time: string;
user_info: UserInfoBase;
[prop: string]: any;
}
export interface PostAnswerReq {
content: string;
html: string;
question_id: string;
}
export interface PageUser {
id;
displayName;
userName?;
avatar_url?;
}
export interface LangsType {
label: string;
value: string;
}
/**
* @description interface for Question
*/
export type QuestionOrderBy =
| 'newest'
| 'active'
| 'frequent'
| 'score'
| 'unanswered';
export interface QueryQuestionsReq extends Paging {
order: QuestionOrderBy;
tags?: string[];
}
export type AdminQuestionStatus = 'available' | 'closed' | 'deleted';
export type AdminContentsFilterBy = 'normal' | 'closed' | 'deleted';
export interface AdminContentsReq extends Paging {
status: AdminContentsFilterBy;
}
/**
* @description interface for Answer
*/
export type AdminAnswerStatus = 'available' | 'deleted';
/**
* @description interface for Users
*/
export type UserFilterBy = 'all' | 'inactive' | 'suspended' | 'deleted';
/**
* @description interface for Flags
*/
export type FlagStatus = 'pending' | 'completed';
export type FlagType = 'all' | 'question' | 'answer' | 'comment';
export interface AdminFlagsReq extends Paging {
status: FlagStatus;
object_type: FlagType;
}
/**
* @description interface for Admin Settings
*/
export interface AdminSettingsGeneral {
name: string;
short_description: string;
description: string;
}
export interface AdminSettingsInterface {
logo: string;
language: string;
theme: string;
}
export interface SiteSettings {
general: AdminSettingsGeneral;
interface: AdminSettingsInterface;
}
/**
* @description interface for Activity
*/
export interface FollowParams {
is_cancel: boolean;
object_id: string;
}
/**
* @description search request params
*/
export interface SearchParams {
q: string;
order: string;
page: number;
size?: number;
}
/**
* @description search response data
*/
export interface SearchResItem {
object_type: string;
object: {
id: string;
title: string;
excerpt: string;
created_at: number;
user_info: UserInfoBase;
vote_count: number;
answer_count: number;
accepted: boolean;
tags: TagBase[];
};
}
export interface SearchRes extends ListResult<SearchResItem> {
extra: any;
}

View File

@ -1,6 +1,6 @@
import create from 'zustand';
import type { UserInfoRes } from '@answer/services/types';
import type { UserInfoRes } from '@answer/common/interface';
import Storage from '@answer/utils/storage';
interface UserInfoStore {