feat: 访问限制
This commit is contained in:
parent
8b559237da
commit
3dd3ead155
@ -1,22 +1,22 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog title="访问限制" v-model="dialogVisible">
|
<el-dialog title="访问限制" v-model="dialogVisible">
|
||||||
<el-form label-position="top" ref="limitFormRef" :model="form">
|
<el-form label-position="top" ref="limitFormRef" :model="form">
|
||||||
<el-form-item label="文档地址" prop="source_url">
|
<el-form-item label="客户端提问限制">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="form.min_star"
|
v-model="form.access_num"
|
||||||
:min="0"
|
:min="0"
|
||||||
:step="1"
|
:step="1"
|
||||||
controls-position="right"
|
controls-position="right"
|
||||||
step-strictly
|
step-strictly
|
||||||
/>
|
/>
|
||||||
次 / 天
|
<span class="ml-4">次 / 天</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="白名单" @click.prevent>
|
<el-form-item label="白名单" @click.prevent>
|
||||||
<el-switch size="small" v-model="form.multiple_rounds_dialogue"></el-switch>
|
<el-switch size="small" v-model="form.white_active"></el-switch>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-input
|
<el-input
|
||||||
v-model="form.source_url"
|
v-model="form.white_list"
|
||||||
placeholder="请输入域名或IP地址,一行一个。"
|
placeholder="请输入域名或IP地址,一行一个。"
|
||||||
:rows="10"
|
:rows="10"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
@ -36,24 +36,22 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { copyClick } from '@/utils/clipboard'
|
import type { FormInstance, FormRules } from 'element-plus'
|
||||||
import overviewApi from '@/api/application-overview'
|
import applicationApi from '@/api/application'
|
||||||
import { datetimeFormat } from '@/utils/time'
|
|
||||||
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
import { MsgSuccess, MsgConfirm } from '@/utils/message'
|
||||||
import useStore from '@/stores'
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const {
|
const {
|
||||||
params: { id }
|
params: { id }
|
||||||
} = route
|
} = route
|
||||||
const { application } = useStore()
|
|
||||||
|
|
||||||
const emit = defineEmits(['addData'])
|
const emit = defineEmits(['refresh'])
|
||||||
|
|
||||||
const limitFormRef = ref()
|
const limitFormRef = ref()
|
||||||
const form = ref<any>({
|
const form = ref<any>({
|
||||||
type: '0',
|
access_num: 0,
|
||||||
source_url: '',
|
white_active: true,
|
||||||
selector: ''
|
white_list: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const dialogVisible = ref<boolean>(false)
|
const dialogVisible = ref<boolean>(false)
|
||||||
@ -62,18 +60,39 @@ const loading = ref(false)
|
|||||||
watch(dialogVisible, (bool) => {
|
watch(dialogVisible, (bool) => {
|
||||||
if (!bool) {
|
if (!bool) {
|
||||||
form.value = {
|
form.value = {
|
||||||
type: '0',
|
access_num: 0,
|
||||||
source_url: '',
|
white_active: true,
|
||||||
selector: ''
|
white_list: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const open = () => {
|
const open = (data: any) => {
|
||||||
|
form.value.access_num = data.access_num
|
||||||
|
form.value.white_active = data.white_active
|
||||||
|
form.value.white_list = data.white_list?.join('\n')
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit() {}
|
const submit = async (formEl: FormInstance | undefined) => {
|
||||||
|
if (!formEl) return
|
||||||
|
await formEl.validate((valid, fields) => {
|
||||||
|
if (valid) {
|
||||||
|
const obj = {
|
||||||
|
white_list: form.value.white_list.split('\n'),
|
||||||
|
white_active: form.value.white_active,
|
||||||
|
access_num: form.value.access_num
|
||||||
|
}
|
||||||
|
applicationApi.putAccessToken(id as string, obj, loading).then((res) => {
|
||||||
|
emit('refresh')
|
||||||
|
MsgSuccess('设置成功')
|
||||||
|
dialogVisible.value = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('error submit!', fields)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
defineExpose({ open })
|
defineExpose({ open })
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -75,7 +75,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<EmbedDialog ref="EmbedDialogRef" />
|
<EmbedDialog ref="EmbedDialogRef" />
|
||||||
<APIKeyDialog ref="APIKeyDialogRef" />
|
<APIKeyDialog ref="APIKeyDialogRef" />
|
||||||
<LimitDialog ref="LimitDialogRef" />
|
<LimitDialog ref="LimitDialogRef" @refresh="refresh" />
|
||||||
</LayoutContainer>
|
</LayoutContainer>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -130,8 +130,8 @@ function updateAccessToken(obj: any, str: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function openLimitDialog() {
|
function openLimitDialog() {
|
||||||
LimitDialogRef.value.open()
|
LimitDialogRef.value.open(accessToken.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
function openAPIKeyDialog() {
|
function openAPIKeyDialog() {
|
||||||
@ -151,6 +151,10 @@ function getDetail() {
|
|||||||
detail.value = res.data
|
detail.value = res.data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
getAccessToken()
|
||||||
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getDetail()
|
getDetail()
|
||||||
getAccessToken()
|
getAccessToken()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user