修改后台生成代码
parent
95d37fab45
commit
fc82ce3ef9
|
@ -8,6 +8,9 @@
|
|||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
|
||||
/>
|
||||
<script>
|
||||
window.yanzhuAppTitle = "数字建安施工";
|
||||
</script>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<title>数字建安施工</title>
|
||||
<script
|
||||
|
@ -217,5 +220,8 @@
|
|||
</div>
|
||||
</div>
|
||||
<script type="module" src="/src/main.js"></script>
|
||||
<script>
|
||||
window.document.body.title = window.yanzhuAppTitle;
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -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("文件复制并替换成功");
|
||||
});
|
||||
});
|
||||
});
|
|
@ -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": {
|
||||
|
|
|
@ -21,13 +21,13 @@ import useSettingsStore from '@/store/modules/settings'
|
|||
defineProps({
|
||||
collapse: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
})
|
||||
|
||||
const title = import.meta.env.VITE_APP_TITLE;
|
||||
const settingsStore = useSettingsStore();
|
||||
const sideTheme = computed(() => settingsStore.sideTheme);
|
||||
const title = window.yanzhuAppTitle
|
||||
const settingsStore = useSettingsStore()
|
||||
const sideTheme = computed(() => settingsStore.sideTheme)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
@ -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",
|
||||
};
|
||||
|
|
|
@ -1,22 +1,26 @@
|
|||
<template>
|
||||
<div class="login main-login">
|
||||
<el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form">
|
||||
<h3 class="title">数字建安</h3>
|
||||
<h3 class="title">{{title}}</h3>
|
||||
<el-form-item prop="username" style="margin-top:60px;">
|
||||
<el-input v-model="loginForm.username" type="text" size="large" auto-complete="off" placeholder="账号">
|
||||
<template #prefix><svg-icon icon-class="user" class="el-input__icon input-icon" /></template>
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="user" class="el-input__icon input-icon" />
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="password">
|
||||
<el-input v-model="loginForm.password" type="password" size="large" auto-complete="off" placeholder="密码"
|
||||
@keyup.enter="handleLogin">
|
||||
<template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template>
|
||||
<el-input v-model="loginForm.password" type="password" size="large" auto-complete="off" placeholder="密码" @keyup.enter="handleLogin">
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="password" class="el-input__icon input-icon" />
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="code" v-if="captchaEnabled">
|
||||
<el-input v-model="loginForm.code" size="large" auto-complete="off" placeholder="验证码" style="width: 63%"
|
||||
@keyup.enter="handleLogin">
|
||||
<template #prefix><svg-icon icon-class="validCode" class="el-input__icon input-icon" /></template>
|
||||
<el-input v-model="loginForm.code" size="large" auto-complete="off" placeholder="验证码" style="width: 63%" @keyup.enter="handleLogin">
|
||||
<template #prefix>
|
||||
<svg-icon icon-class="validCode" class="el-input__icon input-icon" />
|
||||
</template>
|
||||
</el-input>
|
||||
<div class="login-code">
|
||||
<div class="login-code-bg"></div>
|
||||
|
@ -25,8 +29,7 @@
|
|||
</el-form-item>
|
||||
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
||||
<el-form-item style="width:100%;">
|
||||
<el-button :loading="loading" class="btn-login" size="large" type="primary" style="width:100%;"
|
||||
@click.prevent="handleLogin">
|
||||
<el-button :loading="loading" class="btn-login" size="large" type="primary" style="width:100%;" @click.prevent="handleLogin">
|
||||
<span v-if="!loading">登 录</span>
|
||||
<span v-else>登 录 中...</span>
|
||||
</el-button>
|
||||
|
@ -40,100 +43,102 @@
|
|||
<div class="el-login-footer">
|
||||
<span>Copyright © 2023-2024 陕西研筑信息科技有限公司 All Rights Reserved.</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getCodeImg } from "@/api/login";
|
||||
import Cookies from "js-cookie";
|
||||
import { encrypt, decrypt } from "@/utils/jsencrypt";
|
||||
import { getCodeImg } from '@/api/login'
|
||||
import Cookies from 'js-cookie'
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter();
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
let title = ref('系统登录')
|
||||
title.value = window.yanzhuAppTitle
|
||||
const loginForm = ref({
|
||||
username: "",
|
||||
password: "",
|
||||
username: '',
|
||||
password: '',
|
||||
rememberMe: false,
|
||||
code: "",
|
||||
uuid: ""
|
||||
});
|
||||
code: '',
|
||||
uuid: '',
|
||||
})
|
||||
|
||||
const loginRules = {
|
||||
username: [{ required: true, trigger: "blur", message: "请输入您的账号" }],
|
||||
password: [{ required: true, trigger: "blur", message: "请输入您的密码" }],
|
||||
code: [{ required: true, trigger: "change", message: "请输入验证码" }]
|
||||
};
|
||||
username: [{ required: true, trigger: 'blur', message: '请输入您的账号' }],
|
||||
password: [{ required: true, trigger: 'blur', message: '请输入您的密码' }],
|
||||
code: [{ required: true, trigger: 'change', message: '请输入验证码' }],
|
||||
}
|
||||
|
||||
const codeUrl = ref("");
|
||||
const loading = ref(false);
|
||||
const codeUrl = ref('')
|
||||
const loading = ref(false)
|
||||
// 验证码开关
|
||||
const captchaEnabled = ref(true);
|
||||
const captchaEnabled = ref(true)
|
||||
// 注册开关
|
||||
const register = ref(false);
|
||||
const redirect = ref(undefined);
|
||||
const register = ref(false)
|
||||
const redirect = ref(undefined)
|
||||
|
||||
function handleLogin() {
|
||||
proxy.$refs.loginRef.validate(valid => {
|
||||
proxy.$refs.loginRef.validate((valid) => {
|
||||
if (valid) {
|
||||
loading.value = true;
|
||||
loading.value = true
|
||||
// 勾选了需要记住密码设置在 cookie 中设置记住用户名和密码
|
||||
if (loginForm.value.rememberMe) {
|
||||
Cookies.set("username", loginForm.value.username, { expires: 30 });
|
||||
Cookies.set("password", encrypt(loginForm.value.password), { expires: 30 });
|
||||
Cookies.set("rememberMe", loginForm.value.rememberMe, { expires: 30 });
|
||||
Cookies.set('username', loginForm.value.username, { expires: 30 })
|
||||
Cookies.set('password', encrypt(loginForm.value.password), { expires: 30 })
|
||||
Cookies.set('rememberMe', loginForm.value.rememberMe, { expires: 30 })
|
||||
} else {
|
||||
// 否则移除
|
||||
Cookies.remove("username");
|
||||
Cookies.remove("password");
|
||||
Cookies.remove("rememberMe");
|
||||
Cookies.remove('username')
|
||||
Cookies.remove('password')
|
||||
Cookies.remove('rememberMe')
|
||||
}
|
||||
// 调用action的登录方法
|
||||
userStore.login(loginForm.value).then(() => {
|
||||
userStore
|
||||
.login(loginForm.value)
|
||||
.then(() => {
|
||||
if (route.query?.redirect) {
|
||||
location.href = route.query.redirect;
|
||||
location.href = route.query.redirect
|
||||
} else {
|
||||
router.push({ path: "/" });
|
||||
router.push({ path: '/' })
|
||||
}
|
||||
|
||||
}).catch(() => {
|
||||
loading.value = false;
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false
|
||||
// 重新获取验证码
|
||||
if (captchaEnabled.value) {
|
||||
getCode();
|
||||
getCode()
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function getCode() {
|
||||
getCodeImg().then(res => {
|
||||
captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled;
|
||||
getCodeImg().then((res) => {
|
||||
captchaEnabled.value = res.captchaEnabled === undefined ? true : res.captchaEnabled
|
||||
if (captchaEnabled.value) {
|
||||
codeUrl.value = "data:image/gif;base64," + res.img;
|
||||
loginForm.value.uuid = res.uuid;
|
||||
codeUrl.value = 'data:image/gif;base64,' + res.img
|
||||
loginForm.value.uuid = res.uuid
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function getCookie() {
|
||||
const username = Cookies.get("username");
|
||||
const password = Cookies.get("password");
|
||||
const rememberMe = Cookies.get("rememberMe");
|
||||
const username = Cookies.get('username')
|
||||
const password = Cookies.get('password')
|
||||
const rememberMe = Cookies.get('rememberMe')
|
||||
loginForm.value = {
|
||||
username: username === undefined ? loginForm.value.username : username,
|
||||
password: password === undefined ? loginForm.value.password : decrypt(password),
|
||||
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
|
||||
};
|
||||
rememberMe: rememberMe === undefined ? false : Boolean(rememberMe),
|
||||
}
|
||||
}
|
||||
|
||||
getCode();
|
||||
getCookie();
|
||||
getCode()
|
||||
getCookie()
|
||||
</script>
|
||||
|
||||
<style lang='scss'>
|
||||
|
@ -142,7 +147,7 @@ getCookie();
|
|||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
background-image: url("../assets/images/loginbg.jpeg");
|
||||
background-image: url('../assets/images/loginbg.jpeg');
|
||||
background-size: cover;
|
||||
position: relative;
|
||||
|
||||
|
@ -154,7 +159,7 @@ getCookie();
|
|||
}
|
||||
|
||||
.login-form-bg {
|
||||
background-image: url("../assets/images/loginbg3.png");
|
||||
background-image: url('../assets/images/loginbg3.png');
|
||||
position: absolute;
|
||||
top: 0%;
|
||||
width: 80%;
|
||||
|
@ -167,7 +172,7 @@ getCookie();
|
|||
|
||||
.login-form {
|
||||
border-radius: 6px;
|
||||
background-image: url("../assets/images/loginbg2.png");
|
||||
background-image: url('../assets/images/loginbg2.png');
|
||||
background-size: 100% 100%;
|
||||
width: 420px;
|
||||
padding: 50px;
|
||||
|
@ -182,7 +187,7 @@ getCookie();
|
|||
|
||||
.title {
|
||||
position: relative;
|
||||
top: -68px;
|
||||
top: -90px;
|
||||
color: #336699;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
@ -201,7 +206,7 @@ getCookie();
|
|||
|
||||
.el-input__prefix-inner {
|
||||
svg {
|
||||
fill: #45C4DD;
|
||||
fill: #45c4dd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -253,11 +258,11 @@ getCookie();
|
|||
border: solid 1px #1262b5;
|
||||
}
|
||||
|
||||
.el-checkbox__input+.el-checkbox__label {
|
||||
.el-checkbox__input + .el-checkbox__label {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.el-checkbox__input.is-checked+.el-checkbox__label {
|
||||
.el-checkbox__input.is-checked + .el-checkbox__label {
|
||||
color: var(--el-checkbox-checked-text-color) !important;
|
||||
}
|
||||
|
||||
|
|
|
@ -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: {
|
||||
|
@ -31,55 +31,58 @@ export default defineConfig(({ mode, command }) => {
|
|||
proxy: {
|
||||
"/prod-api": {
|
||||
//target: "http://localhost:8080",
|
||||
target: 'http://62.234.3.186',
|
||||
target: "http://62.234.3.186",
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
"^/prod-api": "/",
|
||||
},
|
||||
},
|
||||
// https://cn.vitejs.dev/config/#server-proxy
|
||||
'/dev-api': {
|
||||
target: 'http://localhost:8080',
|
||||
"/dev-api": {
|
||||
target: "http://localhost:8080",
|
||||
changeOrigin: true,
|
||||
rewrite: (p) => p.replace(/^\/dev-api/, '')
|
||||
rewrite: (p) => p.replace(/^\/dev-api/, ""),
|
||||
},
|
||||
'/statics': {
|
||||
target: VITE_APP_ENV === 'production'?'http://62.234.3.186':`http://localhost:9300`,
|
||||
"/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路径完全一致!
|
||||
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目录加进来,否则生产打包会报错!!
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue