Commit 5aaa8926 by qlintonger xeno

feat: AI格式化processing+41567

parent ff6336ef
......@@ -7,7 +7,6 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
NButton: typeof import('naive-ui')['NButton']
NCard: typeof import('naive-ui')['NCard']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NInput: typeof import('naive-ui')['NInput']
......@@ -16,10 +15,7 @@ declare module 'vue' {
NLayoutFooter: typeof import('naive-ui')['NLayoutFooter']
NLayoutHeader: typeof import('naive-ui')['NLayoutHeader']
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NResult: typeof import('naive-ui')['NResult']
NSpace: typeof import('naive-ui')['NSpace']
NTree: typeof import('naive-ui')['NTree']
NUpload: typeof import('naive-ui')['NUpload']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
}
......
......@@ -55,11 +55,10 @@ export class Processing {
const content = fr.result as string;
try {
// 调用 processXML 方法处理读取的文件内容
const { treeData, xmlDOM } = this.processXML(content, handledNode);
xmlDOM.documentElement.querySelectorAll(':not([data-key])').forEach((node) => node.remove())
const { treeData, xmlDOM, xmlContent } = this.processXML(content, handledNode);
// 解析成功,返回树形数据和 XML DOM 对象
resolve({ treeData, xmlDOM, xmlContent: this.serializeXML(xmlDOM) });
resolve({ treeData, xmlDOM, xmlContent });
} catch (error) {
// 解析失败,拒绝 Promise 并返回错误信息
reject(error);
......
import {Processing} from '@/lib/XMLProcessor/src/core/Processing.ts'
import {Plugin} from 'vue'
import {Plugin, getCurrentInstance, getCurrentScope} from 'vue'
const p = new Processing()
export const XMLProcessing: Plugin = function(app) {
......@@ -7,9 +7,8 @@ export const XMLProcessing: Plugin = function(app) {
}
export function useXMLProcessing(): Processing {
try {
if (getCurrentInstance()) {
return <Processing>inject('xmlProcessing')
} catch (e) {
return p
}
return p
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ import { IDomEditor } from '@wangeditor/editor'
import { editorRef, treeData, xmlContent, xmlDOM } from '../constants'
import { TreeOption } from 'naive-ui'
import { nodeSet } from '../constants/nodeParsed'
import { getCurrentInstance, getCurrentScope } from 'vue'
export const handleEditor = (editor: IDomEditor) => {
// console.log(editor.getElemsByTypePrefix('JOBCARD'))
......@@ -34,8 +35,8 @@ export const nodeProps = ({ option }: { option: TreeOption }) => {
}
}
}
const xmlProcessing = useXMLProcessing()
export const uploadXml = async (file: File) => {
const xmlProcessing = useXMLProcessing()
const res = await xmlProcessing.processFile(file, nodeSet)
treeData.value = res.treeData
xmlDOM.value = res.xmlDOM
......
......@@ -15,9 +15,9 @@ import { editorRef, formData, xmlContent } from './constants'
import { handleEditor } from './functions'
onMounted(() => {
nextTick(() => {
watchEffect(function() {
editorRef.value?.editorRef?.setHtml(xmlContent.value)
})
}, {flush: 'post'})
})
</script>
<style lang="less" scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment