Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/chat/serializers/chat_embed_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from application.models import ApplicationAccessToken
from common.database_model_manage.database_model_manage import DatabaseModelManage
from maxkb.conf import PROJECT_DIR
from maxkb.const import CONFIG


class ChatEmbedSerializer(serializers.Serializer):
Expand All @@ -38,7 +39,7 @@ def get_embed(self, with_valid=True, params=None):
access_token=self.data.get('token')).first()
is_draggable = 'false'
show_guide = 'true'
float_icon = f"{self.data.get('protocol')}://{self.data.get('host')}/ui/MaxKB.gif"
float_icon = f"{self.data.get('protocol')}://{self.data.get('host')}{CONFIG.get_chat_path()}/MaxKB.gif"
is_license_valid = DatabaseModelManage.get_model('license_is_valid')
X_PACK_LICENSE_IS_VALID = is_license_valid if is_license_valid is not None else False
# 获取接入的query参数
Expand Down
3 changes: 2 additions & 1 deletion apps/maxkb/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ def page_not_found(request, exception):
if not os.path.exists(index_path):
return HttpResponse("页面不存在", status=404)
content = get_index_html(index_path)
content = content.replace("prefix: '/admin'", f"prefix: '{CONFIG.get_admin_path()}'")
content = content.replace("prefix: '/admin'", f"prefix: '{CONFIG.get_admin_path()}'").replace(
"chatPrefix: '/chat'", f"prefix: '{CONFIG.get_chat_path()}'")
return HttpResponse(content, status=200)
else:
return HttpResponseRedirect(admin_ui_prefix + '/')
Expand Down
1 change: 1 addition & 0 deletions ui/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
;((prefix) => {
window.MaxKB = {
prefix: '/admin',
chatPrefix: '/chat',
}
})()
</script>
Expand Down
1 change: 1 addition & 0 deletions ui/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ interface Window {
sendMessage: ?((message: string, other_params_data: any) => void)
MaxKB: {
prefix: string
chatPrefix: string
}
}
2 changes: 1 addition & 1 deletion ui/src/stores/modules/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getBrowserLang } from '@/locales/index'
import useUserStore from './user'
const useApplicationStore = defineStore('application', {
state: () => ({
location: `${window.location.origin}/${window.MaxKB.prefix}/chat/`,
location: `${window.location.origin}${window.MaxKB.chatPrefix}/`,
}),
actions: {
async asyncGetAllApplication() {
Expand Down
10 changes: 8 additions & 2 deletions ui/src/stores/modules/chat-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ const useChatUserStore = defineStore('chat-user', {
applicationProfile() {
return ChatAPI.applicationProfile().then((ok) => {
this.application = ok.data
this.application['custom_theme']['theme_color'] =
ok.data?.custom_theme.theme_color || '#3370FF'
if (this.application.custom_theme) {
this.application['custom_theme']['theme_color'] =
ok.data?.custom_theme?.theme_color || '#3370FF'
} else {
this.application.custom_theme = {
theme_color: ok.data?.custom_theme?.theme_color || '#3370FF',
}
}
})
},
isAuthentication() {
Expand Down
8 changes: 4 additions & 4 deletions ui/src/views/application-overview/component/EmbedDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const { application } = useStore()

const props = defineProps({
data: Object,
apiInputParams: String
apiInputParams: String,
})

const emit = defineEmits(['addData'])
Expand All @@ -104,7 +104,7 @@ const source3 = ref('')
const urlParams1 = computed(() => (props.apiInputParams ? '?' + props.apiInputParams : ''))
const urlParams2 = computed(() => (props.apiInputParams ? '&' + props.apiInputParams : ''))
const urlParams3 = computed(() =>
props.apiInputParams ? '?mode=mobile&' + props.apiInputParams : '?mode=mobile'
props.apiInputParams ? '?mode=mobile&' + props.apiInputParams : '?mode=mobile',
)
watch(dialogVisible, (bool) => {
if (!bool) {
Expand All @@ -126,9 +126,9 @@ allow="microphone">
source2.value = `<script
async
defer
src="${window.location.origin}/api/application/embed?protocol=${window.location.protocol.replace(
src="${application.location}api/embed?protocol=${window.location.protocol.replace(
':',
''
'',
)}&host=${window.location.host}&token=${val}${urlParams2.value}">
<\/script>
`
Expand Down
Loading