Commit d7955dc9b2c595dc7a96bc30a2f8d04fc626143d

Authored by fengtao
1 parent 280bf161

pref:优化转换函数弹窗报错一直转圈

@@ -134,24 +134,22 @@ @@ -134,24 +134,22 @@
134 }); 134 });
135 // 初始化编辑器 135 // 初始化编辑器
136 const initEditor = () => { 136 const initEditor = () => {
137 - try {  
138 - aceEditor.value = ace.edit(aceRef.value, {  
139 - maxLines: 12, // 最大行数,超过会自动出现滚动条  
140 - minLines: 12, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小  
141 - fontSize: 14, // 编辑器内字体大小  
142 - theme: 'ace/theme/chrome', // 默认设置的主题  
143 - mode: 'ace/mode/javascript', // 默认设置的语言模式  
144 - tabSize: 2, // 制表符设置为 4 个空格大小  
145 - }); 137 + aceEditor.value = ace.edit(aceRef.value, {
  138 + maxLines: 12, // 最大行数,超过会自动出现滚动条
  139 + minLines: 12, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
  140 + fontSize: 14, // 编辑器内字体大小
  141 + theme: 'ace/theme/chrome', // 默认设置的主题
  142 + mode: 'ace/mode/javascript', // 默认设置的语言模式
  143 + tabSize: 2, // 制表符设置为 4 个空格大小
  144 + });
146 145
147 - aceEditor.value.setOptions({  
148 - enableBasicAutocompletion: true,  
149 - enableLiveAutocompletion: true,  
150 - });  
151 - aceEditor.value.setValue();  
152 - beautify(aceEditor.value.session);  
153 - scriptForm.convertJs = aceEditor.value.getValue();  
154 - } catch {} 146 + aceEditor.value.setOptions({
  147 + enableBasicAutocompletion: true,
  148 + enableLiveAutocompletion: true,
  149 + });
  150 + aceEditor.value.setValue();
  151 + beautify(aceEditor.value.session);
  152 + scriptForm.convertJs = aceEditor.value.getValue();
155 }; 153 };
156 const handleCopy = () => { 154 const handleCopy = () => {
157 const valueRef = aceEditor.value.getValue(); 155 const valueRef = aceEditor.value.getValue();
@@ -38,48 +38,46 @@ @@ -38,48 +38,46 @@
38 data: {}, 38 data: {},
39 }); 39 });
40 const [register, { setModalProps, closeModal }] = useModalInner(async (data) => { 40 const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
41 - try {  
42 - setModalProps({ loading: true });  
43 - handleCancel(false);  
44 - isUpdate.value = data.isUpdate;  
45 - isViewDetail.value = data.isView;  
46 - isTest.value = data.isTest;  
47 - isText.value = data.isText;  
48 - isTitle.value = data.isTitle;  
49 - editData.data = data.record;  
50 - setModalProps({ loading: false });  
51 - converScriptRef.value?.initEditor();  
52 - if (!unref(isViewDetail)) {  
53 - const title =  
54 - unref(isTitle) == 'edit'  
55 - ? '编辑转换脚本'  
56 - : unref(isTitle) == 'add'  
57 - ? '新增转换脚本'  
58 - : '测试转换脚本';  
59 - const okText = isText.value == 'test' ? '测试' : '确定';  
60 - if (unref(isTitle) == 'add') { 41 + setModalProps({ loading: true });
  42 + handleCancel(false);
  43 + isUpdate.value = data.isUpdate;
  44 + isViewDetail.value = data.isView;
  45 + isTest.value = data.isTest;
  46 + isText.value = data.isText;
  47 + isTitle.value = data.isTitle;
  48 + editData.data = data.record;
  49 + setModalProps({ loading: false });
  50 + converScriptRef.value?.initEditor();
  51 + if (!unref(isViewDetail)) {
  52 + const title =
  53 + unref(isTitle) == 'edit'
  54 + ? '编辑转换脚本'
  55 + : unref(isTitle) == 'add'
  56 + ? '新增转换脚本'
  57 + : '测试转换脚本';
  58 + const okText = isText.value == 'test' ? '测试' : '确定';
  59 + if (unref(isTitle) == 'add') {
  60 + converScriptRef.value?.setDefaultRadio('HEX', 'true');
  61 + }
  62 + if (unref(isTitle) == 'edit') {
  63 + converScriptRef.value?.setFormData(data.record);
  64 + }
  65 + if (unref(isTitle) == 'test') {
  66 + if (data.record) {
  67 + const res = await getScriptManageDetail(data.record);
  68 + converScriptRef.value?.setFormData(res);
  69 + } else {
61 converScriptRef.value?.setDefaultRadio('HEX', 'true'); 70 converScriptRef.value?.setDefaultRadio('HEX', 'true');
62 } 71 }
63 - if (unref(isTitle) == 'edit') {  
64 - converScriptRef.value?.setFormData(data.record);  
65 - }  
66 - if (unref(isTitle) == 'test') {  
67 - if (data.record) {  
68 - const res = await getScriptManageDetail(data.record);  
69 - converScriptRef.value?.setFormData(res);  
70 - } else {  
71 - converScriptRef.value?.setDefaultRadio('HEX', 'true');  
72 - }  
73 - }  
74 - setModalProps({ title, showOkBtn: true, showCancelBtn: true, okText });  
75 - if (!unref(isUpdate)) {  
76 - }  
77 - } else {  
78 - setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看转换脚本' });  
79 - const res = await getScriptManageDetail(data.record.id);  
80 - converScriptRef.value?.setFormData(res || {});  
81 } 72 }
82 - } catch {} 73 + setModalProps({ title, showOkBtn: true, showCancelBtn: true, okText });
  74 + if (!unref(isUpdate)) {
  75 + }
  76 + } else {
  77 + setModalProps({ showOkBtn: false, showCancelBtn: false, title: '查看转换脚本' });
  78 + const res = await getScriptManageDetail(data.record.id);
  79 + converScriptRef.value?.setFormData(res || {});
  80 + }
83 }); 81 });
84 82
85 const handleSubmit = async () => { 83 const handleSubmit = async () => {