huangyan 1 рік тому
батько
коміт
c0befd76c9
2 змінених файлів з 17 додано та 17 видалено
  1. 16 16
      app/src/App.vue
  2. 1 1
      app/vite.config.js

+ 16 - 16
app/src/App.vue

@@ -545,9 +545,7 @@ const importFromJson = () => {
 //从服务器获取模板
 const importFromJsonServer = async (itemId) => {
   try {
-    const url = new URL(process.env.TEMPLATE_API_URL + 'template');
-    url.searchParams.append('name', itemId);
-    const response = await fetch(url, {
+    const response = await fetch(process.env.TEMPLATE_API_URL + `template?name=${itemId}`, {
       headers: {
         'Content-Type': 'application/json'
       }
@@ -575,12 +573,12 @@ let search = ref('')
 const searchTemplate = async () => {
   const url = window.location.href
   const uuid = getQueryParams(url)
-  console.log(uuid.uuid)
-  try {
-    const url = new URL(process.env.TEMPLATE_API_URL + 'search');
-    url.searchParams.append('name', search.value);
-    url.searchParams.append('uuid', uuid.uuid);
-    const response = await fetch(url, {
+  if (uuid.uuid!=undefined){
+    try {
+    // const url = new URL(process.env.TEMPLATE_API_URL + 'search');
+    // url.searchParams.append('name', search.value);
+    // url.searchParams.append('uuid', uuid.uuid);
+    const response = await fetch(process.env.TEMPLATE_API_URL + `search?name=${search.value}&uuid=${uuid.uuid}`, {
       headers: {
         'Content-Type': 'application/json',
       }
@@ -601,6 +599,10 @@ const searchTemplate = async () => {
   } catch (error) {
     ElNotification.warning('系统出错')
   }
+  }else{
+    ElNotification.warning('缺少必要参数')
+  }
+  
 }
 //删除
 const DeleteeFromJsonServer = async (itemId) => {
@@ -610,12 +612,10 @@ const DeleteeFromJsonServer = async (itemId) => {
     type: 'warning',
   }).then(async () => {
     try {
-      const urls = window.location.href
-      const uuid = getQueryParams(urls)
-      const url = new URL(process.env.TEMPLATE_API_URL + 'template');
-      url.searchParams.append('name', itemId);
-      url.searchParams.append('uuid', uuid.uuid);
-      const response = await fetch(url, {
+      // const urls = window.location.href
+      // const uuid = getQueryParams(urls)
+      // url.searchParams.append('uuid', uuid.uuid);
+      const response = await fetch(process.env.TEMPLATE_API_URL + `template?name=${itemId}`, {
         method: 'DELETE',
         headers: {
           'Content-Type': 'application/json'
@@ -770,7 +770,7 @@ const templateItems = async () => {
         ElNotification.success(jsonData.message)
         search.value = null
       } else {
-        ElNotification.warning('文件不存在')
+        ElNotification.warning('当前模板为空')
       }
     }
 

+ 1 - 1
app/vite.config.js

@@ -4,7 +4,7 @@ import AutoImport from 'unplugin-auto-import/vite'
 import Components from 'unplugin-vue-components/vite'
 import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
 
-const TEMPLATE_API_URL = 'api/';
+const TEMPLATE_API_URL = 'http://localhost:8080/api/';
 // https://vitejs.dev/config/
 export default defineConfig({
   base: '/',