Skip to content

Commit b5b0682

Browse files
committed
update dify
1 parent 06c9527 commit b5b0682

File tree

4 files changed

+63
-25
lines changed

4 files changed

+63
-25
lines changed

docusaurus.config.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,9 @@ const config: Config = {
5656
mermaid: true,
5757
},
5858

59-
scripts: [
60-
{
61-
innerHTML: `
62-
window.difyChatbotConfig = {
63-
token: 'wairWlveaRXYYqb5',
64-
systemVariables: {
65-
// user_id: 'YOU CAN DEFINE USER ID HERE',
66-
// conversation_id: 'YOU CAN DEFINE CONVERSATION ID HERE, IT MUST BE A VALID UUID',
67-
},
68-
}
69-
`,
70-
},
71-
{
72-
src: 'https://udify.app/embed.min.js',
73-
id: 'wairWlveaRXYYqb5',
74-
defer: true,
75-
},
59+
// Add the Dify client module
60+
clientModules: [
61+
'./src/clientModules/difyIntegration.js',
7662
],
7763

7864
plugins: [
@@ -92,8 +78,6 @@ const config: Config = {
9278
{
9379
docs: {
9480
sidebarPath: "./sidebars.ts",
95-
// Please change this to your repo.
96-
// Remove this to remove the "edit this page" links.
9781
editUrl:
9882
"https://github.com/Open-LLM-VTuber/Open-LLM-VTuber-Docs/tree/main/",
9983
},
@@ -103,8 +87,6 @@ const config: Config = {
10387
type: ["rss", "atom"],
10488
xslt: true,
10589
},
106-
// Please change this to your repo.
107-
// Remove this to remove the "edit this page" links.
10890
editUrl:
10991
"https://github.com/Open-LLM-VTuber/Open-LLM-VTuber-Docs/tree/main/",
11092
// Useful options to enforce blogging best practices
@@ -120,7 +102,6 @@ const config: Config = {
120102
],
121103

122104
themeConfig: {
123-
// Replace with your project's social card
124105
image: "img/Open_LLM_VTuber_Social.png",
125106
navbar: {
126107
title: "Open LLM Vtuber",
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
2+
3+
export default (function () {
4+
if (!ExecutionEnvironment.canUseDOM) {
5+
return null; // Don't run on server-side
6+
}
7+
8+
return {
9+
onRouteUpdate({location}) {
10+
// Check if the config is already set (e.g., by a previous navigation)
11+
// Also check if the script is added, maybe the config exists but script failed last time
12+
if (!window.difyChatbotConfig && !document.getElementById('wairWlveaRXYYqb5')) {
13+
console.log('Setting Dify config and adding script via client module');
14+
15+
// Define configuration
16+
window.difyChatbotConfig = {
17+
token: 'wairWlveaRXYYqb5',
18+
systemVariables: {
19+
// user_id: 'YOU CAN DEFINE USER ID HERE',
20+
// conversation_id: 'YOU CAN DEFINE CONVERSATION ID HERE, IT MUST BE A VALID UUID',
21+
},
22+
};
23+
24+
// Get CSP nonce from Docusaurus meta tag
25+
const nonceMeta = document.querySelector('meta[name="docusaurus-csp-nonce"]');
26+
const nonceValue = nonceMeta?.content;
27+
28+
// Create and append the script tag
29+
const script = document.createElement('script');
30+
script.src = 'https://udify.app/embed.min.js';
31+
script.id = 'wairWlveaRXYYqb5';
32+
if (nonceValue) {
33+
script.setAttribute('nonce', nonceValue);
34+
console.log('Applied nonce to Dify script:', nonceValue);
35+
}
36+
document.head.appendChild(script); // Append to head
37+
} else if (window.difyChatbotConfig && !document.getElementById('wairWlveaRXYYqb5')) {
38+
// Config exists, but script is missing (maybe removed or failed to load)
39+
console.log('Dify config exists, re-adding script via client module');
40+
41+
// Get CSP nonce from Docusaurus meta tag
42+
const nonceMeta = document.querySelector('meta[name="docusaurus-csp-nonce"]');
43+
const nonceValue = nonceMeta?.content;
44+
45+
const script = document.createElement('script');
46+
script.src = 'https://udify.app/embed.min.js';
47+
script.id = 'wairWlveaRXYYqb5';
48+
if (nonceValue) {
49+
script.setAttribute('nonce', nonceValue);
50+
console.log('Applied nonce to Dify script (re-add):', nonceValue);
51+
}
52+
document.head.appendChild(script); // Append to head
53+
} else {
54+
console.log('Dify config or script already present, skipping addition.');
55+
}
56+
},
57+
};
58+
})();

src/components/HomepageFeatures/styles.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
.featureImage {
1414
width: auto;
15-
height: 200px; /* 或者您想要的其他高度 */
16-
object-fit: contain; /* 保持图片比例 */
15+
height: 200px;
16+
object-fit: contain;
1717
margin: 0 auto;
1818
}

src/css/custom.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
3030
}
3131

32-
/* Dify Chatbot Styles */
3332
#dify-chatbot-bubble-button {
3433
background-color: #1C64F2 !important;
3534
}

0 commit comments

Comments
 (0)