sige 1 year ago
parent
commit
ea73feba20
  1. 2
      src/components/ServiceConfiguration.vue
  2. 4
      src/components/ServiceConfigurationActionLog.vue
  3. 11
      src/components/ServiceConfigurationActions.vue
  4. 1
      src/components/ServiceConfigurationStatusViewer.vue
  5. 29
      src/utils/ApiClient.js

2
src/components/ServiceConfiguration.vue

@ -24,7 +24,7 @@
</fieldset>
</div>
</div>
<div class="p-1">
<div class="p-1 text-right">
<a-button class="mr-1" @click="actionServiceParamReset">重置</a-button>
<a-button class="mr-1" @click="actionServiceParamReload">刷新</a-button>
<a-button @click="actionServiceParamSave">保存</a-button>

4
src/components/ServiceConfigurationActionLog.vue

@ -45,7 +45,9 @@ async function handleLogChange() {
chart = null;
}
if ( null === props.log || null === props.log.response ) {
if ( null === props.log
|| undefined === props.log.response
|| null === props.log.response ) {
return ;
}

11
src/components/ServiceConfigurationActions.vue

@ -35,7 +35,7 @@
</div>
</template>
<script setup>
import { ref, watch } from 'vue';
import { nextTick, ref, watch } from 'vue';
import ApiClient from '@/utils/ApiClient';
import ServiceConfigurationActionParamFile from './ServiceConfigurationActionParamFile.vue'
const emits = defineEmits(['update:actionLog']);
@ -49,8 +49,6 @@ const actions = ref([]);
const actionLog = ref(null);
// watch service key
watch(() => props.serviceKey, handleServiceKeyChange);
// watch log
watch(actionLog, () => emits('update:actionLog', actionLog.value), {deep:true});
// on mounted
async function handleServiceKeyChange() {
@ -101,13 +99,18 @@ async function actionServiceExecute(action) {
params.paramTypes.push(type);
}
emits('update:actionLog', null);
await nextTick();
actionLog.value = {};
actionLog.value.action = params.action;
actionLog.value.params = params.params;
actionLog.value.response = null;
action.isExecuting = true;
emits('update:actionLog', structuredClone(actionLog.value));
await nextTick();
actionLog.value.response = await client.call('service-config/service-action-exec',params);
action.isExecuting = false;
emits('update:actionLog', structuredClone(actionLog.value));
await nextTick();
} catch ( e ) {
/** nothing to do here */
} finally {

1
src/components/ServiceConfigurationStatusViewer.vue

@ -71,7 +71,6 @@ async function refreshServiceStatusList() {
group.items.sort((a,b) => a.order - b.order);
}
statuses.value.sort((a,b) => a.order - b.order);
console.log(statuses.value);
if ( false !== statusRefreshTimer ) {
statusRefreshTimer = setTimeout(refreshServiceStatusList, 1000);
}

29
src/utils/ApiClient.js

@ -22,15 +22,36 @@ export default class ApiClient {
data: params
});
if ( !response.data.success ) {
let errorInfo = response.data.ecode;
delete errorInfo.codeChName;
let content = h('div', {}, [
h('p',{class:'mb-5 text-red-400'},response.data.message),
h('pre', JSON.stringify(response.data.ecode, null, 2)),
h('pre', {class:'overflow-auto h-96 mt-5'}, response.data.traceInfo),
h('p',{class:'mb-5 text-red-400 white-space-pre'},response.data.message),
h('div', {
style:{height:'20px',overflow:'hidden'},
onClick:(event) => {
let elem = event.target.parentElement;
if ( '20px' === elem.style.height ) {
elem.style.height = '600px';
elem.style.overflow = 'auto';
} else {
elem.style.height = '20px';
elem.scrollTop = 0;
elem.style.overflow = 'hidden';
}
}
}, [
h('div','详情'),
h('pre', JSON.stringify(errorInfo, null, 2)),
h('pre', {class:'overflow-auto h-96 mt-5'}, response.data.traceInfo),
]),
]);
Modal.error({title: '请求错误',content:content,width:800});
throw new Error(`API【${name}】调用失败 : ${response.data}`);
}
if ( 'object' === typeof(response.data.data) ) {
if ( 'MESSAGE' === response.data.appRetType ) {
Modal.info({title:'通知', contnet:response.data.message});
}
if ( null !== response.data.data && 'object' === typeof(response.data.data) ) {
response.data.data.$dataType = response.data.dataType;
}
return response.data.data;

Loading…
Cancel
Save