Refactor: Refine navigation (#214)

This commit is contained in:
Germey authored and GitHub committed 2025-07-13 15:44:50 +08:00
1 parent f000fc2233
commit 9d014e21d2
24 files changed
+300 -195

No files matched your search

+14 -17
View File
@@ -1,6 +1,6 @@
<template>
<div class="selector">
<el-dropdown trigger="click" popper-class="popper">
<el-dropdown v-show="false" trigger="click" popper-class="popper">
<div class="flex justify-center mr-1">
<span class="icon">
<img :src="modelGroup.icon" />
@@ -79,34 +79,31 @@ export default defineComponent({
};
},
computed: {
modelGroup() {
console.log('modelGroup', this.$store.state.chat.modelGroup);
return this.$store.state.chat.modelGroup;
},
model() {
console.log('model', this.$store.state.chat.model);
return this.$store.state.chat.model;
},
modelGroup(): IChatModelGroup {
return (this.$route.meta?.modelGroup as IChatModelGroup) || CHAT_MODEL_GROUP_CHATGPT;
}
},
watch: {
// set first model when modelGroup changes
modelGroup(newValue: IChatModelGroup) {
console.debug('ModelSelector modelGroup changed', newValue);
console.debug('modelGroup from route changed', newValue);
this.$store.dispatch('chat/setModelGroup', newValue);
this.$store.dispatch('chat/setModel', newValue.models[0]);
}
},
mounted() {
if (!this.modelGroup) {
console.debug('ModelSelector mounted, setting default model group');
this.$store.dispatch('chat/setModelGroup', CHAT_MODEL_GROUP_CHATGPT);
} else {
// renew models if modelGroup is already set
console.debug('ModelSelector mounted, checking model group');
const modelGroups = [CHAT_MODEL_GROUP_CHATGPT, CHAT_MODEL_GROUP_DEEPSEEK, CHAT_MODEL_GROUP_GROK];
const foundGroup = modelGroups.find((group) => group.name === this.modelGroup.name);
if (foundGroup) {
this.$store.dispatch('chat/setModelGroup', foundGroup);
}
// renew models if modelGroup is already set
console.debug('ModelSelector mounted, checking model group');
const modelGroups = [CHAT_MODEL_GROUP_CHATGPT, CHAT_MODEL_GROUP_DEEPSEEK, CHAT_MODEL_GROUP_GROK];
const foundGroup = modelGroups.find((group) => group.name === this.modelGroup.name);
console.debug('Found model group:', foundGroup);
if (foundGroup) {
this.$store.dispatch('chat/setModelGroup', foundGroup);
this.$store.dispatch('chat/setModel', foundGroup.models[0]);
}
},
methods: {