|
|
@ -29,7 +29,7 @@ const showNewTokenModal = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const currentLimit = ref(10) |
|
|
|
const currentLimit = ref(10) |
|
|
|
|
|
|
|
|
|
|
|
const defaultTokenName = t('labels.untitledToken') |
|
|
|
const defaultTokenName = t('labels.token') |
|
|
|
|
|
|
|
|
|
|
|
const selectedTokenData = ref<ApiTokenType>({ |
|
|
|
const selectedTokenData = ref<ApiTokenType>({ |
|
|
|
description: defaultTokenName, |
|
|
|
description: defaultTokenName, |
|
|
@ -42,6 +42,30 @@ const pagination = reactive({ |
|
|
|
pageSize: 10, |
|
|
|
pageSize: 10, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getDefaultTokenValue = (tokens: IApiTokenInfo[]) => { |
|
|
|
|
|
|
|
let extractedSortedTokenNumbers = |
|
|
|
|
|
|
|
[...tokens] |
|
|
|
|
|
|
|
.map((e) => { |
|
|
|
|
|
|
|
let tokenName = e.description?.split('-') |
|
|
|
|
|
|
|
if (tokenName && tokenName[tokenName.length - 1] && !isNaN(Number(tokenName[tokenName.length - 1]?.trim()))) { |
|
|
|
|
|
|
|
return Number(tokenName[tokenName.length - 1]?.trim()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.filter((e) => e) |
|
|
|
|
|
|
|
.sort((a, b) => { |
|
|
|
|
|
|
|
if (a !== undefined && b !== undefined) { |
|
|
|
|
|
|
|
return a - b |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0 |
|
|
|
|
|
|
|
}) || [] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (extractedSortedTokenNumbers.length) { |
|
|
|
|
|
|
|
return `${defaultTokenName}-${(extractedSortedTokenNumbers[extractedSortedTokenNumbers.length - 1] || 0) + 1}` |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return `${defaultTokenName}-1` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const hideOrShowToken = (tokenId: string) => { |
|
|
|
const hideOrShowToken = (tokenId: string) => { |
|
|
|
if (selectedToken.isShow && selectedToken.id === tokenId) { |
|
|
|
if (selectedToken.isShow && selectedToken.id === tokenId) { |
|
|
|
selectedToken.isShow = false |
|
|
|
selectedToken.isShow = false |
|
|
@ -67,6 +91,7 @@ const loadTokens = async (page = currentPage.value, limit = currentLimit.value) |
|
|
|
pagination.pageSize = 10 |
|
|
|
pagination.pageSize = 10 |
|
|
|
|
|
|
|
|
|
|
|
tokens.value = response.list as IApiTokenInfo[] |
|
|
|
tokens.value = response.list as IApiTokenInfo[] |
|
|
|
|
|
|
|
selectedTokenData.value.description = getDefaultTokenValue(tokens.value) |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
} |
|
|
|
} |
|
|
@ -116,7 +141,6 @@ const generateToken = async () => { |
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
selectedTokenData.value.description = defaultTokenName |
|
|
|
|
|
|
|
$e('a:api-token:generate') |
|
|
|
$e('a:api-token:generate') |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|