Browse Source

fix: api path

nian 2 months ago
parent
commit
3e922d9d01
2 changed files with 20 additions and 13 deletions
  1. 9 2
      src/views/data-show/data-form/index.vue
  2. 11 11
      src/views/data-show/data-table/index.vue

+ 9 - 2
src/views/data-show/data-form/index.vue

@@ -73,6 +73,8 @@ const rulesCodeHighlight = ref()
 
 const formDisabled = ref(false)
 
+const isRequestLoading = ref(false)
+
 const rules: FormRules = {
   name: { required: true, message: '请输入用户名' },
 }
@@ -154,11 +156,15 @@ function inputOnlyAllowNumber(value: string) {
 }
 
 function generateRandomForm() {
-  fetch(`http://43.143.155.96:3000/api/faker/v2/diy/hobby`)
+  isRequestLoading.value = true
+  fetch(`https://lithe-admin-serverless.vercel.app/api/faker`)
     .then((res) => res.json())
     .then((res) => {
       setForm(res.data)
     })
+    .finally(() => {
+      isRequestLoading.value = false
+    })
 }
 
 function handleSubmitClick() {
@@ -474,8 +480,9 @@ watch(
                 </NButton>
                 <NButton
                   type="info"
-                  :disabled="formDisabled"
+                  :disabled="formDisabled || isRequestLoading"
                   @click="generateRandomForm"
+                  :loading="isRequestLoading"
                 >
                   随机填充表单
                 </NButton>

+ 11 - 11
src/views/data-show/data-table/index.vue

@@ -345,14 +345,6 @@ const paginationPrefix: PaginationProps['prefix'] = (info) => {
   )
 }
 
-const handleQueryClick = () => {
-  formRef.value?.validate((errors) => {
-    if (!errors) {
-      getUserList()
-    }
-  })
-}
-
 const dropdownOptions = reactive<DropdownProps>({
   x: 0,
   y: 0,
@@ -376,11 +368,15 @@ const dropdownOptions = reactive<DropdownProps>({
 })
 
 async function request(pageSize: number): Promise<{ data: UserInfo[]; total: number }> {
-  return fetch(`http://43.143.155.96:3000/api/faker/v2/diy?num=${pageSize}`, {
+  return fetch(`https://lithe-admin-serverless.vercel.app/api/faker?limit=${pageSize}`, {
     method: 'GET',
   }).then((res) => res.json())
 }
 
+function inputOnlyAllowNumber(value: string) {
+  return !value || /^\d+$/.test(value)
+}
+
 function createOrEditUser(data?: UserInfo) {
   const title = data ? '编辑数据' : '新增数据'
 
@@ -416,8 +412,12 @@ function createOrEditUser(data?: UserInfo) {
   })
 }
 
-function inputOnlyAllowNumber(value: string) {
-  return !value || /^\d+$/.test(value)
+const handleQueryClick = () => {
+  formRef.value?.validate((errors) => {
+    if (!errors) {
+      getUserList()
+    }
+  })
 }
 
 function handleDownloadCsvClick() {