Skip to content

Commit f2dae7b

Browse files
committed
feat: 增加应用profile 设置参数
1 parent 204676f commit f2dae7b

File tree

4 files changed

+25
-36
lines changed

4 files changed

+25
-36
lines changed

apps/application/serializers/application_serializers.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,19 @@ def profile(self, with_valid=True):
716716
application_access_token = QuerySet(ApplicationAccessToken).filter(application_id=application.id).first()
717717
if application_access_token is None:
718718
raise AppUnauthorizedFailed(500, "非法用户")
719+
application_setting_model = DBModelManage.get_model('application_setting')
720+
X_PACK_LICENSE_IS_VALID = (settings.XPACK_LICENSE_IS_VALID if hasattr(settings,
721+
'XPACK_LICENSE_IS_VALID') else False)
722+
application_setting_dict = {}
723+
if application_setting_model is not None and X_PACK_LICENSE_IS_VALID:
724+
application_setting = QuerySet(application_setting_model).filter(
725+
application_id=application_access_token.application_id).first()
726+
application_setting_dict = {'show_source': application_access_token.show_source,
727+
'show_history': application_setting.show_history,
728+
'draggable': application_setting.draggable,
729+
'show_guide': application_setting.show_guide,
730+
'avatar': application_setting.avatar,
731+
'float_icon': application_setting.float_icon}
719732
return ApplicationSerializer.Query.reset_application(
720733
{**ApplicationSerializer.ApplicationModel(application).data,
721734
'stt_model_id': application.stt_model_id,
@@ -724,7 +737,8 @@ def profile(self, with_valid=True):
724737
'tts_model_enable': application.tts_model_enable,
725738
'tts_type': application.tts_type,
726739
'work_flow': application.work_flow,
727-
'show_source': application_access_token.show_source})
740+
'show_source': application_access_token.show_source,
741+
**application_setting_dict})
728742

729743
@transaction.atomic
730744
def edit(self, instance: Dict, with_valid=True):

apps/application/serializers/chat_serializers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@
1515
from typing import Dict
1616

1717
import openpyxl
18-
import xlwt
1918
from django.core import validators
2019
from django.core.cache import caches
2120
from django.db import transaction, models
2221
from django.db.models import QuerySet, Q
23-
from django.http import HttpResponse, StreamingHttpResponse, HttpResponseServerError
24-
from openpyxl.workbook import Workbook
22+
from django.http import StreamingHttpResponse
2523
from rest_framework import serializers
2624

2725
from application.flow.workflow_manage import Flow

ui/src/api/application-xpack.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,7 @@ const putAccessToken: (
3535
return put(`${prefix}/${application_id}/setting`, data, undefined, loading)
3636
}
3737

38-
/**
39-
* 对话获取应用相关信息
40-
* @param 参数
41-
{
42-
"access_token": "string"
43-
}
44-
*/
45-
const getAppXpackProfile: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
46-
return get(`${prefix}/xpack/profile`, undefined, loading)
47-
}
48-
4938
export default {
5039
getAccessToken,
51-
putAccessToken,
52-
getAppXpackProfile
40+
putAccessToken
5341
}

ui/src/stores/modules/application.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,14 @@ const useApplicationStore = defineStore({
7979
async asyncGetAppProfile(loading?: Ref<boolean>) {
8080
return new Promise((resolve, reject) => {
8181
const user = useUserStore()
82-
if (user.isEnterprise()) {
83-
applicationXpackApi
84-
.getAppXpackProfile(loading)
85-
.then((data) => {
86-
resolve(data)
87-
})
88-
.catch((error) => {
89-
reject(error)
90-
})
91-
} else {
92-
applicationApi
93-
.getAppProfile(loading)
94-
.then((data) => {
95-
resolve(data)
96-
})
97-
.catch((error) => {
98-
reject(error)
99-
})
100-
}
82+
applicationApi
83+
.getAppProfile(loading)
84+
.then((data) => {
85+
resolve(data)
86+
})
87+
.catch((error) => {
88+
reject(error)
89+
})
10190
})
10291
},
10392

0 commit comments

Comments
 (0)