diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..415d6a2 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +node_modules +.git +.gitignore +Dockerfile +docker-compose.yml +README.md +.vs \ No newline at end of file diff --git a/.env.development b/.env.development deleted file mode 100644 index c3ed821..0000000 --- a/.env.development +++ /dev/null @@ -1,4 +0,0 @@ -VITE_API_BASEURL = "https://ibms-Empower-api.production.mjmtech.com.tw" -VITE_FILE_API_BASEURL = "https://ibms-Empower.production.mjmtech.com.tw" -VITE_MQTT_BASEURL = "wss://mqttwss.mjm-staging.developers-homelab.net" -VITE_FORGE_BASEURL = "https://ibms-Empower.production.mjmtech.com.tw/dist" \ No newline at end of file diff --git a/.env.production b/.env.production deleted file mode 100644 index c3ed821..0000000 --- a/.env.production +++ /dev/null @@ -1,4 +0,0 @@ -VITE_API_BASEURL = "https://ibms-Empower-api.production.mjmtech.com.tw" -VITE_FILE_API_BASEURL = "https://ibms-Empower.production.mjmtech.com.tw" -VITE_MQTT_BASEURL = "wss://mqttwss.mjm-staging.developers-homelab.net" -VITE_FORGE_BASEURL = "https://ibms-Empower.production.mjmtech.com.tw/dist" \ No newline at end of file diff --git a/.env.staging b/.env.staging deleted file mode 100644 index 3a51cfe..0000000 --- a/.env.staging +++ /dev/null @@ -1,3 +0,0 @@ -VITE_API_BASEURL = "http://220.132.206.5:8008" -VITE_FILE_API_BASEURL = "http://220.132.206.5:8085/file" -VITE_FORGE_BASEURL = "http://localhost:5173" \ No newline at end of file diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index b6565d2..0000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -* text=auto -*.html text eol=lf \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..23cc02a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ + # 使用 Node.js 作為基礎映像 +FROM node:18-alpine AS builder + +# 設定工作目錄 +WORKDIR /app + +# 複製 package.json 和 package-lock.json (或 yarn.lock) 到工作目錄 +COPY package*.json ./ + +# 安裝依賴 +RUN npm install --legacy-peer-deps + +# 複製所有檔案到工作目錄 +COPY . . + +# 清理緩存並重新構建 +RUN npm cache clean --force +RUN rm -rf node_modules +RUN npm install --legacy-peer-deps + +# 構建前端應用 (如果需要) +RUN npm run build --omit=dev + +# 使用一個更小的映像來提供靜態文件 (例如 Nginx) +FROM nginx:alpine + +# 將構建好的靜態檔案複製到 Nginx 的預設目錄 +COPY --from=builder /app/dist /usr/share/nginx/html + +# (可選) 複製自定義 Nginx 設定檔 +# COPY nginx.conf /etc/nginx/conf.d/default.conf + +# 暴露 Nginx 預設的 80 端口 +EXPOSE 80 + +# 2025-08-29 說明 +LABEL changelog="2025-08-29: 打包測試。" + +# Nginx 已經預設啟動,所以不需要 CMD 指令 +COPY docker-entrypoint.sh /docker-entrypoint.sh +RUN chmod +x /docker-entrypoint.sh +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 0000000..21d4d1f --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh +echo "window.env = { VITE_API_BASEURL: '${VITE_API_BASEURL}', VITE_FILE_API_BASEURL: '${VITE_FILE_API_BASEURL}', VITE_APP_TITLE: '${VITE_APP_TITLE}' };" > /usr/share/nginx/html/env.js +sed -i "s|.*|${VITE_APP_TITLE}|g" /usr/share/nginx/html/index.html +sed -i "s| 新創賦能 + diff --git a/src/apis/account/index.js b/src/apis/account/index.js index 210b375..f2f8454 100644 --- a/src/apis/account/index.js +++ b/src/apis/account/index.js @@ -10,7 +10,7 @@ import { DELETE_ACCOUNT_USER_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getAccountUserList = async (search_condition = {}) => { const res = await instance.post(GET_ACCOUNT_USERLIST_API, search_condition); diff --git a/src/apis/alert/index.js b/src/apis/alert/index.js index d2f19e3..1e6a848 100644 --- a/src/apis/alert/index.js +++ b/src/apis/alert/index.js @@ -23,7 +23,7 @@ import { POST_ALERT_MQTT_REFRESH, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getAlertFormId = async (uuid) => { const res = await instance.post(GET_ALERT_FORMID_API, uuid); diff --git a/src/apis/asset/index.js b/src/apis/asset/index.js index e124482..adb52d1 100644 --- a/src/apis/asset/index.js +++ b/src/apis/asset/index.js @@ -28,7 +28,7 @@ import { POST_ASSET_ELEC_SETTING_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; import { object } from "yup"; export const getAssetMainList = async (building_guid) => { diff --git a/src/apis/building/index.js b/src/apis/building/index.js index 0c3579e..e726f1e 100644 --- a/src/apis/building/index.js +++ b/src/apis/building/index.js @@ -7,7 +7,7 @@ import { GET_ALL_DEVICE_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getBuildings = async () => { const res = await instance.post(GET_BUILDING_API); diff --git a/src/apis/dashboard/index.js b/src/apis/dashboard/index.js index b6bc297..7c44474 100644 --- a/src/apis/dashboard/index.js +++ b/src/apis/dashboard/index.js @@ -13,7 +13,7 @@ import { GET_DASHBOARD_ALARMOPERATION_INFO_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getDashboardInit = async (page_type = "SR") => { const res = await instance.post(GET_DASHBOARD_INIT_API, { diff --git a/src/apis/energy/index.js b/src/apis/energy/index.js index b739a40..dfaaab0 100644 --- a/src/apis/energy/index.js +++ b/src/apis/energy/index.js @@ -18,7 +18,7 @@ import { POST_TIME_ELEC_API, } from "./api"; import instance, { fileInstance } from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; import downloadExcel from "@/util/downloadExcel"; export const getRealTimeData = async () => { diff --git a/src/apis/forge/index.js b/src/apis/forge/index.js index d13d4bb..1100b39 100644 --- a/src/apis/forge/index.js +++ b/src/apis/forge/index.js @@ -1,6 +1,6 @@ import instance from "@/util/request"; import { GET_FORGETOKEN_API, GET_FORGEURN_API } from "./api"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getUrn = async () => { const res = await instance.post(GET_FORGEURN_API); diff --git a/src/apis/graph/api.js b/src/apis/graph/api.js index 427ae7c..73f513b 100644 --- a/src/apis/graph/api.js +++ b/src/apis/graph/api.js @@ -1,5 +1,5 @@ // graph -const BASEURL = import.meta.env.VITE_API_BASEURL; +const BASEURL = window.env?.VITE_API_BASEURL; export const GET_GRAPH_SIDEBAR_API = `/GraphManage/GraphManageTreeList`; export const UPDATE_GRAPH_SIDEBAR_API = `/GraphManage/EditGraphManageTree`; diff --git a/src/apis/history/api.js b/src/apis/history/api.js index 64de717..c0fd361 100644 --- a/src/apis/history/api.js +++ b/src/apis/history/api.js @@ -1,5 +1,5 @@ // history -const BASEURL = import.meta.env.VITE_API_BASEURL; +const BASEURL = window.env?.VITE_API_BASEURL; export const GET_HISTORY_SIDEBAR_API = `/api/History/GetDeviceInfo`; export const GET_HISTORY_POINT_API = `/api/History/GetAllDevPoi`; export const GET_HISTORY_DATA_API = `/api/History/GetHistoryData`; diff --git a/src/apis/login/index.js b/src/apis/login/index.js index 2bb6498..f2bd9e6 100644 --- a/src/apis/login/index.js +++ b/src/apis/login/index.js @@ -1,6 +1,6 @@ import { POST_LOGIN } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export async function Login({ account, password }) { const res = await instance.post(POST_LOGIN, { diff --git a/src/apis/operation/index.js b/src/apis/operation/index.js index c7c9d1b..9a42892 100644 --- a/src/apis/operation/index.js +++ b/src/apis/operation/index.js @@ -12,7 +12,7 @@ import { DELETE_OPERATION_COMPANY_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; import dayjs from "dayjs"; export const getOperationRecord = async ({ diff --git a/src/apis/productSetting/index.js b/src/apis/productSetting/index.js index 1ed4d46..d811279 100644 --- a/src/apis/productSetting/index.js +++ b/src/apis/productSetting/index.js @@ -1,5 +1,5 @@ import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; import { POST_SETTING_POINT_API, GET_SETTING_TYPE_API, diff --git a/src/apis/system/index.js b/src/apis/system/index.js index 9756bdc..26d4448 100644 --- a/src/apis/system/index.js +++ b/src/apis/system/index.js @@ -7,7 +7,7 @@ import { POST_MQTT_TOPIC_STOP_API, } from "./api"; import instance from "@/util/request"; -import apihandler from "@/util/apihandler"; +import apihandler from "@/util/apiHandler"; export const getSystemFloors = async (building_tag, sub_system_tag) => { const res = await instance.post(GET_SYSTEM_FLOOR_LIST_API, { diff --git a/src/components/forge/Forge.vue b/src/components/forge/Forge.vue index e55b62d..49d4d58 100644 --- a/src/components/forge/Forge.vue +++ b/src/components/forge/Forge.vue @@ -1,7 +1,7 @@