Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wangrui06 committed Apr 9, 2024
1 parent e631fb9 commit 26c341b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ WORKDIR /app

ENV NODE_ENV=production
ENV DATABASE_URL="file:/app/data/db.sqlite"

RUN mkdir -p /app/data/upload
ENV UPLOAD_DIR="file:/app/.output/public/upload"

COPY --from=builder /app/.output /app/.output
COPY --from=builder /app/prisma /app/prisma
COPY --from=builder /app/start.sh /app/start.sh

RUN mkdir -p /app/.output/public/upload

RUN npm init -y
RUN npm install -g prisma
RUN chmod +x /app/start.sh
Expand Down
4 changes: 2 additions & 2 deletions components/MemoInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@
<iframe class="w-full h-[250px] my-2" v-if="bilibiliIfrUrl" :src="bilibiliIfrUrl" scrolling="no" border="0"
frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

<div class="grid grid-cols-3 my-1 gap-2" v-if="imgs && imgs.length > 0">
<div class="grid grid-cols-3 my-2 gap-2" v-if="imgs && imgs.length > 0">
<div v-for="(img, index) in imgs" :key="index" class="relative">
<NuxtImg format="avif,webp" :src="`/${img}`" class="rounded" />
<NuxtImg format="avif,webp" :src="`${img}`" class="rounded" />
<Trash2 color="#379d1b" :size="15" class="absolute top-1 right-1 cursor-pointer"
@click="imgs.splice(index, 1)" />
</div>
Expand Down
9 changes: 3 additions & 6 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
export default defineNuxtConfig({
devtools: { enabled: true },
modules: [
"@nuxtjs/tailwindcss",
"shadcn-nuxt",
"@nuxt/image",
"@nuxtjs/color-mode",
],
],
css: ["~/assets/css/index.css"],
colorMode: {
classSuffix: "",
Expand All @@ -28,8 +28,5 @@ export default defineNuxtConfig({
target: "esnext",
},
},
},
image: {
dir: "/app/data/upload",
},
}
});
8 changes: 5 additions & 3 deletions server/api/files/upload.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ export default defineEventHandler(async (event) => {
if (!file.type.startsWith("image")) {
return {
success: false,
message: "只支持上传图片文件",
message: "只支持上传图片文件",
filename: "",
};
}
const filetype = file.type.split("/")[1];

const filename = short.generate() + "." + filetype;
await fs.writeFile(`/app/data/upload/${filename}`, file.data);

const filepath = `${process.env.UPLOAD_DIR}/${filename}`;
await fs.writeFile(filepath, file.data);

return {
success: true,
filename,
filename: "/upload/" + filename,
message: "上传文件成功!",
};
});

0 comments on commit 26c341b

Please sign in to comment.