add abort
This commit is contained in:
1 parent
3ea9f786dc
commit
8b488de9d6
7 files changed
+107
-31
No files matched your search
@@ -25,14 +25,18 @@
|
||||
:label="$t('application.field.remainingCount')"
|
||||
width="100px"
|
||||
class-name="text-center"
|
||||
/>
|
||||
>
|
||||
<template #default="scope">
|
||||
<span>{{ getRemainingCount(scope.row) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
prop="used_count"
|
||||
:label="$t('application.field.usedCount')"
|
||||
width="100px"
|
||||
class-name="text-center"
|
||||
/>
|
||||
<el-table-column :label="$t('application.field.credential')" class-name="api-key" width="330px">
|
||||
<el-table-column :label="$t('application.field.credential')" class-name="credential" width="380px">
|
||||
<template #default="scope">
|
||||
<div v-if="scope?.row?.credential?.type === credentialType.TOKEN">
|
||||
<span class="key">{{ scope?.row?.credential?.token }}</span>
|
||||
@@ -225,6 +229,14 @@ export default defineComponent({
|
||||
.catch(() => {
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
getRemainingCount(application: IApplication) {
|
||||
if (application.type === IApplicationType.API) {
|
||||
return application.remaining_count;
|
||||
}
|
||||
if (application.type === IApplicationType.PROXY) {
|
||||
return `${((application.remaining_count || 0) / 1024 / 1024).toFixed(2)}MB`;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -244,7 +256,7 @@ export default defineComponent({
|
||||
|
||||
.panel {
|
||||
padding: 30px;
|
||||
.api-key {
|
||||
.credential {
|
||||
.copy {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ export interface IData {
|
||||
loading: boolean;
|
||||
form: IForm;
|
||||
documentType: typeof IDocumentType;
|
||||
canceler: AbortController | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
@@ -72,7 +73,8 @@ export default defineComponent({
|
||||
document: undefined,
|
||||
loading: false,
|
||||
form: {},
|
||||
documentType: IDocumentType
|
||||
documentType: IDocumentType,
|
||||
canceler: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -94,8 +96,16 @@ export default defineComponent({
|
||||
getDocument(id: string) {
|
||||
this.loading = true;
|
||||
this.form = {};
|
||||
// cancel existing pending request
|
||||
if (this.canceler) {
|
||||
console.log('abort');
|
||||
this.canceler.abort();
|
||||
}
|
||||
this.canceler = new AbortController();
|
||||
documentOperator
|
||||
.get(id)
|
||||
.get(id, {
|
||||
signal: this.canceler.signal
|
||||
})
|
||||
.then(({ data: data }: { data: IDocumentDetailResponse }) => {
|
||||
this.loading = false;
|
||||
this.document = data;
|
||||
|
||||
Reference in new issue
Block a user