diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5f12c44 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM nginx:1.27.0 +COPY dist/ /usr/share/nginx/html/ +COPY nginx.conf /etc/nginx/conf.d/default.conf +RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime +RUN echo 'Asia/Shanghai' > /etc/timezone diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..193f933 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +name: + sweet-hut + +services: + blog-ui: + image: cxx/blog-ui:0.0.1 + container_name: blog-ui + ports: + - "82:80" + extra_hosts: + - "host.docker.internal:host-gateway" + networks: + - sweet-hut + restart: always + +networks: + sweet-hut: + driver: bridge diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..a69c3b1 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,22 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + + root /usr/share/nginx/html; + index index.html; + + server_name _; + + location /blog/ { + alias /usr/share/nginx/html/; + try_files $uri $uri/ /blog/index.html; + } + + location /blog-api/ { + proxy_pass http://127.0.0.1:8082/; + } + + location / { + try_files $uri $uri/ =404; + } +} diff --git a/package.json b/package.json index 27dae57..3eabb01 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.1", "scripts": { "dev": "vite", - "build": "vue-tsc -b && vite build", + "build": "vite build", "preview": "vite preview" }, "dependencies": { diff --git a/src/apis/blog.ts b/src/apis/blog.ts index 1aa7210..a50244c 100644 --- a/src/apis/blog.ts +++ b/src/apis/blog.ts @@ -1,19 +1,19 @@ import { cloudService } from './index' -import { IBlog, IBlogCategory, IBlogComment, IBlogStats, IBlogVisit, INewBlog, IQueryBlog } from '@/types/blog' +import { IBlog, IBlogCategory, IBlogComment, IBlogStats, IQueryBlog } from '@/types/blog' import qs from 'qs' import { IPageRecord } from '@/types' export const queryBlogApi = (currentPage: number, pageSize: number): Promise> => cloudService({ - url: '/blog-service/blog/page', + url: '/blog-api/blog/page', method: 'get', params: { currentPage, pageSize } }) export const queryBlogByConditionApi = (query: IQueryBlog): Promise => cloudService({ - url: '/blog-service/blog/condition', + url: '/blog-api/blog/condition', method: 'get', params: query, paramsSerializer: (params) => { @@ -23,85 +23,37 @@ export const queryBlogByConditionApi = (query: IQueryBlog): Promise => export const queryBlogByIdApi = (id: number): Promise => cloudService({ - url: `/blog-service/blog/content/${id}`, + url: `/blog-api/blog/content/${id}`, method: 'get' }) export const queryBlogCategoryApi = (): Promise => cloudService({ - url: '/blog-service/blog/category', + url: '/blog-api/blog/category', method: 'get' }) export const queryBlogStatsApi = (): Promise => cloudService({ - url: '/blog-service/blog/stats', + url: '/blog-api/blog/stats', method: 'get' }) export const queryLatestBlogApi = (): Promise => cloudService({ - url: '/blog-service/blog/latest', + url: '/blog-api/blog/latest', method: 'get' }) export const queryBlogCommentApi = (blogId: number): Promise => cloudService({ - url: `/blog-service/blog/comment/${blogId}`, + url: `/blog-api/blog/comment/${blogId}`, method: 'get' }) export const addBlogCommentApi = (blogComment: IBlogComment): Promise => cloudService({ - url: '/blog-service/blog/comment', + url: '/blog-api/blog/comment', method: 'put', data: blogComment }) - -export const queryAdminBlogApi = (currentPage: number, - pageSize: number): Promise> => - cloudService({ - url: '/admin-service/blog-manage/page', - method: 'get', - params: { currentPage, pageSize } - }) - -export const queryAdminBlogByIdApi = (id: number): Promise => - cloudService({ - url: `/admin-service/blog-manage/content/${id}`, - method: 'get' - }) - -export const queryAdminBlogCategoryApi = (): Promise => - cloudService({ - url: '/admin-service/blog-manage/category', - method: 'get' - }) - -export const addBlogApi = (blog: INewBlog): Promise => - cloudService({ - url: '/admin-service/blog-manage', - method: 'post', - data: blog - }) - -export const updateBlogApi = (id: number, blog: INewBlog): Promise => - cloudService({ - url: `/admin-service/blog-manage/${id}`, - method: 'put', - data: blog - }) - -export const deleteBlogApi = (id: number): Promise => - cloudService({ - url: `/admin-service/blog-manage/${id}`, - method: 'DELETE' - }) - -export const queryBlogVisitApi = (currentPage: number, - pageSize: number): Promise> => - cloudService({ - url: '/admin-service/blog-manage/visit', - method: 'get', - params: { currentPage, pageSize } - }) diff --git a/src/components/Archive/BlogArchive.vue b/src/components/Archive/BlogArchive.vue index 4a54eb5..fe13a31 100644 --- a/src/components/Archive/BlogArchive.vue +++ b/src/components/Archive/BlogArchive.vue @@ -53,7 +53,7 @@ const changeDateEvent = async (value: Date) => { */ const viewBlogClick = async (index: number) => { const blogId = blogStore.blogList[index].id - await router.push({ name: 'BlogDetail', params: { id: blogId } }) + await router.push({ name: 'DetailId', params: { id: blogId } }) } diff --git a/src/components/Category/BlogCategory.vue b/src/components/Category/BlogCategory.vue index 1373811..c441ff7 100644 --- a/src/components/Category/BlogCategory.vue +++ b/src/components/Category/BlogCategory.vue @@ -31,7 +31,7 @@ onMounted(() => { * @param name 类别名称 */ const viewBlogCategoryClick = async (name: string) => { - await router.push({ name: 'BlogCategoryName', params: { name } }) + await router.push({ name: 'CategoryName', params: { name } }) } diff --git a/src/components/Category/BlogCategoryDetail.vue b/src/components/Category/BlogCategoryDetail.vue index 4790e9e..4fedcc7 100644 --- a/src/components/Category/BlogCategoryDetail.vue +++ b/src/components/Category/BlogCategoryDetail.vue @@ -32,7 +32,7 @@ onMounted(async () => { const viewBlogClick = async (index: number) => { const blogId = blogStore.blogList[index].id - await router.push({ name: 'BlogDetailId', params: { id: blogId } }) + await router.push({ name: 'DetailId', params: { id: blogId } }) } diff --git a/src/components/Content/BlogOverview.vue b/src/components/Content/BlogOverview.vue index 5725666..0ce4876 100644 --- a/src/components/Content/BlogOverview.vue +++ b/src/components/Content/BlogOverview.vue @@ -48,7 +48,7 @@ onMounted(async () => { */ const readBlogClick = async (index: number) => { const blogId = blogStore.blogList[index].id - await router.push({ name: 'BlogDetailId', params: { id: blogId } }) + await router.push({ name: 'DetailId', params: { id: blogId } }) } /** diff --git a/src/layout/components/Sidebar/BlogMenu.vue b/src/layout/components/Sidebar/BlogMenu.vue index 2dc1405..4c5899e 100644 --- a/src/layout/components/Sidebar/BlogMenu.vue +++ b/src/layout/components/Sidebar/BlogMenu.vue @@ -1,17 +1,17 @@