mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: Application embed (#3462)
This commit is contained in:
parent
ce17833b0a
commit
66699ef497
|
|
@ -18,6 +18,7 @@ from rest_framework import serializers
|
|||
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):
|
||||
|
|
@ -38,7 +39,7 @@ class ChatEmbedSerializer(serializers.Serializer):
|
|||
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参数
|
||||
|
|
|
|||
|
|
@ -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 + '/')
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
;((prefix) => {
|
||||
window.MaxKB = {
|
||||
prefix: '/admin',
|
||||
chatPrefix: '/chat',
|
||||
}
|
||||
})()
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@ interface Window {
|
|||
sendMessage: ?((message: string, other_params_data: any) => void)
|
||||
MaxKB: {
|
||||
prefix: string
|
||||
chatPrefix: string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ const { application } = useStore()
|
|||
|
||||
const props = defineProps({
|
||||
data: Object,
|
||||
apiInputParams: String
|
||||
apiInputParams: String,
|
||||
})
|
||||
|
||||
const emit = defineEmits(['addData'])
|
||||
|
|
@ -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) {
|
||||
|
|
@ -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>
|
||||
`
|
||||
|
|
|
|||
Loading…
Reference in New Issue