1
0
Эх сурвалжийг харах

fix(tls): no certificate available

Jacky 3 долоо хоног өмнө
parent
commit
8f7574f212

+ 23 - 1
app/src/components/ConfigHistory/ConfigHistory.vue

@@ -5,8 +5,8 @@ import type { Key } from 'ant-design-vue/es/_util/type'
 import config from '@/api/config'
 import StdPagination from '@/components/StdDesign/StdDataDisplay/StdPagination.vue'
 import { message } from 'ant-design-vue'
+import { defineAsyncComponent } from 'vue'
 import { datetime } from '../StdDesign/StdDataDisplay/StdTableTransformer'
-import DiffViewer from './DiffViewer.vue'
 
 // Define props for the component
 const props = defineProps<{
@@ -17,6 +17,19 @@ const props = defineProps<{
 const visible = defineModel<boolean>('visible')
 const currentContent = defineModel<string>('currentContent')
 
+// Import DiffViewer asynchronously with loading options
+const DiffViewer = defineAsyncComponent({
+  loader: () => import('./DiffViewer.vue'),
+  loadingComponent: {
+    template: '<div class="async-loading"><ASpin /></div>',
+  },
+  delay: 200,
+  timeout: 10000,
+  errorComponent: {
+    template: '<div class="async-error"><AAlert type="error" message="Failed to load component" /></div>',
+  },
+})
+
 const loading = ref(false)
 const records = ref<ConfigBackup[]>([])
 const showDiffViewer = ref(false)
@@ -186,4 +199,13 @@ const compareButtonText = computed(() => {
   display: flex;
   gap: 8px;
 }
+
+.async-loading,
+.async-error {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  padding: 20px;
+  min-height: 200px;
+}
 </style>

+ 5 - 2
app/src/components/ConfigHistory/DiffViewer.vue

@@ -17,6 +17,9 @@ const emit = defineEmits<{
   (e: 'restore'): void
 }>()
 
+// Import Range class separately to avoid loading the entire ace package
+const Range = ace.Range
+
 // Define modal visibility using defineModel with boolean type
 const visible = defineModel<boolean>('visible')
 // Define currentContent using defineModel
@@ -253,7 +256,7 @@ function compareAndHighlightLines(leftSession: Ace.EditSession, rightSession: Ac
     if (!matchedLeftLines.has(i)) {
       leftSession.addGutterDecoration(i, 'ace_gutter-active-line')
       leftSession.addMarker(
-        new ace.Range(i, 0, i, leftLines[i].length || 1),
+        new Range(i, 0, i, leftLines[i].length || 1),
         'diff-line-deleted',
         'fullLine',
       )
@@ -265,7 +268,7 @@ function compareAndHighlightLines(leftSession: Ace.EditSession, rightSession: Ac
     if (!matchedRightLines.has(j)) {
       rightSession.addGutterDecoration(j, 'ace_gutter-active-line')
       rightSession.addMarker(
-        new ace.Range(j, 0, j, rightLines[j].length || 1),
+        new Range(j, 0, j, rightLines[j].length || 1),
         'diff-line-added',
         'fullLine',
       )

+ 1 - 1
app/src/version.json

@@ -1 +1 @@
-{"version":"2.0.0-rc.5","build_id":4,"total_build":398}
+{"version":"2.0.0-rc.5","build_id":9,"total_build":403}

+ 8 - 0
app/vite.config.ts

@@ -103,6 +103,14 @@ export default defineConfig(({ mode }) => {
     },
     build: {
       chunkSizeWarningLimit: 1000,
+      rollupOptions: {
+        output: {
+          manualChunks: {
+            'ace-editor': ['ace-builds'],
+            'ace-ext': ['ace-builds/src-min-noconflict/ext-language_tools'],
+          },
+        },
+      },
     },
   }
 })

+ 1 - 1
internal/cert/server_tls.go

@@ -22,7 +22,7 @@ func ReloadServerTLSCertificate() error {
 		return err
 	}
 
-	tlsCert.Store(newCert)
+	tlsCert.Store(&newCert)
 	return nil
 }
 

+ 3 - 1
main.go

@@ -75,12 +75,14 @@ func Program(confPath string) func(state overseer.State) {
 				GetCertificate: func(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) {
 					return cert.GetServerTLSCertificate()
 				},
+				MinVersion: tls.VersionTLS12,
 			}
 
 			srv.TLSConfig = tlsConfig
 
 			logger.Info("Starting HTTPS server")
-			err = srv.ServeTLS(state.Listener, "", "")
+			tlsListener := tls.NewListener(state.Listener, tlsConfig)
+			err = srv.Serve(tlsListener)
 		} else {
 			logger.Info("Starting HTTP server")
 			err = srv.Serve(state.Listener)