From 1d045de70b3e096ca726f4cde353cc6c15aee06b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?1024=E5=B0=8F=E7=A5=9E?= <15670339118@163.com> Date: Thu, 19 Dec 2024 16:07:42 +0800 Subject: [PATCH] update edit vue --- src/lang/en_us.ts | 1 + src/lang/ja_jp.ts | 2 ++ src/lang/ko_kr.ts | 1 + src/lang/zh_cn.ts | 1 + src/lang/zh_tw.ts | 1 + src/pages/edit.vue | 42 ++++++++++++++++++++++++++---------------- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/lang/en_us.ts b/src/lang/en_us.ts index a1fd5d17..7752d9ed 100644 --- a/src/lang/en_us.ts +++ b/src/lang/en_us.ts @@ -46,6 +46,7 @@ export default { desTips: 'Please enter the project description.', save: 'Save', preview: 'Preview', + previewNotSupport: 'Preview is not supported on this platform yet', publish: 'Release', build: 'Build', pubPlatform: 'Platform', diff --git a/src/lang/ja_jp.ts b/src/lang/ja_jp.ts index deeb72c8..cdd622df 100644 --- a/src/lang/ja_jp.ts +++ b/src/lang/ja_jp.ts @@ -48,6 +48,8 @@ export default { desTips: 'プロジェクトの説明を入力してください', save: '保存', preview: 'プレビュー', + previewNotSupport: + 'プレビューはこのプラットフォームではサポートされていません まだ', publish: '公開', build: 'ビルド&公開', pubPlatform: '公開プラットフォーム', diff --git a/src/lang/ko_kr.ts b/src/lang/ko_kr.ts index 9607b77a..2e57b2de 100644 --- a/src/lang/ko_kr.ts +++ b/src/lang/ko_kr.ts @@ -47,6 +47,7 @@ export default { desTips: '프로젝트 설명을 입력하세요', save: '저장', preview: '미리보기', + previewNotSupport: '미리보기는 이 플랫폼에서 지원되지 않습니다 아직', publish: '게시', build: '빌드 및 게시', pubPlatform: '게시 플랫폼', diff --git a/src/lang/zh_cn.ts b/src/lang/zh_cn.ts index 69d02e8b..ecc2e73a 100644 --- a/src/lang/zh_cn.ts +++ b/src/lang/zh_cn.ts @@ -45,6 +45,7 @@ export default { desTips: '请输入项目描述', save: '保存', preview: '预览', + previewNotSupport: '预览暂不支持此平台', publish: '发布', build: '打包发布', pubPlatform: '发布平台', diff --git a/src/lang/zh_tw.ts b/src/lang/zh_tw.ts index 2ba5ec5d..13242df9 100644 --- a/src/lang/zh_tw.ts +++ b/src/lang/zh_tw.ts @@ -45,6 +45,7 @@ export default { desTips: '請輸入項目描述', save: '保存', preview: '預覽', + previewNotSupport: '預覽暫不支持此平台', publish: '發佈', build: '打包發佈', pubPlatform: '發佈平台', diff --git a/src/pages/edit.vue b/src/pages/edit.vue index 7cc53cf0..efddb573 100644 --- a/src/pages/edit.vue +++ b/src/pages/edit.vue @@ -347,6 +347,7 @@ import CutterImg from '@/components/CutterImg.vue' import { useI18n } from 'vue-i18n' import { CSSFILTER, isAlphanumeric, openUrl } from '@/utils/common' import { platforms } from '@/utils/config' +import { platform } from '@tauri-apps/plugin-os' import TauriConfig from '@/components/TauriConfig.vue' const router = useRouter() @@ -358,6 +359,7 @@ const centerDialogVisible = ref(false) const formSize = ref('default') const appFormRef = ref() const appForm: any = reactive(store.currentProject) +const platformName = platform() const iconFileName = ref('') const selJs = ref(null) @@ -896,22 +898,30 @@ const getInitializationScript = () => { } const preview = async (resize: boolean) => { - appFormRef.value?.validate((valid, fields) => { - if (valid) { - console.log('submit!', appForm) - saveProject(false) - // initialization_script - const initJsScript = getInitializationScript() - // console.log('initCssScript', initCssScript) - invoke('preview_from_config', { - resize, - config: tauriConfig.windows, - jsContent: initJsScript, - }) - } else { - console.log('error submit!', fields) - } - }) + // get platform + console.log('platform', platformName) + // if platform is macos, then use tauri preview + if (platformName === 'macos') { + appFormRef.value?.validate((valid, fields) => { + if (valid) { + console.log('submit!', appForm) + saveProject(false) + // initialization_script + const initJsScript = getInitializationScript() + // console.log('initCssScript', initCssScript) + invoke('preview_from_config', { + resize, + config: tauriConfig.windows, + jsContent: initJsScript, + }) + } else { + console.log('error submit!', fields) + } + }) + } else { + console.log('platform is not macos') + ElMessage.error(t('previewNotSupport')) + } } const createRepo = async () => {