Commit 5aaa8926 by qlintonger xeno

feat: AI格式化processing+41567

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