修改步骤问题

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

@ -270,7 +270,8 @@ export default {
sentimentAnalysis: [], sentimentAnalysis: [],
keyEntities: [], keyEntities: [],
logs: [] logs: []
} },
errorMessage: ''
} }
}, },
@ -312,37 +313,67 @@ export default {
methods: { methods: {
...mapActions('process', [ ...mapActions('process', [
'processAnalysis' 'processAnalysis',
'setStepStatus'
]), ]),
startAnalysis() { startAnalysis() {
this.isLoading = true this.analysisStatus = 'running';
this.analysisStatus = 'running' this.isLoading = true;
this.analysisProgress = 0 this.analysisProgress = 0;
this.errorMessage = '';
// //
this.analysisTimer = setInterval(() => { this.progressTimer = setInterval(() => {
this.analysisProgress += Math.floor(Math.random() * 5) + 1 if (this.analysisProgress < 100) {
this.analysisProgress += Math.floor(Math.random() * 5) + 1;
if (this.analysisProgress >= 100) { if (this.analysisProgress > 100) {
clearInterval(this.analysisTimer) this.analysisProgress = 100;
this.analysisProgress = 100 }
this.isLoading = false } else {
this.analysisStatus = 'completed' clearInterval(this.progressTimer);
this.completeAnalysis();
// }
this.resultData = this.generateMockResult() }, 300);
// // API
this.$emit('next') // 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() { handleRetry() {
this.analysisStatus = 'pending' this.errorMessage = '';
this.analysisProgress = 0 this.startAnalysis();
this.$emit('retry') },
completeAnalysis() {
this.isLoading = false;
this.isCompleted = true;
this.$emit('next');
// 使pushcatchNavigationDuplicated
// 使
this.$router.push('/statistics').catch(err => {
if (err.name !== 'NavigationDuplicated') {
throw err;
}
});
}, },
generateMockResult() { generateMockResult() {
@ -505,7 +536,10 @@ export default {
beforeDestroy() { beforeDestroy() {
if (this.analysisTimer) { 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) 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 = [ const routes = [
{ {
path: '/', path: '/',

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

Loading…
Cancel
Save