Răsfoiți Sursa

chore: update ace-builds integration and fix initialization errors

Jacky 3 săptămâni în urmă
părinte
comite
c5ea44ca1e

+ 2 - 2
app/package.json

@@ -9,7 +9,7 @@
     "lint": "eslint .",
     "lint:fix": "eslint --fix .",
     "build": "vite build",
-    "preview": "vite preview",
+    "preview": "vite preview --host",
     "gettext:extract": "vue-gettext-extract"
   },
   "dependencies": {
@@ -25,6 +25,7 @@
     "@xterm/addon-attach": "^0.11.0",
     "@xterm/addon-fit": "^0.10.0",
     "@xterm/xterm": "^5.5.0",
+    "ace-builds": "^1.39.1",
     "ant-design-vue": "^4.2.6",
     "apexcharts": "^4.5.0",
     "axios": "^1.8.4",
@@ -67,7 +68,6 @@
     "@vitejs/plugin-vue-jsx": "^4.1.2",
     "@vue/compiler-sfc": "^3.5.13",
     "@vue/tsconfig": "^0.7.0",
-    "ace-builds": "^1.39.1",
     "autoprefixer": "^10.4.21",
     "eslint": "9.24.0",
     "eslint-plugin-sonarjs": "^3.0.2",

+ 3 - 3
app/pnpm-lock.yaml

@@ -44,6 +44,9 @@ importers:
       '@xterm/xterm':
         specifier: ^5.5.0
         version: 5.5.0
+      ace-builds:
+        specifier: ^1.39.1
+        version: 1.39.1
       ant-design-vue:
         specifier: ^4.2.6
         version: 4.2.6(vue@3.5.13(typescript@5.8.3))
@@ -165,9 +168,6 @@ importers:
       '@vue/tsconfig':
         specifier: ^0.7.0
         version: 0.7.0(typescript@5.8.3)(vue@3.5.13(typescript@5.8.3))
-      ace-builds:
-        specifier: ^1.39.1
-        version: 1.39.1
       autoprefixer:
         specifier: ^10.4.21
         version: 10.4.21(postcss@8.5.3)

+ 8 - 1
app/src/components/CodeEditor/CodeEditor.vue

@@ -23,7 +23,14 @@ const value = computed({
   },
 })
 
-ace.config.setModuleUrl('ace/ext/searchbox', extSearchboxUrl)
+onMounted(() => {
+  try {
+    ace.config.setModuleUrl('ace/ext/searchbox', extSearchboxUrl)
+  }
+  catch (error) {
+    console.error('Failed to initialize Ace editor:', error)
+  }
+})
 </script>
 
 <template>

+ 13 - 3
app/src/components/ConfigHistory/DiffViewer.vue

@@ -3,11 +3,11 @@ import type { ConfigBackup } from '@/api/config'
 import type { Ace } from 'ace-builds'
 import { formatDateTime } from '@/lib/helper'
 import ace from 'ace-builds'
+// Import required modules
+import extLanguageToolsUrl from 'ace-builds/src-min-noconflict/ext-language_tools?url'
 import 'ace-builds/src-noconflict/mode-nginx'
-import 'ace-builds/src-noconflict/theme-monokai'
 
-// Import required modules
-import 'ace-builds/src-min-noconflict/ext-language_tools'
+import 'ace-builds/src-noconflict/theme-monokai'
 
 const props = defineProps<{
   records: ConfigBackup[]
@@ -33,6 +33,16 @@ const originalTitle = ref('')
 const modifiedTitle = ref('')
 const errorMessage = ref('')
 
+// Initialize ace language tools
+onMounted(() => {
+  try {
+    ace.config.setModuleUrl('ace/ext/language_tools', extLanguageToolsUrl)
+  }
+  catch (error) {
+    console.error('Failed to initialize Ace editor language tools:', error)
+  }
+})
+
 // Check if there is content to display
 function hasContent() {
   return originalText.value && modifiedText.value

+ 1 - 0
app/src/composables/useSSE.ts

@@ -5,6 +5,7 @@ import { onUnmounted, shallowRef } from 'vue'
 export interface SSEOptions {
   url: string
   token: string
+  // eslint-disable-next-line ts/no-explicit-any
   onMessage?: (data: any) => void
   onError?: () => void
   parseData?: boolean

+ 1 - 1
app/src/version.json

@@ -1 +1 @@
-{"version":"2.0.0-rc.5","build_id":13,"total_build":407}
+{"version":"2.0.0-rc.5","build_id":19,"total_build":413}

+ 0 - 1
app/vite.config.ts

@@ -107,7 +107,6 @@ export default defineConfig(({ mode }) => {
         output: {
           manualChunks: {
             'ace-editor': ['ace-builds'],
-            'ace-ext': ['ace-builds/src-min-noconflict/ext-language_tools'],
           },
         },
       },