mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-28 04:59:52 +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'
|
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() {
|
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
|
// 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) {
|
if (this.isMobileDevice() && process.env.VUE_APP_H5_URL) {
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ export default {
|
||||||
addModel(params, callback) {
|
addModel(params, callback) {
|
||||||
const { modelType, provideCode, formData } = params;
|
const { modelType, provideCode, formData } = params;
|
||||||
const postData = {
|
const postData = {
|
||||||
|
id: formData.id,
|
||||||
modelCode: formData.modelCode,
|
modelCode: formData.modelCode,
|
||||||
modelName: formData.modelName,
|
modelName: formData.modelName,
|
||||||
isDefault: formData.isDefault ? 1 : 0,
|
isDefault: formData.isDefault ? 1 : 0,
|
||||||
|
|
@ -92,13 +93,10 @@ export default {
|
||||||
},
|
},
|
||||||
// Get model name list
|
// Get model name list
|
||||||
getModelNames(modelType, modelName, callback) {
|
getModelNames(modelType, modelName, callback) {
|
||||||
const queryParams = new URLSearchParams({
|
|
||||||
modelType,
|
|
||||||
modelName: modelName || ''
|
|
||||||
}).toString();
|
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/models/names?${queryParams}`)
|
.url(`${getServiceUrl()}/models/names`)
|
||||||
.method('GET')
|
.method('GET')
|
||||||
|
.data({ modelType, modelName })
|
||||||
.success((res) => {
|
.success((res) => {
|
||||||
RequestService.clearRequestTime();
|
RequestService.clearRequestTime();
|
||||||
callback(res);
|
callback(res);
|
||||||
|
|
@ -111,12 +109,10 @@ export default {
|
||||||
},
|
},
|
||||||
// Get LLM model name list
|
// Get LLM model name list
|
||||||
getLlmModelCodeList(modelName, callback) {
|
getLlmModelCodeList(modelName, callback) {
|
||||||
const queryParams = new URLSearchParams({
|
|
||||||
modelName: modelName || ''
|
|
||||||
}).toString();
|
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/models/llm/names?${queryParams}`)
|
.url(`${getServiceUrl()}/models/llm/names`)
|
||||||
.method('GET')
|
.method('GET')
|
||||||
|
.data({ modelName })
|
||||||
.success((res) => {
|
.success((res) => {
|
||||||
RequestService.clearRequestTime();
|
RequestService.clearRequestTime();
|
||||||
callback(res);
|
callback(res);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import store from './store';
|
||||||
import i18n from './i18n';
|
import i18n from './i18n';
|
||||||
import './styles/global.scss';
|
import './styles/global.scss';
|
||||||
import { register as registerServiceWorker } from './registerServiceWorker';
|
import { register as registerServiceWorker } from './registerServiceWorker';
|
||||||
|
import featureManager from './utils/featureManager';
|
||||||
|
|
||||||
// Create event bus for component communication
|
// Create event bus for component communication
|
||||||
Vue.prototype.$eventBus = new Vue();
|
Vue.prototype.$eventBus = new Vue();
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ class FeatureManager {
|
||||||
},
|
},
|
||||||
voiceClone: {
|
voiceClone: {
|
||||||
name: 'feature.voiceClone.name',
|
name: 'feature.voiceClone.name',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
description: 'feature.voiceClone.description'
|
description: 'feature.voiceClone.description'
|
||||||
},
|
},
|
||||||
knowledgeBase: {
|
knowledgeBase: {
|
||||||
name: 'feature.knowledgeBase.name',
|
name: 'feature.knowledgeBase.name',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
description: 'feature.knowledgeBase.description'
|
description: 'feature.knowledgeBase.description'
|
||||||
},
|
},
|
||||||
mcpAccessPoint: {
|
mcpAccessPoint: {
|
||||||
|
|
@ -27,17 +27,17 @@ class FeatureManager {
|
||||||
},
|
},
|
||||||
vad: {
|
vad: {
|
||||||
name: 'feature.vad.name',
|
name: 'feature.vad.name',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
description: 'feature.vad.description'
|
description: 'feature.vad.description'
|
||||||
},
|
},
|
||||||
asr: {
|
asr: {
|
||||||
name: 'feature.asr.name',
|
name: 'feature.asr.name',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
description: 'feature.asr.description'
|
description: 'feature.asr.description'
|
||||||
},
|
},
|
||||||
addressBook: {
|
addressBook: {
|
||||||
name: 'feature.addressBook.name',
|
name: 'feature.addressBook.name',
|
||||||
enabled: true,
|
enabled: false,
|
||||||
description: 'feature.addressBook.description'
|
description: 'feature.addressBook.description'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -57,15 +57,6 @@ class FeatureManager {
|
||||||
return this.initialized;
|
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.
|
* Initialize feature configuration.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -774,11 +774,10 @@ export default {
|
||||||
if (model.type != "LLM") {
|
if (model.type != "LLM") {
|
||||||
Api.model.getModelNames(model.type, "", ({ data }) => {
|
Api.model.getModelNames(model.type, "", ({ data }) => {
|
||||||
if (data.code === 0) {
|
if (data.code === 0) {
|
||||||
const models = Array.isArray(data.data) ? data.data : [];
|
|
||||||
this.$set(
|
this.$set(
|
||||||
this.modelOptions,
|
this.modelOptions,
|
||||||
model.type,
|
model.type,
|
||||||
models.map((item) => ({
|
data.data.map((item) => ({
|
||||||
value: item.id,
|
value: item.id,
|
||||||
label: item.modelName,
|
label: item.modelName,
|
||||||
isHidden: false,
|
isHidden: false,
|
||||||
|
|
@ -797,8 +796,7 @@ export default {
|
||||||
Api.model.getLlmModelCodeList("", ({ data }) => {
|
Api.model.getLlmModelCodeList("", ({ data }) => {
|
||||||
if (data.code === 0) {
|
if (data.code === 0) {
|
||||||
let LLMdata = [];
|
let LLMdata = [];
|
||||||
const models = Array.isArray(data.data) ? data.data : [];
|
data.data.forEach((item) => {
|
||||||
models.forEach((item) => {
|
|
||||||
LLMdata.push({
|
LLMdata.push({
|
||||||
value: item.id,
|
value: item.id,
|
||||||
label: item.modelName,
|
label: item.modelName,
|
||||||
|
|
@ -1304,26 +1302,11 @@ export default {
|
||||||
this.form.chatHistoryConf = 0;
|
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() {
|
async loadFeatureStatus() {
|
||||||
try {
|
try {
|
||||||
|
// 确保featureManager已初始化完成
|
||||||
await featureManager.waitForInitialization();
|
await featureManager.waitForInitialization();
|
||||||
await featureManager.refresh();
|
|
||||||
const config = featureManager.getConfig();
|
const config = featureManager.getConfig();
|
||||||
this.featureStatus.voiceprintRecognition = config.voiceprintRecognition || false;
|
this.featureStatus.voiceprintRecognition = config.voiceprintRecognition || false;
|
||||||
this.featureStatus.vad = config.vad || false;
|
this.featureStatus.vad = config.vad || false;
|
||||||
|
|
@ -1400,7 +1383,8 @@ export default {
|
||||||
this.getAgentTags(agentId);
|
this.getAgentTags(agentId);
|
||||||
this.fetchAllFunctions();
|
this.fetchAllFunctions();
|
||||||
}
|
}
|
||||||
this.scheduleModelOptionsLoad();
|
this.fetchModelOptions();
|
||||||
|
this.fetchTemplates();
|
||||||
// 加载功能状态,确保featureManager已初始化
|
// 加载功能状态,确保featureManager已初始化
|
||||||
await this.loadFeatureStatus();
|
await this.loadFeatureStatus();
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue