feat: 写手端逻辑处理
This commit is contained in:
@ -6,18 +6,31 @@ export default function useGetAiReviewResult({
|
||||
}: {
|
||||
cardInfo: any;
|
||||
updateAiReview: (ai_review: any) => void;
|
||||
startAiReviewFn: (params: { id: string; platform: string; content: string }) => Promise<any>;
|
||||
getAiReviewResultFn: (id: string, ticket: string) => Promise<any>;
|
||||
startAiReviewFn: (params: {
|
||||
id: string;
|
||||
platform: string;
|
||||
content: string;
|
||||
writerCode: string | undefined;
|
||||
}) => Promise<any>;
|
||||
getAiReviewResultFn: (id: string, ticket: string, writerCode: string | undefined) => Promise<any>;
|
||||
}) {
|
||||
const route = useRoute();
|
||||
const statusPollingTimer = ref<number | null>(null);
|
||||
const ticket = ref('');
|
||||
const checkLoading = ref(false);
|
||||
const checkResult = ref<any>({});
|
||||
|
||||
const writerCode = computed(() => route.params.writerCode);
|
||||
|
||||
const handleStartCheck = async () => {
|
||||
checkLoading.value = true;
|
||||
const { id, platform, content } = cardInfo.value;
|
||||
const { code, data } = await startAiReviewFn({ id, platform, content });
|
||||
const { code, data } = await startAiReviewFn({
|
||||
id,
|
||||
platform,
|
||||
content,
|
||||
writerCode: writerCode.value as string | undefined,
|
||||
});
|
||||
if (code === 200) {
|
||||
ticket.value = data.ticket;
|
||||
startStatusPolling();
|
||||
@ -32,7 +45,11 @@ export default function useGetAiReviewResult({
|
||||
const startStatusPolling = () => {
|
||||
clearStatusPollingTimer();
|
||||
statusPollingTimer.value = setInterval(async () => {
|
||||
const { code, data } = await getAiReviewResultFn(cardInfo.value.id, ticket.value);
|
||||
const { code, data } = await getAiReviewResultFn(
|
||||
cardInfo.value.id,
|
||||
ticket.value,
|
||||
writerCode.value as string | undefined,
|
||||
);
|
||||
if (code === 200 && data.status === 1) {
|
||||
checkResult.value = data.ai_review;
|
||||
updateAiReview?.(data.ai_review);
|
||||
|
||||
Reference in New Issue
Block a user