Commit 91a20522c22934e6efb7869bdf6dc9859e5d01c1

Authored by fengtao
1 parent bdcebf7f

pref:优化转换函数启用后可以测试

@@ -134,22 +134,24 @@ @@ -134,22 +134,24 @@
134 }); 134 });
135 // 初始化编辑器 135 // 初始化编辑器
136 const initEditor = () => { 136 const initEditor = () => {
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 - }); 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 + });
145 146
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(); 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 {}
153 }; 155 };
154 const handleCopy = () => { 156 const handleCopy = () => {
155 const valueRef = aceEditor.value.getValue(); 157 const valueRef = aceEditor.value.getValue();
@@ -38,46 +38,48 @@ @@ -38,46 +38,48 @@
38 data: {}, 38 data: {},
39 }); 39 });
40 const [register, { setModalProps, closeModal }] = useModalInner(async (data) => { 40 const [register, { setModalProps, closeModal }] = useModalInner(async (data) => {
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 - converScriptRef.value?.initEditor();  
50 - setModalProps({ loading: false });  
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 { 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 + converScriptRef.value?.initEditor();
  51 + setModalProps({ loading: false });
  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') {
70 converScriptRef.value?.setDefaultRadio('HEX', 'true'); 61 converScriptRef.value?.setDefaultRadio('HEX', 'true');
71 } 62 }
  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 || {});
72 } 81 }
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 - } 82 + } catch {}
81 }); 83 });
82 84
83 const handleSubmit = async () => { 85 const handleSubmit = async () => {
@@ -29,7 +29,6 @@ @@ -29,7 +29,6 @@
29 icon: 'ant-design:font-size-outlined', 29 icon: 'ant-design:font-size-outlined',
30 auth: 'api:yt:js:test', 30 auth: 'api:yt:js:test',
31 onClick: handleBindTest.bind(null, record), 31 onClick: handleBindTest.bind(null, record),
32 - ifShow: record.status == 0,  
33 }, 32 },
34 { 33 {
35 label: '编辑', 34 label: '编辑',