type -> enum

pull/97/head
orzi! 3 years ago
parent 54da8cdf35
commit d33d7b4c57

@ -273,6 +273,7 @@ import {
import { createPost } from '@/api/post'; import { createPost } from '@/api/post';
import { parsePostTag } from '@/utils/content'; import { parsePostTag } from '@/utils/content';
import type { MentionOption, UploadFileInfo, UploadInst } from 'naive-ui'; import type { MentionOption, UploadFileInfo, UploadInst } from 'naive-ui';
import { VisibilityEnum, PostItemTypeEnum } from '@/utils/IEnum';
@ -297,8 +298,12 @@ const fileQueue = ref<UploadFileInfo[]>([]);
const imageContents = ref<Item.CommentItemProps[]>([]); const imageContents = ref<Item.CommentItemProps[]>([]);
const videoContents = ref<Item.CommentItemProps[]>([]); const videoContents = ref<Item.CommentItemProps[]>([]);
const attachmentContents = ref<Item.AttachmentProps[]>([]); const attachmentContents = ref<Item.AttachmentProps[]>([]);
const visitType = ref<Item.VisibilityStatus>(0) const visitType = ref<VisibilityEnum>(VisibilityEnum.PUBLIC);
const visibilities = [{value: 0, label: "公开"}, {value: 1, label: "私密"}, {value: 2, label: "好友可见"}] const visibilities = [
{value: VisibilityEnum.PUBLIC, label: "公开"}
, {value: VisibilityEnum.PRIVATE, label: "私密"}
, {value: VisibilityEnum.FRIEND, label: "好友可见"}
];
const uploadGateway = import.meta.env.VITE_HOST + '/v1/attachment'; const uploadGateway = import.meta.env.VITE_HOST + '/v1/attachment';
const uploadToken = ref(); const uploadToken = ref();
@ -505,7 +510,7 @@ const submitPost = () => {
contents.push({ contents.push({
content: content.value, content: content.value,
type: 2, // 文字 type: PostItemTypeEnum.TEXT, // 文字
sort, sort,
}); });
@ -513,7 +518,7 @@ const submitPost = () => {
sort++; sort++;
contents.push({ contents.push({
content: img.content, content: img.content,
type: 3, // 图片 type: PostItemTypeEnum.IMAGEURL, // 图片
sort, sort,
}); });
}); });
@ -521,7 +526,7 @@ const submitPost = () => {
sort++; sort++;
contents.push({ contents.push({
content: video.content, content: video.content,
type: 4, // 图片 type: PostItemTypeEnum.VIDEOURL, // 视频
sort, sort,
}); });
}); });
@ -529,7 +534,7 @@ const submitPost = () => {
sort++; sort++;
contents.push({ contents.push({
content: attachment.content, content: attachment.content,
type: 7, // 附件 type: PostItemTypeEnum.ATTACHMENT, // 附件
sort, sort,
}); });
}); });
@ -538,7 +543,7 @@ const submitPost = () => {
sort++; sort++;
contents.push({ contents.push({
content: link, content: link,
type: 6, // 链接 type: PostItemTypeEnum.LINKURL, // 链接
sort, sort,
}); });
}); });
@ -567,7 +572,7 @@ const submitPost = () => {
imageContents.value = []; imageContents.value = [];
videoContents.value = []; videoContents.value = [];
attachmentContents.value = []; attachmentContents.value = [];
visitType.value = 0; visitType.value = VisibilityEnum.PUBLIC;
}) })
.catch((err) => { .catch((err) => {
submitting.value = false; submitting.value = false;

@ -26,7 +26,7 @@
</n-tag> </n-tag>
<n-tag <n-tag
v-if="post.visibility == 1" v-if="post.visibility == VisibilityEnum.PUBLIC"
class="top-tag" class="top-tag"
type="error" type="error"
size="small" size="small"
@ -35,7 +35,7 @@
</n-tag> </n-tag>
<n-tag <n-tag
v-if="post.visibility == 2" v-if="post.visibility == VisibilityEnum.FRIEND"
class="top-tag" class="top-tag"
type="info" type="info"
size="small" size="small"
@ -219,6 +219,7 @@ import {
visibilityPost visibilityPost
} from '@/api/post'; } from '@/api/post';
import type { DropdownOption } from 'naive-ui'; import type { DropdownOption } from 'naive-ui';
import { VisibilityEnum } from '@/utils/IEnum';
const store = useStore(); const store = useStore();
const router = useRouter(); const router = useRouter();
@ -235,7 +236,7 @@ const showLockModal = ref(false);
const showStickModal = ref(false); const showStickModal = ref(false);
const showVisibilityModal = ref(false); const showVisibilityModal = ref(false);
const loading = ref(false); const loading = ref(false);
const tempVisibility = ref<Item.VisibilityStatus>(0); const tempVisibility = ref<VisibilityEnum>(VisibilityEnum.PUBLIC);
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'reload'): void; (e: 'reload'): void;
@ -314,7 +315,7 @@ const adminOptions = computed(() => {
}); });
} }
} }
if (post.value.visibility === 0) { if (post.value.visibility === VisibilityEnum.PUBLIC) {
options.push({ options.push({
label: '', label: '',
key: 'vpublic', key: 'vpublic',
@ -323,7 +324,7 @@ const adminOptions = computed(() => {
, { label: '', key: 'vfriend' } , { label: '', key: 'vfriend' }
] ]
}) })
} else if (post.value.visibility === 1) { } else if (post.value.visibility === VisibilityEnum.PRIVATE) {
options.push({ options.push({
label: '', label: '',
key: 'vprivate', key: 'vprivate',

@ -17,4 +17,4 @@ declare global {
$message: MessageApiInjection, $message: MessageApiInjection,
$store: any $store: any
} }
} }

@ -127,7 +127,7 @@ declare module NetParams {
interface PostVisibilityPost { interface PostVisibilityPost {
id: number, id: number,
/** 可见性0为公开1为私密2为好友可见 */ /** 可见性0为公开1为私密2为好友可见 */
visibility: Item.VisibilityStatus visibility: import('@/utils/IEnum').VisibilityEnum
} }
interface PostGetPostStar { interface PostGetPostStar {
@ -165,7 +165,7 @@ declare module NetParams {
/** 附件价格 */ /** 附件价格 */
attachment_price: number, attachment_price: number,
/** 可见性0为公开1为私密2为好友可见 */ /** 可见性0为公开1为私密2为好友可见 */
visibility: Item.VisibilityStatus visibility: import('@/utils/IEnum').VisibilityEnum
} }
interface PostDeletePost { interface PostDeletePost {

@ -118,7 +118,7 @@ declare module NetReq {
interface PostVisibilityPost { interface PostVisibilityPost {
/** 可见性0为公开1为私密2为好友可见 */ /** 可见性0为公开1为私密2为好友可见 */
visibility_status: Item.VisibilityStatus visibility_status: import('@/utils/IEnum').VisibilityEnum
} }
interface PostGetPostStar { interface PostGetPostStar {

@ -1,8 +1,5 @@
declare module Item { declare module Item {
/** 可见性0为公开1为私密2为好友可见 */
type VisibilityStatus = 0 | 1 | 2;
interface UserInfo { interface UserInfo {
/** 用户UID */ /** 用户UID */
id: number, id: number,
@ -31,7 +28,7 @@ declare module Item {
/** 评论者UID */ /** 评论者UID */
user_id: number, user_id: number,
/** 类别1为标题2为文字段落3为图片地址4为视频地址5为语音地址6为链接地址 */ /** 类别1为标题2为文字段落3为图片地址4为视频地址5为语音地址6为链接地址 */
type: number, type: import('@/utils/IEnum').CommentItemTypeEnum,
/** 内容 */ /** 内容 */
content: string, content: string,
/** 排序,越小越靠前 */ /** 排序,越小越靠前 */
@ -114,7 +111,7 @@ declare module Item {
/** 内容ID */ /** 内容ID */
id: number, id: number,
/** 类型1为标题2为文字段落3为图片地址4为视频地址5为语音地址6为链接地址7为附件资源8为收费资源 */ /** 类型1为标题2为文字段落3为图片地址4为视频地址5为语音地址6为链接地址7为附件资源8为收费资源 */
type: number, type: import('@/utils/IEnum').PostItemTypeEnum,
/** POST ID */ /** POST ID */
post_id: number, post_id: number,
/** 内容 */ /** 内容 */
@ -165,7 +162,7 @@ declare module Item {
/** 标签列表 */ /** 标签列表 */
tags: { [key: string]: number } | string, tags: { [key: string]: number } | string,
/** 可见性0为公开1为私密2为好友可见 */ /** 可见性0为公开1为私密2为好友可见 */
visibility: VisibilityStatus, visibility: import('@/utils/IEnum').VisibilityEnum,
/** 是否锁定 */ /** 是否锁定 */
is_lock: number, is_lock: number,
/** 是否置顶 */ /** 是否置顶 */
@ -195,7 +192,7 @@ declare module Item {
interface MessageProps { interface MessageProps {
id: number, id: number,
/** 类型1为动态2为评论3为回复4为私信99为系统通知 */ /** 类型1为动态2为评论3为回复4为私信99为系统通知 */
type: 1 | 2 | 3 | 4 | 99, type: import('@/utils/IEnum').MessageTypeEnum,
/** 摘要说明 */ /** 摘要说明 */
brief: string, brief: string,
/** 详细内容 */ /** 详细内容 */
@ -233,7 +230,7 @@ declare module Item {
interface AttachmentProps { interface AttachmentProps {
id: number, id: number,
/** 类别1为图片2为视频3为其他附件 */ /** 类别1为图片2为视频3为其他附件 */
type: 1 | 2 | 3, type: import('@/utils/IEnum').AttachmentTypeEnum,
/** 发布者用户UID */ /** 发布者用户UID */
user_id: number, user_id: number,
/** 发布者用户数据 */ /** 发布者用户数据 */

@ -0,0 +1,69 @@
/** 动态内容类型枚举 */
export enum PostItemTypeEnum {
/** 标题 */
TITLE = 1,
/** 文字段落 */
TEXT = 2,
/** 图片地址 */
IMAGEURL = 3,
/** 视频地址 */
VIDEOURL = 4,
/** 音频地址 */
AUDIOURL = 5,
/** 链接地址 */
LINKURL = 6,
/** 附件资源 */
ATTACHMENT = 7,
/** 收费资源 */
CHARGEATTACHMENT = 8
}
/** 回复内容类型枚举 */
export enum CommentItemTypeEnum {
/** 标题 */
TITLE = 1,
/** 文字段落 */
TEXT = 2,
/** 图片地址 */
IMAGEURL = 3,
/** 视频地址 */
VIDEOURL = 4,
/** 音频地址 */
AUDIOURL = 5,
/** 链接地址 */
LINKURL = 6
}
/** 附件类型枚举 */
export enum AttachmentTypeEnum {
/** 图片 */
IMAGE = 1,
/** 视频 */
VIDEO = 2,
/** 其他 */
OTHER = 3
}
/** 消息类型枚举 */
export enum MessageTypeEnum {
/** 动态 */
POST = 1,
/** 评论 */
COMMENT = 2,
/** 回复 */
REPLY = 3,
/** 私信 */
PRIVATELETTER = 4,
/** 系统通知 */
SYSTEMNOTICE = 99
}
/** 动态可见度枚举 */
export enum VisibilityEnum {
/** 公开 */
PUBLIC,
/** 私密 */
PRIVATE,
/** 好友可见 */
FRIEND
}

@ -102,7 +102,7 @@
<n-form-item path="phone" label="手机号"> <n-form-item path="phone" label="手机号">
<n-input <n-input
:value="modelData.phone" :value="modelData.phone"
@update:value="(v) => (modelData.phone = v.trim())" @update:value="(v: string) => (modelData.phone = v.trim())"
placeholder="请输入中国大陆手机号" placeholder="请输入中国大陆手机号"
@keydown.enter.prevent @keydown.enter.prevent
/> />

Loading…
Cancel
Save