Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wangrui06 committed Apr 8, 2024
1 parent 0d1df32 commit 1c60c66
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ logs
.env.*
!.env.example

assets/upload
assets/upload/*
39 changes: 39 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Nuxt 3 builder
FROM node:lts as builder

WORKDIR /app

COPY package*.json ./
COPY prisma ./prisma

# 安装依赖
RUN npm install

# 生成Prisma客户端
RUN npx prisma generate


# 构建Nuxt应用
RUN npm run build

# Nuxt 3 production
FROM node:lts

WORKDIR /app

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

RUN npm init -y
RUN npm install prisma --save-dev

# 运行数据库迁移
RUN npx prisma migrate deplpoy

RUN mkdir /app/assets/upload

ENV NODE_ENV=production

EXPOSE 3000

CMD [ "node", ".output/server/index.mjs" ]
1 change: 0 additions & 1 deletion components/FancyBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const props = defineProps({
const container = ref(null);
onMounted(() => {
console.log(container.value.children)
Array.from(container.value.children).map((el) => {
el.setAttribute('data-fancybox', 'gallery');
});
Expand Down
6 changes: 3 additions & 3 deletions components/HeaderImg.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<img src="~/assets/img/back.svg" class="w-10 h-10 px-1 py-2 cursor-pointer" alt="返回" title="返回"
@click="navigateTo('/')">
</div>
<NuxtImg class="w-full h-[250px]"
<NuxtImg class="w-full "
:src="res?.data?.coverUrl!"
alt=""/>
<div class="absolute right-2 bottom-[-40px]">
<div class="flex flex-col">
<div class="flex flex-row items-center gap-4">
<div class="flex flex-col ">
<div class="flex flex-row items-center gap-4 justify-end">
<div class="text-lg font-bold text-white">Jerry</div>
<NuxtImg :src="res?.data?.avatarUrl!"
class="w-[70px] h-[70px] rounded-xl" />
Expand Down
Binary file removed data.sqlite
Binary file not shown.
1 change: 0 additions & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@
import { Toaster } from '@/components/ui/sonner'
import {Sun,MoonStar} from 'lucide-vue-next'
const colorMode = useColorMode()
console.log(colorMode.value)
</script>
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export default defineNuxtConfig({
},
},
image: {
dir: "assets/upload"
dir: `${process.cwd()}/assets/upload`
}
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"type": "module",
"scripts": {
"migrate": "npx prisma migrate deploy",
"build": "nuxt build",
"dev": "nuxt dev --host 0.0.0.0",
"generate": "nuxt generate",
Expand Down
2 changes: 2 additions & 0 deletions prisma/migrations/20240408052531_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
insert into User(username,nickname,password,avatarUrl,slogan,coverUrl,createdAt,updatedAt) values ('admin','Jerry','$2a$10$3n9B1VzOMK7gWLkM7XeM1OMHV5x4EDc8hkePyk/wrY0YAT6KPOiW2
','https://ui-avatars.com/api/?name=admin','时间不在于你拥有多少,而在于你怎样使用。','https://s2.loli.net/2024/04/08/htPAFmRJ9eZlHwq.png',datetime('now'),datetime('now'));
2 changes: 2 additions & 0 deletions prisma/migrations/20240408053046_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This is an empty migration.
update User set avatarUrl = 'https://p.sda1.dev/16/d5e9d23595a62cae6ffbc8984c109cd2/face.png' where id = 1;
2 changes: 1 addition & 1 deletion server/api/files/upload.post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default defineEventHandler(async (event) => {
const filetype = file.type.split("/")[1];

const filename = short.generate() + "." + filetype;
await fs.writeFile(`D:\\projects\\moments\\assets\\upload\\${filename}`, file.data);
await fs.writeFile(`${process.cwd()}/assets/upload/${filename}`, file.data);

return {
success: true,
Expand Down

0 comments on commit 1c60c66

Please sign in to comment.