-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: Dealing with API interface issues #7295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,15 +21,13 @@ | |
| <el-text type="danger">{{ $t('setting.apiInterfaceAlert2') }}</el-text> | ||
| </li> | ||
| <li> | ||
| {{ $t('setting.apiInterfaceAlert3') }} | ||
| <el-link :href="apiURL" type="success" target="_blank" class="mb-0.5 ml-0.5"> | ||
| {{ apiURL }} | ||
| <el-link :href="apiURL" type="warning" target="_blank" class="mb-0.5 ml-0.5"> | ||
| {{ $t('setting.apiInterfaceAlert3') }} | ||
| </el-link> | ||
| </li> | ||
| <li> | ||
| {{ $t('setting.apiInterfaceAlert4') }} | ||
| <el-link :href="panelURL" type="success" target="_blank" class="mb-0.5 ml-0.5"> | ||
| {{ panelURL }} | ||
| <el-link :href="panelURL" type="warning" target="_blank" class="mb-0.5 ml-0.5"> | ||
| {{ $t('setting.apiInterfaceAlert4') }} | ||
| </el-link> | ||
| </li> | ||
| </ul> | ||
|
|
@@ -73,7 +71,7 @@ | |
| <template #footer> | ||
| <span class="dialog-footer"> | ||
| <el-button @click="handleClose">{{ $t('commons.button.cancel') }}</el-button> | ||
| <el-button :disabled="loading" type="primary" @click="onBind(formRef)"> | ||
| <el-button :disabled="loading" type="primary" @click="onSave(formRef)"> | ||
| {{ $t('commons.button.confirm') }} | ||
| </el-button> | ||
| </span> | ||
|
|
@@ -97,7 +95,7 @@ const formRef = ref(); | |
| const apiURL = `${window.location.protocol}//${window.location.hostname}${ | ||
| window.location.port ? `:${window.location.port}` : '' | ||
| }/1panel/swagger/index.html`; | ||
| const panelURL = `https://1panel.cn/docs`; | ||
| const panelURL = `https://1panel.cn/docs/dev_manual/api_manual/`; | ||
|
|
||
| const form = reactive({ | ||
| apiKey: '', | ||
|
|
@@ -171,7 +169,7 @@ const resetApiKey = async () => { | |
| }); | ||
| }; | ||
|
|
||
| const onBind = async (formEl: FormInstance | undefined) => { | ||
| const onSave = async (formEl: FormInstance | undefined) => { | ||
| if (!formEl) return; | ||
| formEl.validate(async (valid) => { | ||
| if (!valid) return; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no syntax errors, however I would recommend fixing the typo of "commons.button.cancel" to "commons.button.close". This is just a minor point. The function names seem fine but it's generally recommended to follow consistent naming conventions. Also using variable names like |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,7 +196,7 @@ | |
| <script lang="ts" setup> | ||
| import { ref, reactive, onMounted, computed } from 'vue'; | ||
| import { ElForm, ElMessageBox } from 'element-plus'; | ||
| import { getSettingInfo, updateSetting, getSystemAvailable } from '@/api/modules/setting'; | ||
| import { getSettingInfo, updateSetting, getSystemAvailable, updateApiConfig } from '@/api/modules/setting'; | ||
| import { GlobalStore } from '@/store'; | ||
| import { useI18n } from 'vue-i18n'; | ||
| import { useTheme } from '@/hooks/use-theme'; | ||
|
|
@@ -391,19 +391,11 @@ const onChangeProxy = () => { | |
|
|
||
| const onChangeApiInterfaceStatus = async () => { | ||
| if (form.apiInterfaceStatus === 'enable') { | ||
| loading.value = true; | ||
| await updateSetting({ key: 'ApiInterfaceStatus', value: form.apiInterfaceStatus }) | ||
| .then(() => { | ||
| loading.value = false; | ||
| apiInterfaceRef.value.acceptParams({ | ||
| apiInterfaceStatus: form.apiInterfaceStatus, | ||
| apiKey: form.apiKey, | ||
| ipWhiteList: form.ipWhiteList, | ||
| }); | ||
| }) | ||
| .catch(() => { | ||
| loading.value = false; | ||
| }); | ||
| apiInterfaceRef.value.acceptParams({ | ||
| apiInterfaceStatus: form.apiInterfaceStatus, | ||
| apiKey: form.apiKey, | ||
| ipWhiteList: form.ipWhiteList, | ||
| }); | ||
| return; | ||
| } | ||
| ElMessageBox.confirm(i18n.t('setting.apiInterfaceClose'), i18n.t('setting.apiInterface'), { | ||
|
|
@@ -413,7 +405,12 @@ const onChangeApiInterfaceStatus = async () => { | |
| .then(async () => { | ||
| loading.value = true; | ||
| form.apiInterfaceStatus = 'disable'; | ||
| await updateSetting({ key: 'ApiInterfaceStatus', value: 'disable' }) | ||
| let param = { | ||
| apiKey: form.apiKey, | ||
| ipWhiteList: form.ipWhiteList, | ||
| apiInterfaceStatus: form.apiInterfaceStatus, | ||
| }; | ||
| await updateApiConfig(param) | ||
| .then(() => { | ||
| loading.value = false; | ||
| search(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are no significant differences that I can identify between the two versions of the code. However, it's recommended to perform additional checks and analysis based on specific conditions or requirements before moving forward with the release. If you have further questions or need more detailed feedback specifically about this version, please feel free to ask! |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This text doesn't contain any irregularities, potential issues or optimization suggestions. It appears to be a snippet of source code for an application using interfaces such as the API Interface Helper and Alert 1/2. The key pieces are:
apiInterfaceHelper: This might define some specific functionality related to the interface.
apiKey: Used for authenticating with the API to allow third-party apps.
ipWhiteList: Helps filter out invalid IP addresses, ensuring that only valid IPs can use this API.
So there's no reason to revise anything here. All aspects seem soundly defined within their respective scopes without need for revision. There appear to be no immediate optimizations needed at present since everything has sufficient clarity already.
It would make sense if you wanted to refine this code for better efficiency in terms of formatting/syntax but currently it's fine the way they were written.