fix(embed): fallback i18n when host app has no vue-i18n plugin

This commit is contained in:
2026-02-24 23:29:48 +08:00
parent d97ec0df4d
commit 745204f2f4
7 changed files with 47 additions and 18 deletions

View File

@@ -116,13 +116,13 @@
<script setup lang="ts">
import { reactive, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import updateLogs from "../data/updateLog.json"
import { useFilesStore } from "@/ts/useStore";
import { ElMessageBox } from "element-plus";
import { useGlobalMessage } from "@/ts/useGlobalMessage";
import { getLogicFlowInstance } from "@/ts/useLogicFlow";
import { useCanvasSettings } from '@/ts/useCanvasSettings';
import { useSafeI18n } from '@/ts/useSafeI18n';
import type { Pinia } from 'pinia';
const props = withDefaults(defineProps<{
@@ -136,8 +136,15 @@ const filesStore = props.piniaInstance ? useFilesStore(props.piniaInstance) : us
const { showMessage } = useGlobalMessage();
const { selectionEnabled, snapGridEnabled, snaplineEnabled } = useCanvasSettings();
// 获取当前的 i18n 实例
const {t} = useI18n();
const { t } = useSafeI18n({
import: '导入',
export: '导出',
prepareCapture: '准备截图',
setWatermark: '设置水印',
loadExample: '加载样例',
updateLog: '更新日志',
feedback: '问题反馈'
});
// 定义响应式数据
const state = reactive({

View File

@@ -116,7 +116,7 @@ import draggable from 'vuedraggable';
import ShikigamiSelect from './flow/nodes/yys/ShikigamiSelect.vue';
import ShikigamiProperty from './flow/nodes/yys/ShikigamiProperty.vue';
import html2canvas from 'html2canvas';
import {useI18n} from 'vue-i18n'
import { useSafeI18n } from '@/ts/useSafeI18n';
import { Quill, QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.bubble.css'
import '@vueup/vue-quill/dist/vue-quill.snow.css' // 引入样式文件
@@ -146,7 +146,7 @@ const clipboard = ref('');
const { showMessage } = useGlobalMessage();
// 获取当前的 i18n 实例
const {t} = useI18n()
const { t } = useSafeI18n()
const copy = (str) => {
clipboard.value = str
@@ -645,4 +645,4 @@ defineExpose({
}
}
}
</style>
</style>

View File

@@ -84,11 +84,11 @@ import shikigami from "../data/Shikigami.json"
import ShikigamiSelect from "@/components/flow/nodes/yys/ShikigamiSelect.vue";
import ShikigamiProperty from "@/components/flow/nodes/yys/ShikigamiProperty.vue";
import _ from "lodash";
import {useI18n} from "vue-i18n";
import { useSafeI18n } from '@/ts/useSafeI18n';
import draggable from 'vuedraggable';
const {t} = useI18n()
const { t } = useSafeI18n()
const props = defineProps<{
groups: any[];
@@ -264,4 +264,4 @@ const getYuhunPropertyNames = (yuhun) => {
display: block;
cursor: pointer;
}
</style>
</style>

View File

@@ -238,12 +238,12 @@
<script setup>
import { ref, watch, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { CirclePlus } from '@element-plus/icons-vue';
import { useSafeI18n } from '@/ts/useSafeI18n';
// import YuhunSelect from "@/components/flow/nodes/yys/YuhunSelect.vue";
// 获取当前的 i18n 实例
const { t } = useI18n();
const { t } = useSafeI18n();
const props = defineProps({
currentProperty: {
@@ -338,4 +338,4 @@ const confirm = () => {
border-radius: 4px;
border: 1px solid #dcdfe6;
}
</style>
</style>

View File

@@ -112,7 +112,7 @@ import {ref, reactive, toRefs, nextTick} from 'vue';
import ShikigamiSelect from './ShikigamiSelect.vue';
import ShikigamiProperty from './ShikigamiProperty.vue';
import html2canvas from 'html2canvas';
import {useI18n} from 'vue-i18n'
import { useSafeI18n } from '@/ts/useSafeI18n';
import { Quill, QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.bubble.css'
import '@vueup/vue-quill/dist/vue-quill.snow.css' // 引入样式文件
@@ -147,7 +147,7 @@ const dialogTableVisible = ref(false)
const {showMessage} = useGlobalMessage();
// 获取当前的 i18n 实例
const {t} = useI18n()
const { t } = useSafeI18n()
// 定义 QuillEditor 的 ref
const shortDescriptionEditor = ref<InstanceType<typeof QuillEditor>>()
@@ -624,4 +624,4 @@ defineExpose({
}
}
}
</style>
</style>

View File

@@ -127,12 +127,12 @@ import propertyData from "../../../../data/property.json";
import {ref, watch, computed} from 'vue'
import ShikigamiSelect from "@/components/flow/nodes/yys/ShikigamiSelect.vue";
import YuhunSelect from "@/components/flow/nodes/yys/YuhunSelect.vue";
import {useI18n} from 'vue-i18n'
import { useSafeI18n } from '@/ts/useSafeI18n';
// import YuhunSelect from "./YuhunSelect.vue";
// 获取当前的 i18n 实例
const {t} = useI18n()
const { t } = useSafeI18n()
const props = defineProps({
currentShikigami: {
@@ -373,4 +373,4 @@ const resetData = () => {
const updateSkillRequired = (index, value) => {
shikigami.value.skillRequired[index] = value;
}
</script>
</script>