mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-27 04:49:47 +01:00
Initialize user and pub configuration on app creation; update feature management to disable certain features
- Added logic to load user info and public configuration from local storage during the app's creation phase. - Modified feature manager to disable voice cloning, knowledge base, VAD, ASR, and address book features by default. - Simplified model name retrieval by directly passing parameters instead of using query strings.
This commit is contained in:
parent
c30b3e024e
commit
f4a33c80cc
5 changed files with 20 additions and 44 deletions
|
|
@ -60,6 +60,10 @@ export default {
|
|||
isCDNEnabled: process.env.VUE_APP_USE_CDN === 'true'
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.$store.commit('setUserInfo', JSON.parse(localStorage.getItem('userInfo') || '{}'));
|
||||
this.$store.commit('setPubConfig', JSON.parse(localStorage.getItem('pubConfig') || '{}'));
|
||||
},
|
||||
mounted() {
|
||||
// Check if it is a mobile device and VUE_APP_H5_URL is not empty, if both conditions are met then redirect to H5 page
|
||||
if (this.isMobileDevice() && process.env.VUE_APP_H5_URL) {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ export default {
|
|||
addModel(params, callback) {
|
||||
const { modelType, provideCode, formData } = params;
|
||||
const postData = {
|
||||
id: formData.id,
|
||||
modelCode: formData.modelCode,
|
||||
modelName: formData.modelName,
|
||||
isDefault: formData.isDefault ? 1 : 0,
|
||||
|
|
@ -92,13 +93,10 @@ export default {
|
|||
},
|
||||
// Get model name list
|
||||
getModelNames(modelType, modelName, callback) {
|
||||
const queryParams = new URLSearchParams({
|
||||
modelType,
|
||||
modelName: modelName || ''
|
||||
}).toString();
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/models/names?${queryParams}`)
|
||||
.url(`${getServiceUrl()}/models/names`)
|
||||
.method('GET')
|
||||
.data({ modelType, modelName })
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
|
|
@ -111,12 +109,10 @@ export default {
|
|||
},
|
||||
// Get LLM model name list
|
||||
getLlmModelCodeList(modelName, callback) {
|
||||
const queryParams = new URLSearchParams({
|
||||
modelName: modelName || ''
|
||||
}).toString();
|
||||
RequestService.sendRequest()
|
||||
.url(`${getServiceUrl()}/models/llm/names?${queryParams}`)
|
||||
.url(`${getServiceUrl()}/models/llm/names`)
|
||||
.method('GET')
|
||||
.data({ modelName })
|
||||
.success((res) => {
|
||||
RequestService.clearRequestTime();
|
||||
callback(res);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import store from './store';
|
|||
import i18n from './i18n';
|
||||
import './styles/global.scss';
|
||||
import { register as registerServiceWorker } from './registerServiceWorker';
|
||||
import featureManager from './utils/featureManager';
|
||||
|
||||
// Create event bus for component communication
|
||||
Vue.prototype.$eventBus = new Vue();
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ class FeatureManager {
|
|||
},
|
||||
voiceClone: {
|
||||
name: 'feature.voiceClone.name',
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
description: 'feature.voiceClone.description'
|
||||
},
|
||||
knowledgeBase: {
|
||||
name: 'feature.knowledgeBase.name',
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
description: 'feature.knowledgeBase.description'
|
||||
},
|
||||
mcpAccessPoint: {
|
||||
|
|
@ -27,17 +27,17 @@ class FeatureManager {
|
|||
},
|
||||
vad: {
|
||||
name: 'feature.vad.name',
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
description: 'feature.vad.description'
|
||||
},
|
||||
asr: {
|
||||
name: 'feature.asr.name',
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
description: 'feature.asr.description'
|
||||
},
|
||||
addressBook: {
|
||||
name: 'feature.addressBook.name',
|
||||
enabled: true,
|
||||
enabled: false,
|
||||
description: 'feature.addressBook.description'
|
||||
}
|
||||
};
|
||||
|
|
@ -57,15 +57,6 @@ class FeatureManager {
|
|||
return this.initialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload feature configuration from pub-config (e.g. after login).
|
||||
*/
|
||||
async refresh() {
|
||||
this.initPromise = this.init();
|
||||
await this.initPromise;
|
||||
return this.currentFeatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize feature configuration.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -774,11 +774,10 @@ export default {
|
|||
if (model.type != "LLM") {
|
||||
Api.model.getModelNames(model.type, "", ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
const models = Array.isArray(data.data) ? data.data : [];
|
||||
this.$set(
|
||||
this.modelOptions,
|
||||
model.type,
|
||||
models.map((item) => ({
|
||||
data.data.map((item) => ({
|
||||
value: item.id,
|
||||
label: item.modelName,
|
||||
isHidden: false,
|
||||
|
|
@ -797,8 +796,7 @@ export default {
|
|||
Api.model.getLlmModelCodeList("", ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
let LLMdata = [];
|
||||
const models = Array.isArray(data.data) ? data.data : [];
|
||||
models.forEach((item) => {
|
||||
data.data.forEach((item) => {
|
||||
LLMdata.push({
|
||||
value: item.id,
|
||||
label: item.modelName,
|
||||
|
|
@ -1304,26 +1302,11 @@ export default {
|
|||
this.form.chatHistoryConf = 0;
|
||||
}
|
||||
},
|
||||
hasModelOptionsLoaded() {
|
||||
return Object.keys(this.modelOptions).length > 0;
|
||||
},
|
||||
scheduleModelOptionsLoad() {
|
||||
const load = () => {
|
||||
this.fetchModelOptions();
|
||||
this.fetchTemplates();
|
||||
};
|
||||
load();
|
||||
this.$nextTick(() => {
|
||||
if (!this.hasModelOptionsLoaded()) {
|
||||
load();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 加载功能状态
|
||||
async loadFeatureStatus() {
|
||||
try {
|
||||
// 确保featureManager已初始化完成
|
||||
await featureManager.waitForInitialization();
|
||||
await featureManager.refresh();
|
||||
const config = featureManager.getConfig();
|
||||
this.featureStatus.voiceprintRecognition = config.voiceprintRecognition || false;
|
||||
this.featureStatus.vad = config.vad || false;
|
||||
|
|
@ -1400,7 +1383,8 @@ export default {
|
|||
this.getAgentTags(agentId);
|
||||
this.fetchAllFunctions();
|
||||
}
|
||||
this.scheduleModelOptionsLoad();
|
||||
this.fetchModelOptions();
|
||||
this.fetchTemplates();
|
||||
// 加载功能状态,确保featureManager已初始化
|
||||
await this.loadFeatureStatus();
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue