lesion 1 year ago
parent
commit
ddc0b07f7d
4 changed files with 39 additions and 39 deletions
  1. 1 1
      components/cosetta.vue
  2. 2 2
      package.json
  3. 1 1
      pages/c/[cosetta].vue
  4. 35 35
      server/services/upload-service.ts

+ 1 - 1
components/cosetta.vue

@@ -8,7 +8,7 @@ const { cosetta } = defineProps({
 </script>
 <template>
   <div class="rounded overflow-hidden shadow-lg flex flex-col justify-between">
-    <img class="object-cover w-full h-48" :src="`/imgs/${cosetta.images[0]}`" alt="Mountain">
+    <img class="object-cover w-full h-48" :src="`/${cosetta.images[0]}`" alt="Mountain">
     <div class="px-6 py-4 grow">
       <nuxt-link :to="`/c/${cosetta.uuid}`">
         <h2 class="text-pink-500 card-title hover:underline uppercase mb-2 line-clamp-2" v-text='cosetta.name' />

+ 2 - 2
package.json

@@ -7,11 +7,11 @@
     "preview": "nuxt preview"
   },
   "devDependencies": {
-    "@iconify/json": "^2.1.94",
+    "@iconify/json": "^2.1.96",
     "@nuxtjs/svg": "^0.4.0",
     "@nuxtjs/tailwindcss": "^5.3.2",
     "daisyui": "^2.24.0",
-    "nuxt": "3.0.0-rc.6",
+    "nuxt": "npm:nuxt3@latest",
     "unplugin-icons": "^0.14.8",
     "unplugin-vue-components": "^0.22.4"
   },

+ 1 - 1
pages/c/[cosetta].vue

@@ -15,7 +15,7 @@ const addComment = async () => {
   <section class="bg-white py-8">
 
     <div class="container mx-auto pt-4 pb-12">
-      <img v-if='cosetta.images' :src="`/imgs/${cosetta.images[0]}`" />
+      <img v-if='cosetta.images' :src="`/${cosetta.images[0]}`" />
       <h2 class="text-pink-500 text-2xl card-title uppercase mb-2 divider" v-text='cosetta.name' />
       <div class="px-6 pt-4 pb-2">
         <span v-for='tag in cosetta.tags' :key='tag'

+ 35 - 35
server/services/upload-service.ts

@@ -5,42 +5,42 @@ import { v4 } from 'uuid'
 import path from 'path'
 
 export const uploadService = () => {
-	let folderPath = './imgs/'
-	if (!fs.existsSync(folderPath)) {
-		fs.mkdirSync(folderPath, { recursive: true })
-	}
-	const { limits: templateLimits }: Options = {
-		limits: {
-			files: 1,
-			fieldNameSize: 400,
-			fileSize: 80 * 1024 * 1024,
-		},
-	};
+  let folderPath = './public/'
+  if (!fs.existsSync(folderPath)) {
+    fs.mkdirSync(folderPath, { recursive: true })
+  }
+  const { limits: templateLimits }: Options = {
+    limits: {
+      files: 1,
+      fieldNameSize: 400,
+      fileSize: 80 * 1024 * 1024,
+    },
+  };
 
-	const { filename }: multer.DiskStorageOptions = {
-		filename: (_req, file, cb) => {
-			const type = path.extname(file.originalname)
-			cb(null, v4() + type)
-		}
-	}
+  const { filename }: multer.DiskStorageOptions = {
+    filename: (_req, file, cb) => {
+      const type = path.extname(file.originalname)
+      cb(null, v4() + type)
+    }
+  }
 
-	const generateHandler = () => {
-		try {
-			const options: Options = {
-				limits: {
-					...templateLimits,
-				},
-				storage: multer.diskStorage({
-					filename,
-					destination: folderPath
-				}),
-			};
+  const generateHandler = () => {
+    try {
+      const options: Options = {
+        limits: {
+          ...templateLimits,
+        },
+        storage: multer.diskStorage({
+          filename,
+          destination: folderPath
+        }),
+      };
 
-			return multer(options).single('imgs');
-		} catch (e) {
-			console.error('Upload error', e)
-			throw e;
-		}
-	};
-	return { generateHandler };
+      return multer(options).single('imgs');
+    } catch (e) {
+      console.error('Upload error', e)
+      throw e;
+    }
+  };
+  return { generateHandler };
 };