fix(Text Tranlator): enhance UI and fix for arm64

Fix #175
This commit is contained in:
ShareVB committed 2025-08-23 14:17:01 +02:00
1 parent e942fe4f04
commit dd87f353aa
3 files changed
+16 -12

No files matched your search

+4
View File
@@ -47,3 +47,7 @@ interface JSON {
parseBigInt: (jsonStr: string, options?: { minDigits?: number; fallbackToString?: boolean; }) => any; parseBigInt: (jsonStr: string, options?: { minDigits?: number; fallbackToString?: boolean; }) => any;
rawJSON(value: string): any; rawJSON(value: string): any;
} }
interface Navigator {
gpu?: any;
}
+11 -11
View File
@@ -1,13 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
import type { TranslationPipeline, TranslationSingle } from '@huggingface/transformers'; import type { TranslationPipeline, TranslationSingle } from '@huggingface/transformers';
import { pipeline } from '@huggingface/transformers'; import { env, pipeline } from '@huggingface/transformers';
import { useQueryParamOrStorage } from '@/composable/queryParams';
env.useBrowserCache = true;
env.allowRemoteModels = true;
// State // State
const inputText = ref(''); const inputText = ref('');
const translatedText = ref(''); const translatedText = ref('');
const error = ref(''); const error = ref('');
const sourceLang = ref('en'); const sourceLang = useQueryParamOrStorage({ name: 'from', storageName: 'translator:from', defaultValue: 'en' });
const targetLang = ref('fr'); const targetLang = useQueryParamOrStorage({ name: 'to', storageName: 'translator:to', defaultValue: 'fr' });
const loadingModel = ref(false); const loadingModel = ref(false);
const translating = ref(false); const translating = ref(false);
@@ -130,14 +134,10 @@ async function translateText() {
</NButton> </NButton>
</n-space> </n-space>
<div mb-3 mt-3> <n-space justify="center" mb-3 mt-3>
<NSpin v-if="loadingModel" size="large"> <NSpin v-if="loadingModel" size="large" description="Loading translation model..." />
Loading translation model... <NSpin v-if="translating" size="large" description="Translating..." />
</NSpin> </n-space>
<NSpin v-if="translating" size="large">
Translating...
</NSpin>
</div>
<c-alert v-if="error" mb-2> <c-alert v-if="error" mb-2>
{{ error }} {{ error }}
+1 -1
View File
@@ -161,7 +161,7 @@ export default defineConfig({
}, },
}, },
optimizeDeps: { optimizeDeps: {
include: ['isolated-vm', 'pdfjs-dist', 'onnxruntime-node', 'unpdf', 'unpdf/pdfjs', ...(process.env.VERCEL ? ['webcrypto-liner-shim'] : [])], // optionally specify dependency name include: ['isolated-vm', 'pdfjs-dist', 'onnxruntime-node', 'onnxruntime-web', 'unpdf', 'unpdf/pdfjs', ...(process.env.VERCEL ? ['webcrypto-liner-shim'] : [])], // optionally specify dependency name
esbuildOptions: { esbuildOptions: {
supported: { supported: {
'top-level-await': true, 'top-level-await': true,