ソースを参照

perf(views): 优化“协议结果”步骤,点击返回按钮时回到上传文件

wangcong 2 ヶ月 前
コミット
bd8fdd0f2b

+ 6 - 2
src/layout/UseGuidance.vue

@@ -59,13 +59,17 @@ const goNextStep = () => {
   current.value++;
 };
 
-const goPrevStep = () => {
+const goPrevStep = async () => {
   if (isFirstStep.value) {
     goOutOfUseGuide();
     return;
   }
 
-  current.value--;
+  const hasGoBack = await stepRef.value?.goBack?.();
+
+  if (!hasGoBack) {
+    current.value--;
+  }
 };
 
 const goOutOfUseGuide = () => {

+ 5 - 0
src/types/index.ts

@@ -111,6 +111,11 @@ export interface UseGuideStepItemProps<T> {
 
 export type UseGuideStepItemExpose = {
   exportData?: () => void | Promise<void>;
+  /**
+   * 在当前步骤点击返回时预先执行某些操作
+   * @returns 是否已经返回之前的步骤
+   */
+  goBack?: () => boolean | Promise<boolean>;
   finish?: () => void | Promise<void>;
 };
 

+ 6 - 0
src/views/setup-protocol/RecognitionResult.vue

@@ -46,6 +46,11 @@ const exportData = () => {
   });
 };
 
+const goBack = () => {
+  reRecognize();
+  return true;
+};
+
 const protocolContentRef = useTemplateRef('protocolContent');
 
 const finish = async () => {
@@ -56,6 +61,7 @@ const finish = async () => {
 
 defineExpose<UseGuideStepItemExpose>({
   exportData,
+  goBack,
   finish,
 });
 </script>