Revert "fix: update js-yaml imports for v5"

This reverts commit 250198d547.

Revert "chore(deps): update dependency js-yaml to v5 (#7331)"

This reverts commit b44f671fc2.
This commit is contained in:
Tunglies
2026-06-29 05:17:04 +08:00
parent 250198d547
commit 3a4cd2c361
7 changed files with 40 additions and 48 deletions
+6 -6
View File
@@ -14,7 +14,7 @@ import {
} from '@mui/material'
import { invoke } from '@tauri-apps/api/core'
import { useLockFn } from 'ahooks'
import { dump, load } from 'js-yaml'
import yaml from 'js-yaml'
import type { Ref } from 'react'
import {
useCallback,
@@ -385,7 +385,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
config.hosts = hosts
}
setYamlContent(dump(config, { forceQuotes: true }))
setYamlContent(yaml.dump(config, { forceQuotes: true }))
}, [generateDnsConfig, setYamlContent, values.hosts])
// 重置为默认值
@@ -428,7 +428,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
// 从YAML更新表单值
const updateValuesFromYaml = useCallback(() => {
try {
const parsedYaml = load(yamlContent) as any
const parsedYaml = yaml.load(yamlContent) as any
if (!parsedYaml) return
skipYamlSyncRef.current = true
@@ -478,7 +478,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
if (dnsConfigExists) {
const dnsConfig = await invoke<string>('get_dns_config_content', {})
const config = load(dnsConfig) as any
const config = yaml.load(dnsConfig) as any
updateValuesFromConfig(config)
setYamlContent(dnsConfig)
@@ -524,7 +524,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
}
} else {
// 使用YAML编辑器的值
const parsedConfig = load(yamlContent)
const parsedConfig = yaml.load(yamlContent)
if (typeof parsedConfig !== 'object' || parsedConfig === null) {
throw new Error(t('settings.modals.dns.errors.invalid'))
}
@@ -594,7 +594,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
// 允许YAML编辑后立即分析和更新表单值
try {
const config = load(value || '') as any
const config = yaml.load(value || '') as any
if (config && typeof config === 'object') {
setTimeout(() => {
updateValuesFromConfig(config)