Merge pull request #8 from pohunchn/main

前端完善TS
pull/14/head
ROC 2 years ago committed by GitHub
commit ad7fc2d75b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,7 +5,7 @@ import request from '@/utils/request';
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getPosts = (params: any) => { export const getPosts = (params: NetParams.PostGetPosts) => {
return request({ return request({
method: 'get', method: 'get',
url: '/posts', url: '/posts',
@ -18,12 +18,12 @@ export const getPosts = (params: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getTags = (params: any) => { export const getTags = (params: NetParams.PostGetTags) => {
return request({ return request({
method: 'get', method: 'get',
url: '/tags', url: '/tags',
params params
}); }) as unknown as Promise<NetReq.PostGetTags>;
}; };
/** /**
@ -31,12 +31,12 @@ export const getTags = (params: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getPost = (params: any) => { export const getPost = (params: NetParams.PostGetPost) => {
return request({ return request({
method: 'get', method: 'get',
url: '/post', url: '/post',
params params
}); }) as unknown as Promise<NetReq.PostGetPost>;
}; };
/** /**
@ -44,12 +44,12 @@ export const getPost = (params: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getPostStar = (params: any) => { export const getPostStar = (params: NetParams.PostPostStar) => {
return request({ return request({
method: 'get', method: 'get',
url: '/post/star', url: '/post/star',
params params
}); }) as unknown as Promise<NetReq.PostGetPostStar>;
}; };
/** /**
@ -57,12 +57,12 @@ export const getPostStar = (params: any) => {
* @param {Object} data * @param {Object} data
* @returns Promise * @returns Promise
*/ */
export const postStar = (data: any) => { export const postStar = (data: NetParams.PostPostStar) => {
return request({ return request({
method: 'post', method: 'post',
url: '/post/star', url: '/post/star',
data data
}); }) as unknown as Promise<NetReq.PostPostStar>;
}; };
/** /**
@ -70,12 +70,12 @@ export const postStar = (data: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getPostCollection = (params: any) => { export const getPostCollection = (params: NetParams.PostGetPostCollection) => {
return request({ return request({
method: 'get', method: 'get',
url: '/post/collection', url: '/post/collection',
params params
}); }) as unknown as Promise<NetReq.PostGetPostCollection>;
}; };
/** /**
@ -83,12 +83,12 @@ export const getPostCollection = (params: any) => {
* @param {Object} data * @param {Object} data
* @returns Promise * @returns Promise
*/ */
export const postCollection = (data: any) => { export const postCollection = (data: NetParams.PostPostCollection) => {
return request({ return request({
method: 'post', method: 'post',
url: '/post/collection', url: '/post/collection',
data data
}); }) as unknown as Promise<NetReq.PostPostCollection>;
}; };
/** /**
@ -96,12 +96,12 @@ export const postCollection = (data: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getPostComments = (params: any) => { export const getPostComments = (params: NetParams.PostGetPostComments) => {
return request({ return request({
method: 'get', method: 'get',
url: '/post/comments', url: '/post/comments',
params params
}); }) as unknown as Promise<NetReq.PostGetPostComments>;
}; };
/** /**
@ -140,12 +140,12 @@ export const deletePost = (data: any) => {
* - @param {number} id * - @param {number} id
* @returns Promise * @returns Promise
*/ */
export const lockPost = (data: any) => { export const lockPost = (data: NetParams.PostLockPost) => {
return request({ return request({
method: 'post', method: 'post',
url: '/post/lock', url: '/post/lock',
data data
}); }) as unknown as Promise<NetReq.PostLockPost>;
}; };
/** /**

@ -5,12 +5,12 @@ import request from '@/utils/request';
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getCaptcha = (params: any) => { export const getCaptcha = (params: NetParams.UserGetCaptcha = {}) => {
return request({ return request({
method: 'get', method: 'get',
url: '/captcha', url: '/captcha',
params params
}); }) as unknown as Promise<NetReq.UserGetCaptcha>;
}; };
/** /**
@ -31,12 +31,12 @@ export const sendCaptcha = (data: any) => {
* @param {Object} data * @param {Object} data
* @returns Promise * @returns Promise
*/ */
export const bindUserPhone = (data: any) => { export const bindUserPhone = (data: NetParams.UserBindUserPhone) => {
return request({ return request({
method: 'post', method: 'post',
url: '/user/phone', url: '/user/phone',
data data
}); }) as unknown as Promise<NetParams.UserBindUserPhone>;
}; };
/** /**
@ -83,12 +83,12 @@ export const changeAvatar = (data: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getUnreadMsgCount = (params: any) => { export const getUnreadMsgCount = (params: NetParams.UserGetUnreadMsgCount = {}) => {
return request({ return request({
method: 'get', method: 'get',
url: '/user/msgcount/unread', url: '/user/msgcount/unread',
params params
}); }) as unknown as Promise<NetReq.UserGetUnreadMsgCount>;
}; };
/** /**
@ -96,12 +96,12 @@ export const getUnreadMsgCount = (params: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getMessages = (params: any) => { export const getMessages = (params: NetParams.UserGetMessages) => {
return request({ return request({
method: 'get', method: 'get',
url: '/user/messages', url: '/user/messages',
params params
}); }) as unknown as Promise<NetReq.UserGetMessages>;
}; };
/** /**
@ -122,7 +122,7 @@ export const readMessage = (data: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getCollections = (params: any) => { export const getCollections = (params: NetParams.UserGetCollections) => {
return request({ return request({
method: 'get', method: 'get',
url: '/user/collections', url: '/user/collections',
@ -135,12 +135,12 @@ export const getCollections = (params: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getStars = (params: any) => { export const getStars = (params: NetParams.UserGetStars) => {
return request({ return request({
method: 'get', method: 'get',
url: '/user/stars', url: '/user/stars',
params params
}); }) as unknown as Promise<NetReq.UserGetStars>;
}; };
/** /**
@ -148,12 +148,12 @@ export const getStars = (params: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getUserProfile = (params: any) => { export const getUserProfile = (params: NetParams.UserGetUserProfile) => {
return request({ return request({
method: 'get', method: 'get',
url: '/user/profile', url: '/user/profile',
params params
}); }) as unknown as Promise<NetReq.UserGetUserProfile>;
}; };
/** /**
@ -161,12 +161,12 @@ export const getUserProfile = (params: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getUserPosts = (params: any) => { export const getUserPosts = (params: NetParams.UserGetUserPosts) => {
return request({ return request({
method: 'get', method: 'get',
url: '/user/posts', url: '/user/posts',
params params
}); }) as unknown as Promise<NetReq.UserGetUserPosts>;
}; };
/** /**
@ -174,12 +174,12 @@ export const getUserPosts = (params: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getBills = (params: any) => { export const getBills = (params: NetParams.UserGetBills) => {
return request({ return request({
method: 'get', method: 'get',
url: '/user/wallet/bills', url: '/user/wallet/bills',
params params
}); }) as unknown as Promise<NetReq.UserGetBills>;
}; };
/** /**
@ -187,12 +187,12 @@ export const getBills = (params: any) => {
* @param {Object} data * @param {Object} data
* @returns Promise * @returns Promise
*/ */
export const reqRecharge = (data: any) => { export const reqRecharge = (data: NetParams.UserReqRecharge) => {
return request({ return request({
method: 'post', method: 'post',
url: '/user/recharge', url: '/user/recharge',
data data
}); }) as unknown as Promise<NetReq.UserReqRecharge>;
}; };
/** /**
@ -200,12 +200,12 @@ export const reqRecharge = (data: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getRecharge = (params: any) => { export const getRecharge = (params: NetParams.UserGetRecharge) => {
return request({ return request({
method: 'get', method: 'get',
url: '/user/recharge', url: '/user/recharge',
params params
}); }) as unknown as Promise<NetReq.UserGetRecharge>;
}; };
/** /**
@ -239,12 +239,12 @@ export const getSuggestTags = (params: {k: string}) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const precheckAttachment = (params: any) => { export const precheckAttachment = (params: NetParams.UserPrecheckAttachment) => {
return request({ return request({
method: 'get', method: 'get',
url: '/attachment/precheck', url: '/attachment/precheck',
params params
}); }) as unknown as Promise<NetReq.UserPrecheckAttachment>;
}; };
/** /**
@ -252,10 +252,10 @@ export const precheckAttachment = (params: any) => {
* @param {Object} params * @param {Object} params
* @returns Promise * @returns Promise
*/ */
export const getAttachment = (params: any) => { export const getAttachment = (params: NetParams.UserGetAttachment) => {
return request({ return request({
method: 'get', method: 'get',
url: '/attachment', url: '/attachment',
params params
}); }) as unknown as Promise<NetReq.UserGetAttachment>;
}; };

@ -168,18 +168,14 @@ import { createComment } from '@/api/post';
import { getSuggestUsers } from '@/api/user'; import { getSuggestUsers } from '@/api/user';
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 { FileInfo } from 'naive-ui/lib/upload/src/interface';
const emit = defineEmits(['post-success']); const emit = defineEmits(['post-success']);
const props = defineProps({ const props = withDefaults(defineProps<{
lock: { lock: number,
type: Number, postId: number,
default: 0, }>(), {
}, lock: 0,
postId: { postId: 0
type: Number,
default: 0,
},
}); });
const store = useStore(); const store = useStore();

@ -7,12 +7,11 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
const props = defineProps({ const props = withDefaults(defineProps<{
num: { num: number
type: Number, }>(), {
default: 1, num: 1
},
}); });
</script> </script>

@ -35,26 +35,23 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { h, ref } from 'vue'; import { h, ref } from 'vue';
import { CloudDownloadOutline } from '@vicons/ionicons5'; import { CloudDownloadOutline } from '@vicons/ionicons5';
import { precheckAttachment, getAttachment } from '@/api/user'; import { precheckAttachment, getAttachment } from '@/api/user';
const props = defineProps({ const props = withDefaults(defineProps<{
attachments: { attachments: Item.AttachmentProps[],
type: Array, price: number,
default: () => [], }>(), {
}, attachments: () => [],
price: { price: 0
type: Number,
default: 0,
},
}); });
const showDownloadModal = ref(false); const showDownloadModal = ref(false);
const downloadTip = ref(''); const downloadTip = ref<any>('');
const attachmentID = ref(0); const attachmentID = ref(0);
const download = (attachment) => { const download = (attachment: Item.AttachmentProps) => {
showDownloadModal.value = true; showDownloadModal.value = true;
attachmentID.value = attachment.id; attachmentID.value = attachment.id;

@ -133,7 +133,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, onMounted, computed } from 'vue'; import { ref, onMounted, computed } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
@ -160,20 +160,18 @@ const store = useStore();
const router = useRouter(); const router = useRouter();
const hasStarred = ref(false); const hasStarred = ref(false);
const hasCollected = ref(false); const hasCollected = ref(false);
const props = defineProps({ const props = withDefaults(defineProps<{
post: { post: Item.PostProps,
type: Object, }>(), {});
default: () => {},
},
});
const showDelModal = ref(false); const showDelModal = ref(false);
const showLockModal = ref(false); const showLockModal = ref(false);
const loading = ref(false);
const emit = defineEmits(['reload']); const emit = defineEmits(['reload']);
const post = computed({ const post = computed({
get: () => { get: () => {
let post = Object.assign( let post: Required<Item.PostProps> = Object.assign(
{ {
texts: [], texts: [],
imgs: [], imgs: [],
@ -246,7 +244,7 @@ const adminOptions = computed(() => {
return options; return options;
}); });
const goPostDetail = (id) => { const goPostDetail = (id: number) => {
router.push({ router.push({
name: 'post', name: 'post',
query: { query: {
@ -254,9 +252,9 @@ const goPostDetail = (id) => {
}, },
}); });
}; };
const doClickText = (e, id) => { const doClickText = (e: MouseEvent, id: number) => {
if (e.target.dataset.detail) { if ((e.target as any).dataset.detail) {
const d = e.target.dataset.detail.split(':'); const d = (e.target as any).dataset.detail.split(':');
if (d.length === 2) { if (d.length === 2) {
store.commit('refresh'); store.commit('refresh');
if (d[0] === 'tag') { if (d[0] === 'tag') {
@ -280,7 +278,7 @@ const doClickText = (e, id) => {
} }
goPostDetail(id); goPostDetail(id);
}; };
const handlePostAction = (item) => { const handlePostAction = (item: "delete" | "lock" | "unlock") => {
if (item === 'delete') { if (item === 'delete') {
showDelModal.value = true; showDelModal.value = true;
} }

@ -222,18 +222,17 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
const defaultImg = const defaultImg =
'https://paopao-assets.oss-cn-shanghai.aliyuncs.com/public/404.png'; 'https://paopao-assets.oss-cn-shanghai.aliyuncs.com/public/404.png';
const thumbnail = const thumbnail =
'?x-oss-process=image/resize,m_fill,w_300,h_300,limit_0/auto-orient,1/format,png'; '?x-oss-process=image/resize,m_fill,w_300,h_300,limit_0/auto-orient,1/format,png';
const props = defineProps({ const props = withDefaults(defineProps<{
imgs: { imgs: Item.PostProps[],
type: Array, }>(), {
default: () => [], imgs: () => []
},
}); });
</script> </script>

@ -81,7 +81,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { computed } from 'vue'; import { computed } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
@ -96,15 +96,12 @@ import {
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const store = useStore(); const store = useStore();
const props = defineProps({ const props = withDefaults(defineProps<{
post: { post: Item.PostProps,
type: Object, }>(), {});
default: () => {},
},
});
const post = computed(() => { const post = computed(() => {
let post = Object.assign( let post: Required<Item.PostProps> = Object.assign(
{ {
texts: [], texts: [],
imgs: [], imgs: [],
@ -137,7 +134,7 @@ const post = computed(() => {
}); });
return post; return post;
}); });
const goPostDetail = (id) => { const goPostDetail = (id: number) => {
router.push({ router.push({
name: 'post', name: 'post',
query: { query: {
@ -145,9 +142,9 @@ const goPostDetail = (id) => {
}, },
}); });
}; };
const doClickText = (e, id) => { const doClickText = (e: MouseEvent, id: number) => {
if (e.target.dataset.detail) { if ((e.target as any).dataset.detail) {
const d = e.target.dataset.detail.split(':'); const d = (e.target as any).dataset.detail.split(':');
if (d.length === 2) { if (d.length === 2) {
store.commit('refresh'); store.commit('refresh');
if (d[0] === 'tag') { if (d[0] === 'tag') {

@ -14,13 +14,12 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { LinkOutline } from '@vicons/ionicons5'; import { LinkOutline } from '@vicons/ionicons5';
const props = defineProps({ const props = withDefaults(defineProps<{
links: { links: Item.PostProps[]
type: Array, }>(), {
default: () => [], links: () => []
},
}); });
</script> </script>

@ -10,12 +10,11 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
const props = defineProps({ const props = withDefaults(defineProps<{
num: { num: number,
type: Number, }>(), {
default: 1, num: 1
},
}); });
</script> </script>

@ -16,18 +16,15 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { reactive } from 'vue'; import { reactive } from 'vue';
import NVideo from 'nonesir-video'; import NVideo from 'nonesir-video';
const props = defineProps({ const props = withDefaults(defineProps<{
videos: { videos: Item.PostProps[],
type: Array, full: boolean,
default: () => [], }>(), {
}, videos: () => [],
full: { full: false
type: Boolean,
default: false,
},
}); });
</script> </script>

@ -65,18 +65,15 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { Trash } from '@vicons/tabler'; import { Trash } from '@vicons/tabler';
import { formatRelativeTime } from '@/utils/formatTime'; import { formatRelativeTime } from '@/utils/formatTime';
import { deleteCommentReply } from '@/api/post'; import { deleteCommentReply } from '@/api/post';
const props = defineProps({ const props = withDefaults(defineProps<{
reply: { reply: Item.ReplyProps,
type: Object, }>(), {});
default: () => {},
},
});
const store = useStore(); const store = useStore();
const emit = defineEmits(['focusReply', 'reload']); const emit = defineEmits(['focusReply', 'reload']);

@ -68,14 +68,14 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { getTags } from '@/api/post'; import { getTags } from '@/api/post';
import { Search } from '@vicons/ionicons5'; import { Search } from '@vicons/ionicons5';
const tags = ref([]); const tags = ref<Item.TagProps[]>([]);
const loading = ref(false); const loading = ref(false);
const keyword = ref(''); const keyword = ref('');
const store = useStore(); const store = useStore();
@ -95,7 +95,7 @@ const loadTags = () => {
loading.value = false; loading.value = false;
}); });
}; };
const formatQuoteNum = (num) => { const formatQuoteNum = (num: number) => {
if (num >= 1000) { if (num >= 1000) {
return (num / 1000).toFixed(1) + 'k'; return (num / 1000).toFixed(1) + 'k';
} }

@ -87,11 +87,12 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { h, ref, watch, computed, onMounted } from 'vue'; import { h, ref, watch, computed, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { NIcon, NBadge, useMessage } from 'naive-ui'; import { NIcon, NBadge, useMessage } from 'naive-ui';
import type { RouteRecordName } from "vue-router";
import { import {
HomeOutline, HomeOutline,
BookmarkOutline, BookmarkOutline,
@ -110,7 +111,7 @@ const store = useStore();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const hasUnreadMsg = ref(false); const hasUnreadMsg = ref(false);
const selectedPath = ref(route.name || ''); const selectedPath = ref<any>(route.name || '');
const msgLoop = ref(); const msgLoop = ref();
watch(route, () => { watch(route, () => {
@ -217,13 +218,13 @@ const menuOptions = computed(() => {
]; ];
}); });
const renderMenuLabel = (option) => { const renderMenuLabel = (option: AnyObject) => {
if ('href' in option) { if ('href' in option) {
return h('div', {}, option.label); return h('div', {}, option.label);
} }
return option.label; return option.label;
}; };
const renderMenuIcon = (option) => { const renderMenuIcon = (option: AnyObject) => {
if (option.key === 'notification') { if (option.key === 'notification') {
return h( return h(
NBadge, NBadge,
@ -250,7 +251,7 @@ const renderMenuIcon = (option) => {
return h(NIcon, null, { default: option.icon }); return h(NIcon, null, { default: option.icon });
}; };
const goRouter = (name, item) => { const goRouter = (name: string, item: any = {}) => {
selectedPath.value = name; selectedPath.value = name;
router.push({ name }); router.push({ name });
}; };
@ -261,7 +262,7 @@ const goHome = () => {
goRouter('home'); goRouter('home');
}; };
const triggerAuth = (key) => { const triggerAuth = (key: string) => {
store.commit('triggerAuth', true); store.commit('triggerAuth', true);
store.commit('triggerAuthKey', key); store.commit('triggerAuthKey', key);
}; };

@ -6,13 +6,102 @@ declare module NetParams {
} }
interface UserGetCollections { interface UserGetCollections {
list: any[], page: number,
pager: AnyObject page_size: number
}
interface UserPrecheckAttachment {
id: number
}
interface UserGetAttachment {
id: number
}
interface UserGetUnreadMsgCount {
}
interface UserGetMessages {
page: number,
page_size: number
}
interface UserGetUserPosts {
username: string,
page: number,
page_size: number
}
interface UserGetStars {
page: number,
page_size: number
}
interface UserGetUserProfile {
username: string
}
interface UserGetBills {
page: number,
page_size: number
}
interface UserReqRecharge {
amount: number
}
interface UserGetRecharge {
id: number
}
interface UserBindUserPhone {
phone: string,
captcha: string
}
interface UserGetCaptcha {
}
interface PostGetPost {
id: number
} }
interface PostGetPosts { interface PostGetPosts {
list: any[], query: string | null,
pager: AnyObject type: number,
page: number,
page_size: number
}
interface PostLockPost {
id: number
}
interface PostGetPostStar {
id: number
}
interface PostGetPostCollection {
id: number
}
interface PostPostStar {
id: number
}
interface PostPostCollection {
id: number
}
interface PostGetTags {
type: "hot" | string,
num: number
}
interface PostGetPostComments {
id: number
} }
} }

@ -12,9 +12,87 @@ declare module NetReq {
type UserGetSuggestUsers = string[] type UserGetSuggestUsers = string[]
type UserGetSuggestTags = string[] type UserGetSuggestTags = string[]
interface UserPrecheckAttachment {
paid: number
}
type UserGetAttachment = string
interface UserGetUnreadMsgCount {
count: number
}
interface UserGetMessages {
list: Item.MessageProps[],
pager: Item.PagerProps
}
interface UserGetUserPosts {
list: Item.PostProps[],
pager: Item.PagerProps
}
interface UserGetStars {
list: Item.PostProps[],
pager: Item.PagerProps
}
type UserGetUserProfile = Item.UserInfo
interface UserGetBills {
list: Item.BillProps[],
pager: Item.PagerProps
}
interface UserReqRecharge {
id: number,
pay: string
}
interface UserGetRecharge {
status: string
}
interface UserBindUserPhone {
}
interface UserGetCaptcha {
id: string,
b64s: string
}
type PostGetPost = Item.PostProps
interface PostGetPosts { interface PostGetPosts {
list: any[], list: Item.PostProps[],
pager: AnyObject pager: Item.PagerProps
}
interface PostLockPost {
lock_status: number
}
interface PostGetPostStar {
status: boolean
}
interface PostGetPostCollection {
status: boolean
}
interface PostPostStar {
status: boolean
}
interface PostPostCollection {
status: boolean
}
type PostGetTags = Item.TagProps[]
interface PostGetPostComments {
list: Item.PostProps[]
} }
} }

@ -24,11 +24,35 @@ declare module Item {
interface ReplyProps { interface ReplyProps {
id: number, id: number,
user_id: number, user_id: number,
user: UserInfo user: UserInfo,
at_user_id: number,
at_user: UserInfo,
content: string,
ip_loc: string,
created_on: number
} }
interface PostProps { interface PostProps {
id: number, id: number,
type: number,
user: UserInfo,
attachment_price: number,
ip_loc: string,
created_on: number,
latest_replied_on: number,
upvote_count: number,
comment_count: number,
collection_count: number,
content: string,
contents: PostProps[],
is_lock: number,
is_top: boolean,
texts?: PostProps[],
imgs?: PostProps[],
videos?: PostProps[],
links?: PostProps[],
attachments?: PostProps[],
charge_attachments?: PostProps[]
} }
interface MessageProps { interface MessageProps {
@ -42,4 +66,27 @@ declare module Item {
breif: string breif: string
} }
interface AttachmentProps {
id: number,
type: number
}
interface TagProps {
id: number,
quote_num: number,
tag: string,
user: UserInfo
}
interface PagerProps {
total_rows: number
}
interface BillProps {
id: number,
reason: string,
change_amount: number,
created_on: number
}
} }

@ -67,7 +67,7 @@ const loadPosts = () => {
loading.value = true; loading.value = true;
getPosts({ getPosts({
query: route.query.q ? decodeURIComponent(route.query.q as string) : null, query: route.query.q ? decodeURIComponent(route.query.q as string) : null,
type: route.query.t, type: +(route.query.t as string),
page: page.value, page: page.value,
page_size: pageSize.value, page_size: pageSize.value,
}) })

@ -31,7 +31,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -39,10 +39,10 @@ import { getMessages } from '@/api/user';
const route = useRoute(); const route = useRoute();
const store = useStore(); const store = useStore();
const loading = ref(false); const loading = ref(false);
const page = ref(+route.query.p || 1); const page = ref(+(route.query.p as string) || 1);
const pageSize = ref(10); const pageSize = ref(10);
const totalPage = ref(0); const totalPage = ref(0);
const list = ref([]); const list = ref<Item.MessageProps[]>([]);
const loadMessages = () => { const loadMessages = () => {
loading.value = true; loading.value = true;
@ -59,7 +59,7 @@ const loadMessages = () => {
loading.value = false; loading.value = false;
}); });
}; };
const updatePage = (p) => { const updatePage = (p: number) => {
page.value = p; page.value = p;
loadMessages(); loadMessages();
}; };

@ -45,24 +45,22 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, watch, onMounted, computed } from 'vue'; import { ref, watch, onMounted, computed, Ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { getPost, getPostComments } from '@/api/post'; import { getPost, getPostComments } from '@/api/post';
const route = useRoute(); const route = useRoute();
const post = ref({ const post = ref<Item.PostProps>({} as Item.PostProps);
id: 0,
});
const loading = ref(false); const loading = ref(false);
const commentLoading = ref(false); const commentLoading = ref(false);
const comments = ref([]); const comments = ref<Item.PostProps[]>([]);
const postId = computed(() => +route.query.id); const postId = computed(() => +(route.query.id as string));
const loadPost = () => { const loadPost = () => {
post.value = { post.value = {
id: 0, id: 0,
}; } as Item.PostProps;
loading.value = true; loading.value = true;
getPost({ getPost({
id: postId.value, id: postId.value,
@ -78,12 +76,12 @@ const loadPost = () => {
loading.value = false; loading.value = false;
}); });
}; };
const loadComments = (scrollToBottom) => { const loadComments = (scrollToBottom: boolean = false) => {
if (comments.value.length === 0) { if (comments.value.length === 0) {
commentLoading.value = true; commentLoading.value = true;
} }
getPostComments({ getPostComments({
id: post.value.id, id: post.value.id as number,
}) })
.then((res) => { .then((res) => {
comments.value = res.list; comments.value = res.list;

@ -50,7 +50,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -60,8 +60,8 @@ const store = useStore();
const route = useRoute(); const route = useRoute();
const loading = ref(false); const loading = ref(false);
const list = ref([]); const list = ref<Item.PostProps[]>([]);
const page = ref(+route.query.p || 1); const page = ref(+(route.query.p as string) || 1);
const pageSize = ref(20); const pageSize = ref(20);
const totalPage = ref(0); const totalPage = ref(0);
@ -83,7 +83,7 @@ const loadPosts = () => {
loading.value = false; loading.value = false;
}); });
}; };
const updatePage = (p) => { const updatePage = (p: number) => {
page.value = p; page.value = p;
loadPosts(); loadPosts();
}; };

@ -237,7 +237,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { onMounted, ref, reactive } from 'vue'; import { onMounted, ref, reactive } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { Edit } from '@vicons/tabler'; import { Edit } from '@vicons/tabler';
@ -249,6 +249,7 @@ import {
changeNickname, changeNickname,
changeAvatar, changeAvatar,
} from '@/api/user'; } from '@/api/user';
import type { UploadInst, FormItemRule, FormItemInst, FormInst, InputInst } from "naive-ui"
const uploadGateway = import.meta.env.VITE_HOST + '/attachment'; const uploadGateway = import.meta.env.VITE_HOST + '/attachment';
const uploadToken = 'Bearer ' + localStorage.getItem('PAOPAO_TOKEN'); const uploadToken = 'Bearer ' + localStorage.getItem('PAOPAO_TOKEN');
@ -257,29 +258,31 @@ const uploadType = ref('public/avatar');
const store = useStore(); const store = useStore();
const sending = ref(false); const sending = ref(false);
const binding = ref(false); const binding = ref(false);
const avatarRef = ref(null); const avatarRef = ref<UploadInst>();
const inputInstRef = ref(null); const inputInstRef = ref<InputInst>();
const showNicknameEdit = ref(false); const showNicknameEdit = ref(false);
const passwordSetting = ref(false); const passwordSetting = ref(false);
const showPasswordSetting = ref(false); const showPasswordSetting = ref(false);
const smsDisabled = ref(false); const smsDisabled = ref(false);
const smsCounter = ref(60); const smsCounter = ref(60);
const showPhoneBind = ref(false); const showPhoneBind = ref(false);
const phoneFormRef = ref(null); const phoneFormRef = ref<FormInst>();
const formRef = ref(null); const formRef = ref<FormInst>();
const rPasswordFormItemRef = ref(null); const rPasswordFormItemRef = ref<FormItemInst>();
const modelData = reactive({ const modelData = reactive({
id: '', id: '',
b64s: '', b64s: '',
imgCaptcha: '', imgCaptcha: '',
phone: null, phone: '',
phone_captcha: null, phone_captcha: '',
password: null, password: null,
old_password: null, old_password: null,
reenteredPassword: null, reenteredPassword: null,
}); });
const beforeUpload = async (data) => { const model = ref<AnyObject>({})
const beforeUpload = async (data: any) => {
// 图片类型校验 // 图片类型校验
if ( if (
uploadType.value === 'public/avatar' && uploadType.value === 'public/avatar' &&
@ -297,7 +300,7 @@ const beforeUpload = async (data) => {
return true; return true;
}; };
const finishUpload = ({ file, event }) => { const finishUpload = ({ file, event }: any): any => {
try { try {
let data = JSON.parse(event.target?.response); let data = JSON.parse(event.target?.response);
@ -325,15 +328,15 @@ const finishUpload = ({ file, event }) => {
} }
}; };
const validatePasswordStartWith = (rule, value) => { const validatePasswordStartWith = (rule: FormItemRule, value: any) => {
return ( return (
!!modelData.password && !!modelData.password &&
modelData.password.startsWith(value) && (modelData.password as any).startsWith(value) &&
modelData.password.length >= value.length (modelData.password as any).length >= value.length
); );
}; };
const validatePasswordSame = (rule, value) => { const validatePasswordSame = (rule: FormItemRule, value: any) => {
return value === modelData.password; return value === modelData.password;
}; };
@ -343,7 +346,7 @@ const handlePasswordInput = () => {
} }
}; };
const handleValidateButtonClick = (e) => { const handleValidateButtonClick = (e: MouseEvent) => {
e.preventDefault(); e.preventDefault();
formRef.value?.validate((errors) => { formRef.value?.validate((errors) => {
if (!errors) { if (!errors) {
@ -369,7 +372,7 @@ const handleValidateButtonClick = (e) => {
}); });
}; };
const handlePhoneBind = (e) => { const handlePhoneBind = (e: MouseEvent) => {
e.preventDefault(); e.preventDefault();
phoneFormRef.value?.validate((errors) => { phoneFormRef.value?.validate((errors) => {
if (!errors) { if (!errors) {
@ -388,7 +391,7 @@ const handlePhoneBind = (e) => {
phone: modelData.phone, phone: modelData.phone,
}); });
model = { model.value = {
id: '', id: '',
b64s: '', b64s: '',
imgCaptcha: '', imgCaptcha: '',
@ -470,7 +473,7 @@ const bindRules = {
required: true, required: true,
message: '', message: '',
trigger: ['input'], trigger: ['input'],
validator: (rule, value) => { validator: (rule: FormItemRule, value: any) => {
return /^[1]+[3-9]{1}\d{9}$/.test(value); return /^[1]+[3-9]{1}\d{9}$/.test(value);
}, },
}, },

@ -30,7 +30,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, onMounted, computed, watch } from 'vue'; import { ref, onMounted, computed, watch } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
@ -41,8 +41,8 @@ const route = useRoute();
const router = useRouter(); const router = useRouter();
const loading = ref(false); const loading = ref(false);
const list = ref([]); const list = ref<Item.PostProps[]>([]);
const page = ref(+route.query.p || 1); const page = ref(+(route.query.p as string) || 1);
const pageSize = ref(20); const pageSize = ref(20);
const totalPage = ref(0); const totalPage = ref(0);
@ -63,7 +63,7 @@ const loadPosts = () => {
loading.value = false; loading.value = false;
}); });
}; };
const updatePage = (p) => { const updatePage = (p: number) => {
page.value = p; page.value = p;
loadPosts(); loadPosts();
}; };

@ -39,11 +39,11 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { getTags } from '@/api/post'; import { getTags } from '@/api/post';
const tags = ref([]); const tags = ref<Item.TagProps[]>([]);
const tagType = ref('hot'); const tagType = ref('hot');
const loading = ref(false); const loading = ref(false);
@ -61,7 +61,7 @@ const loadTags = () => {
loading.value = false; loading.value = false;
}); });
}; };
const changeTab = (tab) => { const changeTab = (tab: string) => {
tagType.value = tab; tagType.value = tab;
loadTags(); loadTags();
}; };

@ -61,7 +61,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, reactive, watch, onMounted } from 'vue'; import { ref, reactive, watch, onMounted } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -78,16 +78,16 @@ const user = reactive({
nickname: '', nickname: '',
}); });
const userLoading = ref(false); const userLoading = ref(false);
const list = ref([]); const list = ref<Item.PostProps[]>([]);
const username = ref(route.query.username || ''); const username = ref(route.query.username || '');
const page = ref(+route.query.p || 1); const page = ref(+(route.query.p as string) || 1);
const pageSize = ref(20); const pageSize = ref(20);
const totalPage = ref(0); const totalPage = ref(0);
const loadPosts = () => { const loadPosts = () => {
loading.value = true; loading.value = true;
getUserPosts({ getUserPosts({
username: username.value, username: username.value as string,
page: page.value, page: page.value,
page_size: pageSize.value, page_size: pageSize.value,
}) })
@ -105,7 +105,7 @@ const loadPosts = () => {
const loadUser = () => { const loadUser = () => {
userLoading.value = true; userLoading.value = true;
getUserProfile({ getUserProfile({
username: username.value, username: username.value as string,
}) })
.then((res) => { .then((res) => {
userLoading.value = false; userLoading.value = false;
@ -121,7 +121,7 @@ const loadUser = () => {
}); });
}; };
const updatePage = (p) => { const updatePage = (p: number) => {
page.value = p; page.value = p;
loadPosts(); loadPosts();
}; };

@ -143,7 +143,7 @@
</div> </div>
</template> </template>
<script setup> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { useStore } from 'vuex'; import { useStore } from 'vuex';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
@ -162,8 +162,8 @@ const recharging = ref(false);
const rechargeQrcode = ref(''); const rechargeQrcode = ref('');
const loading = ref(false); const loading = ref(false);
const list = ref([]); const list = ref<Item.BillProps[]>([]);
const page = ref(+route.query.p || 1); const page = ref(+(route.query.p as string) || 1);
const pageSize = ref(20); const pageSize = ref(20);
const totalPage = ref(0); const totalPage = ref(0);
@ -186,7 +186,7 @@ const loadPosts = () => {
loading.value = false; loading.value = false;
}); });
}; };
const updatePage = (p) => { const updatePage = (p: number) => {
page.value = p; page.value = p;
loadPosts(); loadPosts();
}; };
@ -212,7 +212,7 @@ const loadWallet = () => {
const doRecharge = () => { const doRecharge = () => {
showRecharge.value = true; showRecharge.value = true;
}; };
const handleRecharge = (amount) => { const handleRecharge = (amount: any) => {
recharging.value = true; recharging.value = true;
reqRecharge({ reqRecharge({
amount: selectedRechargeAmount.value, amount: selectedRechargeAmount.value,

Loading…
Cancel
Save