|
|
@@ -26,7 +26,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, onMounted } from 'vue';
|
|
|
+import { ref, onMounted, onBeforeUpdate } from 'vue';
|
|
|
import { useRoute, useRouter, onBeforeRouteUpdate } from 'vue-router';
|
|
|
import LayoutExperience from './layout/LayoutExperience.vue';
|
|
|
import ContentContainer from './layout/ContentContainer.vue';
|
|
|
@@ -174,26 +174,7 @@ function comfirmAgent(agent_id) {
|
|
|
chat_agent.value = agent_id;
|
|
|
}
|
|
|
|
|
|
-onBeforeRouteUpdate(async (to, from) => {
|
|
|
- // console.log(to, from);
|
|
|
- // // 路由发生了变化
|
|
|
- if (to.path === '/chat' || to.path === '/chat/qa') {
|
|
|
- const default_agent_id = await getDefaultAgentId();
|
|
|
-
|
|
|
- if (!to.query.agent) {
|
|
|
- chat_agent.value = default_agent_id;
|
|
|
-
|
|
|
- router.replace({
|
|
|
- path: '/chat/qa',
|
|
|
- query: {
|
|
|
- agent: default_agent_id
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
-});
|
|
|
-
|
|
|
-onMounted(async () => {
|
|
|
+async function init() {
|
|
|
const query = route.query;
|
|
|
|
|
|
const agent_id = query.agent;
|
|
|
@@ -258,5 +239,35 @@ onMounted(async () => {
|
|
|
query_value_status.value = 2;
|
|
|
query_value_message.value = 'success';
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 处理路由变化
|
|
|
+ * 监听路由参数的变化
|
|
|
+ */
|
|
|
+onBeforeRouteUpdate(async (to, from) => {
|
|
|
+ // // 路由发生了变化
|
|
|
+ if (to.path === '/chat' || to.path === '/chat/qa') {
|
|
|
+ const default_agent_id = await getDefaultAgentId();
|
|
|
+
|
|
|
+ if (!to.query.agent) {
|
|
|
+ chat_agent.value = default_agent_id;
|
|
|
+
|
|
|
+ router.replace({
|
|
|
+ path: '/chat/qa',
|
|
|
+ query: {
|
|
|
+ agent: default_agent_id
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+onMounted(async () => {
|
|
|
+ await init();
|
|
|
+});
|
|
|
+
|
|
|
+onBeforeUpdate(async () => {
|
|
|
+ await init();
|
|
|
});
|
|
|
</script>
|