修复typescript类型错误

This commit is contained in:
2024-09-06 16:10:46 +08:00
parent 01a049ef9e
commit 2248b60e2d
10 changed files with 110 additions and 69 deletions

View File

@@ -1,12 +1,12 @@
<script setup>
import { request } from '@/lib/request';
<script setup lang='ts'>
import { request, type BaseResponseData } from '@/lib/request';
import { computed, onMounted, reactive, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import { timestampToString } from '@/lib/timestampToString';
const model = defineModel();
const route = useRoute()
const bloguuid = route.params.uuid;
const blogCommentList = reactive([]);
const blogCommentList: any[] = reactive([]);
const loadStatus = ref(0)// 0加载中 1已加载全部评论 -1加载失败
onMounted(async () => {
await loadComment();
@@ -25,7 +25,7 @@ const getStatusText = computed(() => {
const loadComment = async () => {
try {
let commentRes = await request.get(`/blogComment?bloguuid=${bloguuid}`);
let commentRes:BaseResponseData = await request.get(`/blogComment?bloguuid=${bloguuid}`);
if (commentRes.code == 0) {
blogCommentList.splice(0, blogCommentList.length);
blogCommentList.push(...commentRes.data);

View File

@@ -1,9 +1,9 @@
<script setup>
<script setup lang='ts'>
import { Star, Edit, StarFilled } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus';
import { ElMessage, ElMessageBox } from 'element-plus';
import { ref, onMounted, onUnmounted } from 'vue';
import { useRoute } from 'vue-router';
import { request } from '@/lib/request';
import { request, type BaseResponseData } from '@/lib/request';
import RotationVerification from '../Common/RotationVerification.vue';
const route = useRoute()
const bloguuid = route.params.uuid;
@@ -28,7 +28,7 @@ const likeBlog = async () => {
return ElMessage.success('已经点过赞啦~')
}
try {
let likeRes = await request.post('/blogLike?bloguuid=' + bloguuid)
let likeRes: BaseResponseData = await request.post('/blogLike?bloguuid=' + bloguuid)
if (likeRes.code == 0) {
isLiked.value = true;
return ElMessage.success('点赞成功~')
@@ -65,7 +65,7 @@ const submitComment = async () => {
isCaptchaViewShow.value = false;
ElMessage.info('正在提交,请稍后')
try {
let commentRes = await request.post('blogComment', {
let commentRes: BaseResponseData = await request.post('blogComment', {
session: localStorage.getItem('captcha-session'),
bloguuid: bloguuid,
content: inputComment.value.trim(),