add abort
This commit is contained in:
1 parent
3ea9f786dc
commit
8b488de9d6
7 files changed
+107
-31
No files matched your search
+1
-1
@@ -30,7 +30,7 @@
|
||||
"@sentry/vue": "^7.34.0",
|
||||
"@types/mustache": "^4.2.2",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"axios": "^0.21.1",
|
||||
"axios": "^1.34.0",
|
||||
"codemirror": "^6.0.1",
|
||||
"copy-to-clipboard": "^3.3.3",
|
||||
"dayjs": "^1.10.7",
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
<el-link type="primary" class="link" :underline="false">
|
||||
<span class="name">{{ document?.title || document?.api?.title }}</span>
|
||||
</el-link>
|
||||
<el-tag v-if="document?.api?.request?.method" type="" class="method" effect="dark">
|
||||
{{ document?.api?.request?.method }}
|
||||
<el-tag class="type" effect="dark">
|
||||
{{ documentType.API.toUpperCase() }}
|
||||
</el-tag>
|
||||
</div>
|
||||
<div
|
||||
@@ -24,8 +24,8 @@
|
||||
<el-link type="primary" class="link" :underline="false">
|
||||
<span class="name">{{ document?.title || document?.proxy?.title }}</span>
|
||||
</el-link>
|
||||
<el-tag v-if="document?.api?.request?.method" type="" class="method" effect="dark">
|
||||
{{ document?.api?.request?.method }}
|
||||
<el-tag class="type" effect="dark">
|
||||
{{ documentType.PROXY.toUpperCase() }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</template>
|
||||
@@ -99,10 +99,12 @@ $height: 35px;
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
.method {
|
||||
.type {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
right: 5px;
|
||||
top: 5px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -57,6 +57,7 @@ export default {
|
||||
height: 100%;
|
||||
padding: 30px;
|
||||
box-shadow: 1px 0 0 #eee;
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AxiosResponse } from 'axios';
|
||||
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { httpClient } from '../instance';
|
||||
import { IDocument, IDocumentDetailResponse, IDocumentListResponse } from './models';
|
||||
|
||||
@@ -12,26 +12,32 @@ export interface IDocumentQuery {
|
||||
class DocumentOperator {
|
||||
key = 'documents';
|
||||
|
||||
async getAll(query: IDocumentQuery): Promise<AxiosResponse<IDocumentListResponse>> {
|
||||
async getAll(query: IDocumentQuery, config?: AxiosRequestConfig): Promise<AxiosResponse<IDocumentListResponse>> {
|
||||
return await httpClient.get(`/${this.key}/`, {
|
||||
...config,
|
||||
params: query
|
||||
});
|
||||
}
|
||||
|
||||
async get(id: string): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.get(`/${this.key}/${id}`);
|
||||
async get(id: string, config?: AxiosRequestConfig): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
console.log('sss', config);
|
||||
return await httpClient.get(`/${this.key}/${id}`, config);
|
||||
}
|
||||
|
||||
async create(data: IDocument): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data);
|
||||
async create(data: IDocument, config?: AxiosRequestConfig): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.post(`/${this.key}/`, data, config);
|
||||
}
|
||||
|
||||
async update(id: string, data: IDocument): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data);
|
||||
async update(
|
||||
id: string,
|
||||
data: IDocument,
|
||||
config?: AxiosRequestConfig
|
||||
): Promise<AxiosResponse<IDocumentDetailResponse>> {
|
||||
return await httpClient.put(`/${this.key}/${id}`, data, config);
|
||||
}
|
||||
|
||||
async delete(id: string): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`);
|
||||
async delete(id: string, config?: AxiosRequestConfig): Promise<AxiosResponse<null>> {
|
||||
return await httpClient.delete(`/${this.key}/${id}`, config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1054,6 +1054,11 @@ async-validator@^4.2.5:
|
||||
resolved "https://registry.yarnpkg.com/async-validator/-/async-validator-4.2.5.tgz#c96ea3332a521699d0afaaceed510a54656c6339"
|
||||
integrity sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==
|
||||
|
||||
asynckit@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
|
||||
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
|
||||
|
||||
autoprefixer@^10.3.3:
|
||||
version "10.4.2"
|
||||
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.4.2.tgz#25e1df09a31a9fba5c40b578936b90d35c9d4d3b"
|
||||
@@ -1066,12 +1071,14 @@ autoprefixer@^10.3.3:
|
||||
picocolors "^1.0.0"
|
||||
postcss-value-parser "^4.2.0"
|
||||
|
||||
axios@^0.21.1:
|
||||
version "0.21.4"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
|
||||
integrity sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==
|
||||
axios@^1.34.0:
|
||||
version "1.3.4"
|
||||
resolved "https://registry.yarnpkg.com/axios/-/axios-1.3.4.tgz#f5760cefd9cfb51fd2481acf88c05f67c4523024"
|
||||
integrity sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==
|
||||
dependencies:
|
||||
follow-redirects "^1.14.0"
|
||||
follow-redirects "^1.15.0"
|
||||
form-data "^4.0.0"
|
||||
proxy-from-env "^1.1.0"
|
||||
|
||||
babel-walk@3.0.0-canary-5:
|
||||
version "3.0.0-canary-5"
|
||||
@@ -1236,6 +1243,13 @@ color@^4.0.1:
|
||||
color-convert "^2.0.1"
|
||||
color-string "^1.9.0"
|
||||
|
||||
combined-stream@^1.0.8:
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
|
||||
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
|
||||
dependencies:
|
||||
delayed-stream "~1.0.0"
|
||||
|
||||
commander@^8.0.0:
|
||||
version "8.3.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66"
|
||||
@@ -1383,6 +1397,11 @@ defined@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693"
|
||||
integrity sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=
|
||||
|
||||
delayed-stream@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
|
||||
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
|
||||
|
||||
detective@^5.2.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/detective/-/detective-5.2.0.tgz#feb2a77e85b904ecdea459ad897cc90a99bd2a7b"
|
||||
@@ -2038,10 +2057,19 @@ flatted@^3.1.0:
|
||||
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3"
|
||||
integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==
|
||||
|
||||
follow-redirects@^1.14.0:
|
||||
version "1.14.7"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.7.tgz#2004c02eb9436eee9a21446a6477debf17e81685"
|
||||
integrity sha512-+hbxoLbFMbRKDwohX8GkTataGqO6Jb7jGwpAlwgy2bIz25XtRm7KEzJM76R1WiNT5SwZkX4Y75SwBolkpmE7iQ==
|
||||
follow-redirects@^1.15.0:
|
||||
version "1.15.2"
|
||||
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
|
||||
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
|
||||
|
||||
form-data@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
|
||||
dependencies:
|
||||
asynckit "^0.4.0"
|
||||
combined-stream "^1.0.8"
|
||||
mime-types "^2.1.12"
|
||||
|
||||
fraction.js@^4.1.2:
|
||||
version "4.1.2"
|
||||
@@ -2612,6 +2640,18 @@ micromatch@^4.0.4:
|
||||
braces "^3.0.1"
|
||||
picomatch "^2.2.3"
|
||||
|
||||
mime-db@1.52.0:
|
||||
version "1.52.0"
|
||||
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
|
||||
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
|
||||
|
||||
mime-types@^2.1.12:
|
||||
version "2.1.35"
|
||||
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
|
||||
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
|
||||
dependencies:
|
||||
mime-db "1.52.0"
|
||||
|
||||
minimatch@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
@@ -2937,6 +2977,11 @@ promise@^7.0.1:
|
||||
dependencies:
|
||||
asap "~2.0.3"
|
||||
|
||||
proxy-from-env@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
|
||||
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==
|
||||
|
||||
pug-attrs@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/pug-attrs/-/pug-attrs-3.0.0.tgz#b10451e0348165e31fad1cc23ebddd9dc7347c41"
|
||||
|
||||
Reference in new issue
Block a user