diff --git a/yanzhu-ui-vue3/index.html b/yanzhu-ui-vue3/index.html index de0bd253..82e0e24f 100644 --- a/yanzhu-ui-vue3/index.html +++ b/yanzhu-ui-vue3/index.html @@ -8,6 +8,9 @@ name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" /> + 数字建安施工 + diff --git a/yanzhu-ui-vue3/make.cjs b/yanzhu-ui-vue3/make.cjs new file mode 100644 index 00000000..ea1de21a --- /dev/null +++ b/yanzhu-ui-vue3/make.cjs @@ -0,0 +1,55 @@ +const fs = require("fs"); +const path = require("path"); + +const config = [ + { + name: "app1", + title: "建安施工管理平台", + dirPath: "app1", + }, + { + name: "app2", + title: "数字项管+", + dirPath: "app2", + }, +]; + +config.forEach((item) => { + // 在 dist 目录下创建 app 目录 + const appDirPath = path.join(__dirname, "dist", item.dirPath); + fs.mkdir(appDirPath, { recursive: true }, (err) => { + if (err) { + console.error("创建目录时出错:", err); + return; + } + console.log("目录创建成功或已存在"); + }); + const xdAppPath = path.join(__dirname, "dist", "xd"); + // 源文件路径 + const sourceFilePath = path.join(xdAppPath, "index.html"); + // 目标文件路径 + const targetFilePath = path.join(appDirPath, "index.html"); + + // 读取源文件内容 + fs.readFile(sourceFilePath, "utf8", (err, data) => { + if (err) { + console.error("读取文件时出错:", err); + return; + } + + // 替换文本 + const newData = data + .replace(/数字建安施工/g, item.title) + .replaceAll(`src="./`, `src = "/xd/`) + .replaceAll(`href="./`, `href = "/xd/`); + + // 将替换后的内容写入目标文件 + fs.writeFile(targetFilePath, newData, "utf8", (err) => { + if (err) { + console.error("写入文件时出错:", err); + return; + } + console.log("文件复制并替换成功"); + }); + }); +}); diff --git a/yanzhu-ui-vue3/package.json b/yanzhu-ui-vue3/package.json index 61f56ba6..4c7940a5 100644 --- a/yanzhu-ui-vue3/package.json +++ b/yanzhu-ui-vue3/package.json @@ -8,8 +8,9 @@ "scripts": { "dev": "vite", "dev:prod": "vite --mode production", - "build:prod": "vite build", + "build:prod": "vite build && npm run pkg", "build:stage": "vite build --mode staging", + "pkg":"node make.cjs", "preview": "vite preview" }, "repository": { diff --git a/yanzhu-ui-vue3/src/layout/components/Sidebar/Logo.vue b/yanzhu-ui-vue3/src/layout/components/Sidebar/Logo.vue index 67582d0d..724e5efa 100644 --- a/yanzhu-ui-vue3/src/layout/components/Sidebar/Logo.vue +++ b/yanzhu-ui-vue3/src/layout/components/Sidebar/Logo.vue @@ -1,16 +1,16 @@ \ No newline at end of file diff --git a/yanzhu-ui-vue3/src/settings.js b/yanzhu-ui-vue3/src/settings.js index 10e1db41..b77783e9 100644 --- a/yanzhu-ui-vue3/src/settings.js +++ b/yanzhu-ui-vue3/src/settings.js @@ -2,11 +2,11 @@ export default { /** * 网页标题 */ - title: import.meta.env.VITE_APP_TITLE, + title: window.yanzhuAppTitle, /** * 侧边栏主题 深色主题theme-dark,浅色主题theme-light */ - sideTheme: 'theme-dark', + sideTheme: "theme-dark", /** * 是否系统布局配置 */ @@ -43,5 +43,5 @@ export default { * The default is only used in the production env * If you want to also use it in dev, you can pass ['production', 'development'] */ - errorLog: 'production' -} + errorLog: "production", +}; diff --git a/yanzhu-ui-vue3/src/views/login.vue b/yanzhu-ui-vue3/src/views/login.vue index 80438090..ef9ba0dc 100644 --- a/yanzhu-ui-vue3/src/views/login.vue +++ b/yanzhu-ui-vue3/src/views/login.vue @@ -1,289 +1,294 @@ diff --git a/yanzhu-ui-vue3/vite.config.js b/yanzhu-ui-vue3/vite.config.js index 8ee0ab98..1fc36b09 100644 --- a/yanzhu-ui-vue3/vite.config.js +++ b/yanzhu-ui-vue3/vite.config.js @@ -1,27 +1,27 @@ -import { defineConfig, loadEnv } from 'vite' -import path from 'path' -import createVitePlugins from './vite/plugins' +import { defineConfig, loadEnv } from "vite"; +import path from "path"; +import createVitePlugins from "./vite/plugins"; // https://vitejs.dev/config/ export default defineConfig(({ mode, command }) => { - const env = loadEnv(mode, process.cwd()) - const { VITE_APP_ENV } = env + const env = loadEnv(mode, process.cwd()); + const { VITE_APP_ENV } = env; return { // 部署生产环境和开发环境下的URL。 // 默认情况下,vite 会假设你的应用是被部署在一个域名的根路径上 // 例如 https://www.ruoyi.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.ruoyi.vip/admin/,则设置 baseUrl 为 /admin/。 - base: VITE_APP_ENV === 'production' ? '/xd/' : '/xd/', - plugins: createVitePlugins(env, command === 'build'), + base: VITE_APP_ENV === "production" ? "/xd/" : "/xd/", + plugins: createVitePlugins(env, command === "build"), resolve: { // https://cn.vitejs.dev/config/#resolve-alias alias: { // 设置路径 - '~': path.resolve(__dirname, './'), + "~": path.resolve(__dirname, "./"), // 设置别名 - '@': path.resolve(__dirname, './src') + "@": path.resolve(__dirname, "./src"), }, // https://cn.vitejs.dev/config/#resolve-extensions - extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'] + extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"], }, // vite 相关配置 server: { @@ -30,56 +30,59 @@ export default defineConfig(({ mode, command }) => { open: true, proxy: { "/prod-api": { - //target: "http://localhost:8080", - target: 'http://62.234.3.186', - changeOrigin: true, - pathRewrite: { - "^/prod-api": "/", - }, - }, - // https://cn.vitejs.dev/config/#server-proxy - '/dev-api': { - target: 'http://localhost:8080', + //target: "http://localhost:8080", + target: "http://62.234.3.186", changeOrigin: true, - rewrite: (p) => p.replace(/^\/dev-api/, '') + pathRewrite: { + "^/prod-api": "/", + }, }, - '/statics': { - target: VITE_APP_ENV === 'production'?'http://62.234.3.186':`http://localhost:9300`, + // https://cn.vitejs.dev/config/#server-proxy + "/dev-api": { + target: "http://localhost:8080", + changeOrigin: true, + rewrite: (p) => p.replace(/^\/dev-api/, ""), + }, + "/statics": { + target: + VITE_APP_ENV === "production" + ? "http://62.234.3.186" + : `http://localhost:9300`, //target: 'http://62.234.3.186', changeOrigin: true, pathRewrite: { "^/statics": "/", }, }, - - } + }, }, //fix:error:stdin>:7356:1: warning: "@charset" must be the first rule in the file css: { postcss: { plugins: [ { - postcssPlugin: 'internal:charset-removal', + postcssPlugin: "internal:charset-removal", AtRule: { charset: (atRule) => { - if (atRule.name === 'charset') { + if (atRule.name === "charset") { atRule.remove(); } - } - } - } - ] - } - }, + }, + }, + }, + ], + }, + }, optimizeDeps: { - include: ['@/lib/vform/designer.umd.js'] //此处路径必须跟main.js中import路径完全一致! - }, - build: { + include: ["@/lib/vform/designer.umd.js"], //此处路径必须跟main.js中import路径完全一致! + }, + build: { + outDir: "dist/xd/", /* 其他build生产打包配置省略 */ //... commonjsOptions: { - include: /node_modules|lib/ //这里记得把lib目录加进来,否则生产打包会报错!! - } - } - } -}) + include: /node_modules|lib/, //这里记得把lib目录加进来,否则生产打包会报错!! + }, + }, + }; +});