wangrong
2026-08-30 4c949c0dc9bcae785c281c9d8125295f09810b15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<script lang="ts" setup>
import { PropType, toRefs } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
 
export interface AuthConfig {
  verification: string
  username: string
  password: string
}
 
const props = defineProps({
  request: {
    type: Object as PropType<{ authManager: AuthConfig }>,
    default: () => ({})
  }
})
const { t } = useI18n()
 
const { request } = toRefs(props)
 
const options = [{ name: 'No Auth' }, { name: 'Basic Auth' }]
const change = () => {
  const { username, password, verification } = request.value.authManager
  const isBasic = verification === 'Basic Auth'
  request.value.authManager.username = isBasic ? username : ''
  request.value.authManager.password = isBasic ? password : ''
}
</script>
 
<template>
  <el-form label-position="top">
    <el-form-item class="api-auth-config" :label="t('datasource.verification_method')">
      <el-select
        style="width: 100%"
        v-model="request.authManager.verification"
        @change="change"
        :placeholder="t('datasource.verification_method')"
      >
        <el-option v-for="item in options" :key="item.name" :label="item.name" :value="item.name" />
      </el-select>
    </el-form-item>
    <el-row :gutter="16">
      <el-col :span="12">
        <el-form-item
          v-if="request.authManager.verification === 'Basic Auth'"
          :label="t('datasource.username')"
        >
          <el-input
            v-model="request.authManager.username"
            :placeholder="t('datasource.username')"
            class="ms-http-input"
          />
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item
          v-if="request.authManager.verification === 'Basic Auth'"
          :label="t('datasource.password')"
        >
          <el-input
            v-model="request.authManager.password"
            type="password"
            :placeholder="t('datasource.password')"
          />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>
 
<style lang="less">
.api-auth-config {
  margin-bottom: 16px !important;
}
</style>