feat:增加Docker部署
This commit is contained in:
6
Dockerfile
Normal file
6
Dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
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
|
||||
RUN chmod -R 755 /usr/share/nginx/html/
|
||||
23
nginx.conf
Normal file
23
nginx.conf
Normal file
@@ -0,0 +1,23 @@
|
||||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
index index.html;
|
||||
|
||||
server_name _;
|
||||
|
||||
location /food-hub/ {
|
||||
alias /usr/share/nginx/html/;
|
||||
try_files $uri $uri/ /food-hub/index.html;
|
||||
}
|
||||
|
||||
location /food-api/ {
|
||||
proxy_pass http://host.docker.internal:8083/;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
||||
@@ -4,45 +4,45 @@ import type { IStatsChart } from 'vue3-common/types'
|
||||
|
||||
export const addRecipeApi = (recipe: IRecipe): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/recipe',
|
||||
url: '/food-api/food/recipe',
|
||||
method: 'post',
|
||||
data: recipe
|
||||
})
|
||||
|
||||
export const updateRecipeApi = (id: number, recipe: IRecipe): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/recipe/${id}`,
|
||||
url: `/food-api/food/recipe/${id}`,
|
||||
method: 'put',
|
||||
data: recipe
|
||||
})
|
||||
|
||||
export const deleteRecipeApi = (id: number): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/recipe/${id}`,
|
||||
url: `/food-api/food/recipe/${id}`,
|
||||
method: 'DELETE'
|
||||
})
|
||||
|
||||
export const queryRecipeByIdApi = (id: number): Promise<IRecipe> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/recipe/${id}`,
|
||||
url: `/food-api/food/recipe/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const queryRecipeByUserApi = (id: number): Promise<IRecipe[]> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/recipe/user/${id}`,
|
||||
url: `/food-api/food/recipe/user/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const queryRecipeUserFavouriteApi = (): Promise<IRecipe[]> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/recipe/user/favourite',
|
||||
url: '/food-api/food/recipe/user/favourite',
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const queryRecipeApi = (query: IFoodQuery): Promise<IRecipe[]> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/recipe',
|
||||
url: '/food-api/food/recipe',
|
||||
method: 'get',
|
||||
params: { ...query }
|
||||
})
|
||||
@@ -50,101 +50,101 @@ export const queryRecipeApi = (query: IFoodQuery): Promise<IRecipe[]> =>
|
||||
export const queryRecipeByPageApi = (currentPage: number, pageSize: number,
|
||||
query: IFoodQuery): Promise<any> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/recipe/page',
|
||||
url: '/food-api/food/recipe/page',
|
||||
method: 'get',
|
||||
params: { currentPage, pageSize, ...query }
|
||||
})
|
||||
|
||||
export const queryFoodNameListApi = (): Promise<string[]> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/recipe/name',
|
||||
url: '/food-api/food/recipe/name',
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const addRecordApi = (record: IRecord): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/record',
|
||||
url: '/food-api/food/record',
|
||||
method: 'post',
|
||||
data: record
|
||||
})
|
||||
|
||||
export const updateRecordApi = (id: number, record: IRecord): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/record/${id}`,
|
||||
url: `/food-api/food/record/${id}`,
|
||||
method: 'put',
|
||||
data: record
|
||||
})
|
||||
|
||||
export const deleteRecordApi = (id: number): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/record/${id}`,
|
||||
url: `/food-api/food/record/${id}`,
|
||||
method: 'DELETE'
|
||||
})
|
||||
|
||||
export const addRecipeCommentApi = (id: number, content: string): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/recipe/${id}/comment`,
|
||||
url: `/food-api/food/recipe/${id}/comment`,
|
||||
method: 'post',
|
||||
params: { content }
|
||||
})
|
||||
|
||||
export const addRecipeLikeApi = (id: number): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/recipe/${id}/like`,
|
||||
url: `/food-api/food/recipe/${id}/like`,
|
||||
method: 'post'
|
||||
})
|
||||
|
||||
export const deleteRecipeLikeApi = (id: number): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/recipe/${id}/like`,
|
||||
url: `/food-api/food/recipe/${id}/like`,
|
||||
method: 'delete'
|
||||
})
|
||||
|
||||
export const addRecipeFavouriteApi = (id: number): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/recipe/${id}/favourite`,
|
||||
url: `/food-api/food/recipe/${id}/favourite`,
|
||||
method: 'post'
|
||||
})
|
||||
|
||||
export const deleteRecipeFavouriteApi = (id: number): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/food/recipe/${id}/favourite`,
|
||||
url: `/food-api/food/recipe/${id}/favourite`,
|
||||
method: 'delete'
|
||||
})
|
||||
|
||||
export const queryRecordApi = (startDate: string, endDate: string): Promise<IRecord[]> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/record',
|
||||
url: '/food-api/food/record',
|
||||
method: 'get',
|
||||
params: { startDate, endDate }
|
||||
})
|
||||
|
||||
export const queryCategoryApi = (): Promise<string[]> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/category',
|
||||
url: '/food-api/food/category',
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const queryStatsApi = (): Promise<IStats> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/stats',
|
||||
url: '/food-api/food/stats',
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const queryRecordStatsApi = (): Promise<IStatsChart[]> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/stats/record',
|
||||
url: '/food-api/food/stats/record',
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const queryCategoryStatsApi = (): Promise<IStatsChart[]> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/stats/category',
|
||||
url: '/food-api/food/stats/category',
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const queryRankStatsApi = (): Promise<IStatsChart[]> =>
|
||||
cloudService({
|
||||
url: '/food-service/food/stats/rank',
|
||||
url: '/food-api/food/stats/rank',
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
@@ -3,51 +3,51 @@ import type { IMoment } from '@/types/food'
|
||||
|
||||
export const addMomentApi = (moment: IMoment): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: '/food-service/moment',
|
||||
url: '/food-api/moment',
|
||||
method: 'post',
|
||||
data: moment
|
||||
})
|
||||
|
||||
export const updateMomentApi = (id: number, moment: IMoment): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/moment/${id}`,
|
||||
url: `/food-api/moment/${id}`,
|
||||
method: 'put',
|
||||
data: moment
|
||||
})
|
||||
|
||||
export const deleteMomentApi = (id: number): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/moment/${id}`,
|
||||
url: `/food-api/moment/${id}`,
|
||||
method: 'delete'
|
||||
})
|
||||
|
||||
export const queryMomentListApi = (): Promise<IMoment[]> =>
|
||||
cloudService({
|
||||
url: '/food-service/moment',
|
||||
url: '/food-api/moment',
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const queryMomentByIdApi = (id: number): Promise<IMoment[]> =>
|
||||
cloudService({
|
||||
url: `/food-service/moment/${id}`,
|
||||
url: `/food-api/moment/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const addMomentCommentApi = (id: number, content: string): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/moment/${id}/comment`,
|
||||
url: `/food-api/moment/${id}/comment`,
|
||||
method: 'post',
|
||||
params: { content }
|
||||
})
|
||||
|
||||
export const addMomentLikeApi = (id: number): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/moment/${id}/like`,
|
||||
url: `/food-api/moment/${id}/like`,
|
||||
method: 'post'
|
||||
})
|
||||
|
||||
export const deleteMomentLikeApi = (id: number): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/moment/${id}/like`,
|
||||
url: `/food-api/moment/${id}/like`,
|
||||
method: 'delete'
|
||||
})
|
||||
|
||||
@@ -3,14 +3,14 @@ import type { ISession } from '@/types/auth'
|
||||
|
||||
export const loginApi = (username: string, password: string): Promise<ISession> =>
|
||||
cloudService({
|
||||
url: '/food-service/session',
|
||||
url: '/food-api/session',
|
||||
method: 'post',
|
||||
params: { username, password }
|
||||
})
|
||||
|
||||
export const logoutApi = (username: string): Promise<ISession> =>
|
||||
cloudService({
|
||||
url: '/food-service/session',
|
||||
url: '/food-api/session',
|
||||
method: 'delete',
|
||||
params: { username }
|
||||
})
|
||||
|
||||
@@ -3,20 +3,20 @@ import type { ISession, IUser } from '@/types/auth'
|
||||
|
||||
export const registerApi = (username: string, password: string): Promise<ISession> =>
|
||||
cloudService({
|
||||
url: '/food-service/user',
|
||||
url: '/food-api/user',
|
||||
method: 'post',
|
||||
params: { username, password }
|
||||
})
|
||||
|
||||
export const queryUserApi = (id: number): Promise<IUser> =>
|
||||
cloudService({
|
||||
url: `/food-service/user/${id}`,
|
||||
url: `/food-api/user/${id}`,
|
||||
method: 'get'
|
||||
})
|
||||
|
||||
export const updateUserApi = (id: number, user: IUser): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/food-service/user/${id}`,
|
||||
url: `/food-api/user/${id}`,
|
||||
method: 'put',
|
||||
data: user
|
||||
})
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* 文件服务器地址
|
||||
*/
|
||||
export const fileServiceUrl = '/food-service/file'
|
||||
export const fileServiceUrl = '/food-api/file'
|
||||
|
||||
/**
|
||||
* 服务器文件路径根地址
|
||||
*/
|
||||
export const serviceFileRootPath = '/food-service/'
|
||||
export const serviceFileRootPath = '/food-api/'
|
||||
|
||||
/**
|
||||
* 获取assets静态资源
|
||||
|
||||
@@ -12,7 +12,7 @@ export default defineConfig({
|
||||
}
|
||||
}
|
||||
},
|
||||
base: './',
|
||||
base: '/food-hub/',
|
||||
resolve: {
|
||||
// 配置路径别名
|
||||
alias: {
|
||||
@@ -20,12 +20,11 @@ export default defineConfig({
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 5175,
|
||||
proxy: {
|
||||
'/food-service': {
|
||||
target: 'http://127.0.0.1:8100',
|
||||
'/food-api': {
|
||||
target: 'http://127.0.0.1:8083',
|
||||
changeOrigin: true,
|
||||
rewrite: (item) => item.replace(/^\/food-service/, '')
|
||||
rewrite: (item) => item.replace(/^\/food-api/, '')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user