Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
fix: add clipboard API fallback for non-secure contexts
Andy Yang29c790b46c4c
diff --git a/frontend/src/views/chat/components/tool-results/ChunkDetail.vue b/frontend/src/views/chat/components/tool-results/ChunkDetail.vueindex 5a907d3ce..9a62e7709 100644--- a/frontend/src/views/chat/components/tool-results/ChunkDetail.vue+++ b/frontend/src/views/chat/components/tool-results/ChunkDetail.vue@@ -46,10 +46,26 @@ const props = defineProps<{const { t } = useI18n();const copyToClipboard = () => {- if (navigator.clipboard) {- navigator.clipboard.writeText(props.data.content);+ const text = props.data.content;+ if (navigator.clipboard && navigator.clipboard.writeText) {+ navigator.clipboard.writeText(text).catch(() => {+ fallbackCopy(text);+ });+ } else {+ fallbackCopy(text);}};++function fallbackCopy(text: string) {+ const textArea = document.createElement('textarea');+ textArea.value = text;+ textArea.style.position = 'fixed';+ textArea.style.opacity = '0';+ document.body.appendChild(textArea);+ textArea.select();+ document.execCommand('copy');+ document.body.removeChild(textArea);+}</script><style lang="less" scoped>diff --git a/frontend/src/views/organization/OrganizationList.vue b/frontend/src/views/organization/OrganizationList.vueindex a713b181e..5025f4bde 100644--- a/frontend/src/views/organization/OrganizationList.vue+++ b/frontend/src/views/organization/OrganizationList.vue@@ -1128,11 +1128,33 @@ function viewOrganizationFromPreview() {// 复制预览中的空间 IDfunction copyPreviewSpaceId() {if (!invitePreviewData.value?.id) return- navigator.clipboard.writeText(invitePreviewData.value.id).then(() => {- MessagePlugin.success(t('common.copied'))- }).catch(() => {+ const text = invitePreviewData.value.id+ try {+ if (navigator.clipboard && navigator.clipboard.writeText) {+ navigator.clipboard.writeText(text).then(() => {+ MessagePlugin.success(t('common.copied'))+ }).catch(() => {+ fallbackCopyText(text)+ MessagePlugin.success(t('common.copied'))+ })+ } else {+ fallbackCopyText(text)+ MessagePlugin.success(t('common.copied'))+ }+ } catch {MessagePlugin.error('复制失败')- })+ }+}++function fallbackCopyText(text: string) {+ const textArea = document.createElement('textarea')+ textArea.value = text+ textArea.style.position = 'fixed'+ textArea.style.opacity = '0'+ document.body.appendChild(textArea)+ textArea.select()+ document.execCommand('copy')+ document.body.removeChild(textArea)}// 从搜索列表加入空间(通过空间 ID,无需邀请码)- 在预览确认后调用diff --git a/frontend/src/views/organization/OrganizationSettingsModal.vue b/frontend/src/views/organization/OrganizationSettingsModal.vueindex 60a913dd9..17aea14cc 100644--- a/frontend/src/views/organization/OrganizationSettingsModal.vue+++ b/frontend/src/views/organization/OrganizationSettingsModal.vue@@ -1292,17 +1292,46 @@ const resetAddMemberDialog = () => {userSearchResults.value = []}-const copyInviteCode = () => {+const fallbackCopyText = (text: string) => {+ const textArea = document.createElement('textarea')+ textArea.value = text+ textArea.style.position = 'fixed'+ textArea.style.opacity = '0'+ document.body.appendChild(textArea)+ textArea.select()+ document.execCommand('copy')+ document.body.removeChild(textArea)+}++const copyInviteCode = async () => {if (inviteCode.value) {- navigator.clipboard.writeText(inviteCode.value)- MessagePlugin.success(t('common.copied'))+ try {+ if (navigator.clipboard && navigator.clipboard.writeText) {+ await navigator.clipboard.writeText(inviteCode.value)+ } else {+ fallbackCopyText(inviteCode.value)+ }+ MessagePlugin.success(t('common.copied'))+ } catch {+ fallbackCopyText(inviteCode.value)+ MessagePlugin.success(t('common.copied'))+ }}}-const copyInviteLink = () => {+const copyInviteLink = async () => {if (inviteLink.value) {- navigator.clipboard.writeText(inviteLink.value)- MessagePlugin.success(t('common.copied'))+ try {+ if (navigator.clipboard && navigator.clipboard.writeText) {+ await navigator.clipboard.writeText(inviteLink.value)+ } else {+ fallbackCopyText(inviteLink.value)+ }+ MessagePlugin.success(t('common.copied'))+ } catch {+ fallbackCopyText(inviteLink.value)+ MessagePlugin.success(t('common.copied'))+ }}}diff --git a/frontend/src/views/settings/ApiInfo.vue b/frontend/src/views/settings/ApiInfo.vueindex 421d36046..5f9295d45 100644--- a/frontend/src/views/settings/ApiInfo.vue+++ b/frontend/src/views/settings/ApiInfo.vue@@ -173,6 +173,17 @@ const openApiDoc = () => {window.open('https://github.com/Tencent/WeKnora/blob/main/docs/api/README.md', '_blank')}+const fallbackCopyText = (text: string) => {+ const textArea = document.createElement('textarea')+ textArea.value = text+ textArea.style.position = 'fixed'+ textArea.style.opacity = '0'+ document.body.appendChild(textArea)+ textArea.select()+ document.execCommand('copy')+ document.body.removeChild(textArea)+}+const copyApiKey = async () => {if (!tenantInfo.value?.api_key) {MessagePlugin.warning(t('tenant.api.noKey'))@@ -180,10 +191,15 @@ const copyApiKey = async () => {}try {- await navigator.clipboard.writeText(tenantInfo.value.api_key)+ if (navigator.clipboard && navigator.clipboard.writeText) {+ await navigator.clipboard.writeText(tenantInfo.value.api_key)+ } else {+ fallbackCopyText(tenantInfo.value.api_key)+ }MessagePlugin.success(t('tenant.api.copySuccess'))} catch (err) {- MessagePlugin.error(t('tenant.api.copyFailed'))+ fallbackCopyText(tenantInfo.value.api_key)+ MessagePlugin.success(t('tenant.api.copySuccess'))}}