|
|
@@ -21,15 +21,15 @@
|
|
|
<ElFormItem prop="remark" label="备注">
|
|
|
<ElInput v-model="model.remark" placeholder="请输入备注" />
|
|
|
</ElFormItem>
|
|
|
- <ElFormItem prop="value" label="值" v-if="model.name === 'model'">
|
|
|
- <ElSelect v-model="model.value">
|
|
|
- <ElOption label="gpt-3.5" value="gpt-3.5" />
|
|
|
- <ElOption label="gpt-4" value="gpt-4" />
|
|
|
- <ElOption label="azure-gpt-3.5" value="azure-gpt-3.5" />
|
|
|
- <ElOption label="azure-gpt-4" value="azure-gpt-4" />
|
|
|
- <ElOption label="cf-gpt-3.5" value="cf-gpt-3.5" />
|
|
|
- <ElOption label="cf-gpt-4" value="cf-gpt-4" />
|
|
|
- </ElSelect>
|
|
|
+ <ElFormItem prop="type" label="类型">
|
|
|
+ <EnumSelect v-model="model.type" :enum="SysConfigType" />
|
|
|
+ </ElFormItem>
|
|
|
+ <ElFormItem prop="value" label="值" v-if="model.type === 'file'">
|
|
|
+ <ElInput v-model="model.value" placeholder="请输入">
|
|
|
+ <template #append>
|
|
|
+ <ElButton type="primary" @click="chooseFile" :loading="uploading">上传</ElButton>
|
|
|
+ </template>
|
|
|
+ </ElInput>
|
|
|
</ElFormItem>
|
|
|
<ElFormItem prop="value" label="值" v-else>
|
|
|
<ElInput v-model="model.value" placeholder="请输入值" />
|
|
|
@@ -48,7 +48,10 @@ import { UserRole } from '@/enums'
|
|
|
import { http } from '@/plugins/http'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import { useClipboard } from '@vueuse/core'
|
|
|
+import resolveUrl from 'resolve-url'
|
|
|
+import { SysConfigType } from '@/enums'
|
|
|
|
|
|
+const uploadUrl = resolveUrl(import.meta.env.VITE_API_BASE_URL, '/api/file/upload')
|
|
|
const where = ref({})
|
|
|
const timeFormatter = useTimeFormatter()
|
|
|
const table = ref(null)
|
|
|
@@ -72,4 +75,22 @@ function getToken(row) {
|
|
|
ElMessage.success('复制成功')
|
|
|
})
|
|
|
}
|
|
|
+const uploading = ref(false)
|
|
|
+function chooseFile() {
|
|
|
+ const input = document.createElement('input')
|
|
|
+ input.type = 'file'
|
|
|
+ input.onchange = async (e) => {
|
|
|
+ const file = e.target.files[0]
|
|
|
+ if (!file) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uploading.value = true
|
|
|
+ const formData = new FormData()
|
|
|
+ formData.append('file', file)
|
|
|
+ const res = await http.post(uploadUrl, formData)
|
|
|
+ model.value.value = res.url
|
|
|
+ uploading.value = false
|
|
|
+ }
|
|
|
+ input.click()
|
|
|
+}
|
|
|
</script>
|