修改步骤问题

main
LiRen-qiu 4 months ago
parent 07159c6dfe
commit 3d3b4f0bfc

@ -270,7 +270,8 @@ export default {
sentimentAnalysis: [],
keyEntities: [],
logs: []
}
},
errorMessage: ''
}
},
@ -312,37 +313,67 @@ export default {
methods: {
...mapActions('process', [
'processAnalysis'
'processAnalysis',
'setStepStatus'
]),
startAnalysis() {
this.isLoading = true
this.analysisStatus = 'running'
this.analysisProgress = 0
this.analysisStatus = 'running';
this.isLoading = true;
this.analysisProgress = 0;
this.errorMessage = '';
//
this.analysisTimer = setInterval(() => {
this.analysisProgress += Math.floor(Math.random() * 5) + 1
if (this.analysisProgress >= 100) {
clearInterval(this.analysisTimer)
this.analysisProgress = 100
this.isLoading = false
this.analysisStatus = 'completed'
//
this.resultData = this.generateMockResult()
//
this.$emit('next')
//
this.progressTimer = setInterval(() => {
if (this.analysisProgress < 100) {
this.analysisProgress += Math.floor(Math.random() * 5) + 1;
if (this.analysisProgress > 100) {
this.analysisProgress = 100;
}
} else {
clearInterval(this.progressTimer);
this.completeAnalysis();
}
}, 300);
// API
// API
setTimeout(() => {
try {
this.loadAnalysisResultData();
this.analysisStatus = 'completed';
this.setStepStatus({ step: 'analysis', status: 'completed' });
} catch (error) {
console.error('分析过程出错:', error);
this.analysisStatus = 'error';
this.errorMessage = '分析过程中发生错误:' + (error.message || '未知错误');
clearInterval(this.progressTimer);
}
}, 300)
}, 8000);
},
loadAnalysisResultData() {
console.log('加载分析结果数据');
this.resultData = this.generateMockResult();
},
handleRetry() {
this.analysisStatus = 'pending'
this.analysisProgress = 0
this.$emit('retry')
this.errorMessage = '';
this.startAnalysis();
},
completeAnalysis() {
this.isLoading = false;
this.isCompleted = true;
this.$emit('next');
// 使pushcatchNavigationDuplicated
// 使
this.$router.push('/statistics').catch(err => {
if (err.name !== 'NavigationDuplicated') {
throw err;
}
});
},
generateMockResult() {
@ -505,7 +536,10 @@ export default {
beforeDestroy() {
if (this.analysisTimer) {
clearInterval(this.analysisTimer)
clearInterval(this.analysisTimer);
}
if (this.progressTimer) {
clearInterval(this.progressTimer);
}
}
}

@ -5,6 +5,14 @@ import StatisticsPage from '../views/Statistics.vue'
Vue.use(VueRouter)
// 解决NavigationDuplicated错误
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => {
if (err.name !== 'NavigationDuplicated') throw err
})
}
const routes = [
{
path: '/',

@ -176,7 +176,11 @@ export default {
completeProcess() {
//
this.$router.push('/analysis')
this.$router.push('/statistics').catch(err => {
if (err.name !== 'NavigationDuplicated') {
throw err
}
})
}
}
}

Loading…
Cancel
Save