diff --git a/packages/docs/fluent-editor/.vitepress/components/TranslateComponent.vue b/packages/docs/fluent-editor/.vitepress/components/TranslateComponent.vue
new file mode 100644
index 0000000..2666fb3
--- /dev/null
+++ b/packages/docs/fluent-editor/.vitepress/components/TranslateComponent.vue
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages/docs/fluent-editor/.vitepress/config.ts b/packages/docs/fluent-editor/.vitepress/config.ts
index 8847452..0aee9f6 100644
--- a/packages/docs/fluent-editor/.vitepress/config.ts
+++ b/packages/docs/fluent-editor/.vitepress/config.ts
@@ -18,6 +18,7 @@ export default defineConfig({
['script', { src: 'https://cdn.jsdelivr.net/npm/lottie-web/build/player/lottie.js' }],
['script', { src: 'https://cdn.jsdelivr.net/npm/@petercatai/assistant@1.0.7/dist/umd/assistant.min.js' }],
['link', { rel: 'stylesheet', href: 'https://cdn.jsdelivr.net/npm/@petercatai/assistant@1.0.7/dist/umd/assistant.min.css' }],
+ ['script', { src: 'https://cdn.staticfile.net/translate.js/3.12.0/translate.js' }],
],
themeConfig: {
logo: '/logo.svg',
@@ -29,6 +30,9 @@ export default defineConfig({
{ text: 'TinyVue', link: 'https://opentiny.design/tiny-vue/' },
],
},
+ {
+ component: 'TranslateComponent'
+ },
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/opentiny/fluent-editor/' },
diff --git a/packages/docs/fluent-editor/.vitepress/theme/index.ts b/packages/docs/fluent-editor/.vitepress/theme/index.ts
index c63d605..99cd4d4 100644
--- a/packages/docs/fluent-editor/.vitepress/theme/index.ts
+++ b/packages/docs/fluent-editor/.vitepress/theme/index.ts
@@ -5,6 +5,8 @@ import * as Toast from 'vue-toastification'
import { insertBaiduScript } from './insert-baidu-script'
import { inertDepsVersion } from './insert-deps-version'
import { insertPeterCatAssistant } from './insert-petercat-assistant'
+import { insertTranslate } from './insert-translate'
+import TranslateComponent from '../components/TranslateComponent.vue'
import '@vitepress-code-preview/container/dist/style.css'
import './style.css'
import 'vue-toastification/dist/index.css'
@@ -13,6 +15,7 @@ export const define = (value: T): T => value
export default define({
...DefaultTheme,
enhanceApp({ app }) {
+ app.component('TranslateComponent', TranslateComponent)
app.use(Toast.default, {
position: 'top-center',
timeout: 3000,
@@ -24,5 +27,8 @@ export default define({
setTimeout(() => {
insertPeterCatAssistant()
}, 300)
+ setTimeout(() => {
+ insertTranslate()
+ }, 3000)
},
})
diff --git a/packages/docs/fluent-editor/.vitepress/theme/insert-translate.ts b/packages/docs/fluent-editor/.vitepress/theme/insert-translate.ts
new file mode 100644
index 0000000..6bf34e2
--- /dev/null
+++ b/packages/docs/fluent-editor/.vitepress/theme/insert-translate.ts
@@ -0,0 +1,22 @@
+export function insertTranslate() {
+ if (typeof document === 'undefined') return
+ const translateScript = document.createElement('script')
+ const translateScriptStr = `
+ translate.language.setLocal('chinese_simplified');
+ translate.service.use('client.edge');
+ translate.listener.start();
+ translate.setAutoDiscriminateLocalLanguage();
+ translate.selectLanguageTag.languages = 'english,chinese_simplified';
+ translate.selectLanguageTag.show = false;
+ translate.language.setDefaultTo('chinese_simplified');
+
+ translate.ignore.class.push('ql-container');
+ translate.ignore.class.push('ql-editor');
+ translate.ignore.class.push('petercat-lui-assistant');
+ translate.ignore.class.push('translate-switch');
+
+ translate.execute();
+ `
+ translateScript.textContent = translateScriptStr
+ document.body.append(translateScript)
+}
diff --git a/packages/docs/fluent-editor/.vitepress/theme/style.css b/packages/docs/fluent-editor/.vitepress/theme/style.css
index c139287..ecdb21e 100644
--- a/packages/docs/fluent-editor/.vitepress/theme/style.css
+++ b/packages/docs/fluent-editor/.vitepress/theme/style.css
@@ -98,3 +98,8 @@
padding-top: 0;
line-height: 22px;
}
+
+/* 翻译工具 */
+#translate {
+ display: none;
+}