diff --git a/build_release.sh b/build_release.sh index 17b75a8e..6bd1c426 100755 --- a/build_release.sh +++ b/build_release.sh @@ -95,14 +95,6 @@ function buildWindows() { build "$1/mayfly-go-windows" "windows" "amd64" $2 } -function rmServerStatic() { - runBuildWebType=$1 - if [ "${runBuildWebType}" == "2" ];then - echo_green "移除server/static/static内容" - rm -rf ${server_folder}/static/static/* - fi -} - function runBuild() { # 构建结果的目的路径 read -p "请输入构建产物输出目录: " toPath @@ -117,7 +109,10 @@ function runBuild() { read -p "是否构建前端[0|其他->否 1->是 2->构建并拷贝至server/static/static]: " runBuildWeb read -p "请选择构建版本[0|其他->全部 1->linux-amd64 2->linux-arm64 3->windows]: " buildType - buildWeb ${runBuildWeb} + + if [ "${runBuildWeb}" == "1" ] || [ "${runBuildWeb}" == "2" ] ; then + buildWeb ${runBuildWeb} + fi case ${buildType} in "1") diff --git a/mayfly_go_web/src/App.vue b/mayfly_go_web/src/App.vue index e2f9a345..f8d6e2fd 100644 --- a/mayfly_go_web/src/App.vue +++ b/mayfly_go_web/src/App.vue @@ -11,6 +11,8 @@ import { useStore } from '@/store/index.ts'; import { getLocal } from '@/common/utils/storage.ts'; import LockScreen from '@/views/layout/lockScreen/index.vue'; import Setings from '@/views/layout/navBars/breadcrumb/setings.vue'; +import Watermark from '@/common/utils/wartermark.ts'; + export default defineComponent({ name: 'app', components: { LockScreen, Setings }, @@ -57,6 +59,8 @@ export default defineComponent({ () => route.path, () => { nextTick(() => { + // 路由变化更新水印 + Watermark.use(); document.title = `${route.meta.title} - ${getThemeConfig.value.globalTitle}` || getThemeConfig.value.globalTitle; }); } diff --git a/mayfly_go_web/src/common/openApi.ts b/mayfly_go_web/src/common/openApi.ts index e72c5136..de8fa114 100644 --- a/mayfly_go_web/src/common/openApi.ts +++ b/mayfly_go_web/src/common/openApi.ts @@ -1,10 +1,11 @@ import request from './request' export default { - login: (param: any) => request.request('POST', '/sys/accounts/login', param, null), - changePwd: (param: any) => request.request('POST', '/sys/accounts/change-pwd', param, null), - getPublicKey: () => request.request('GET', '/common/public-key', null, null), - captcha: () => request.request('GET', '/sys/captcha', null, null), - logout: (param: any) => request.request('POST', '/sys/accounts/logout/{token}', param, null), - getMenuRoute: (param: any) => request.request('Get', '/sys/resources/account', param, null) + login: (param: any) => request.request('POST', '/sys/accounts/login', param), + changePwd: (param: any) => request.request('POST', '/sys/accounts/change-pwd', param), + getPublicKey: () => request.request('GET', '/common/public-key'), + getConfigValue: (param: any) => request.request('GET', '/sys/configs/value', param), + captcha: () => request.request('GET', '/sys/captcha'), + logout: (param: any) => request.request('POST', '/sys/accounts/logout/{token}', param), + getMenuRoute: (param: any) => request.request('Get', '/sys/resources/account', param) } \ No newline at end of file diff --git a/mayfly_go_web/src/common/sysconfig.ts b/mayfly_go_web/src/common/sysconfig.ts new file mode 100644 index 00000000..f4c1a77d --- /dev/null +++ b/mayfly_go_web/src/common/sysconfig.ts @@ -0,0 +1,48 @@ +import openApi from './openApi'; + +// 登录是否使用验证码配置key +const UseLoginCaptchaConfigKey = "UseLoginCaptcha" +const UseWartermarkConfigKey = "UseWartermark" + +/** + * 获取系统配置值 + * + * @param key 配置key + * @returns 配置值 + */ +export async function getConfigValue(key: string) : Promise { + return await openApi.getConfigValue({key}) as string +} + +/** + * 获取bool类型系统配置值 + * + * @param key 配置key + * @param defaultValue 默认值 + * @returns 是否为ture,1: true;其他: false + */ +export async function getBoolConfigValue(key :string, defaultValue :boolean) : Promise { + const value = await getConfigValue(key) + if (!value) { + return defaultValue; + } + return value == "1"; +} + +/** + * 是否使用登录验证码 + * + * @returns + */ +export async function useLoginCaptcha() : Promise { + return await getBoolConfigValue(UseLoginCaptchaConfigKey, true) +} + +/** + * 是否启用水印 + * + * @returns + */ + export async function useWartermark() : Promise { + return await getBoolConfigValue(UseWartermarkConfigKey, true) +} \ No newline at end of file diff --git a/mayfly_go_web/src/common/utils/storage.ts b/mayfly_go_web/src/common/utils/storage.ts index 7124a24b..6259e0c3 100644 --- a/mayfly_go_web/src/common/utils/storage.ts +++ b/mayfly_go_web/src/common/utils/storage.ts @@ -35,3 +35,22 @@ export function removeSession(key: string) { export function clearSession() { window.sessionStorage.clear(); } + + + +export function getUserInfo4Session() { + return getSession("userInfo") +} + +export function setUserInfo2Session(userinfo: any) { + setSession("userInfo", userinfo) +} + +// 获取是否开启水印 +export function getUseWatermark4Session() { + return getSession("useWatermark") +} + +export function setUseWatermark2Session(useWatermark: boolean) { + setSession("useWatermark", useWatermark) +} \ No newline at end of file diff --git a/mayfly_go_web/src/common/utils/wartermark.ts b/mayfly_go_web/src/common/utils/wartermark.ts index dc1850fa..557bfc9f 100644 --- a/mayfly_go_web/src/common/utils/wartermark.ts +++ b/mayfly_go_web/src/common/utils/wartermark.ts @@ -1,21 +1,26 @@ +import { getUseWatermark4Session, getUserInfo4Session } from '@/common/utils/storage.ts'; +import { dateFormat } from '@/common/utils/date.ts' + // 页面添加水印效果 const setWatermark = (str: any) => { const id = '1.23452384164.123412416'; if (document.getElementById(id) !== null) document.body.removeChild(document.getElementById(id) as any); const can = document.createElement('canvas'); - can.width = 250; - can.height = 180; + can.width = 400; + can.height = 250; const cans: any = can.getContext('2d'); cans.rotate((-20 * Math.PI) / 180); - cans.font = '12px Vedana'; - cans.fillStyle = 'rgba(200, 200, 200, 0.30)'; - cans.textAlign = 'center'; + cans.font = '14px Vedana'; + cans.fillStyle = 'rgba(200, 200, 200, 0.35)'; + cans.textAlign = 'left'; cans.textBaseline = 'Middle'; - cans.fillText(str, can.width / 10, can.height / 2); + // cans.fillText('mayfly go', can.width / 4, can.height ) + cans.fillText(str, can.width / 8, can.height / 2); + const div = document.createElement('div'); div.id = id; div.style.pointerEvents = 'none'; - div.style.top = '35px'; + div.style.top = '30px'; div.style.left = '0px'; div.style.position = 'fixed'; div.style.zIndex = '10000000'; @@ -26,16 +31,34 @@ const setWatermark = (str: any) => { return id; }; +function set(str: any) { + let id = setWatermark(str); + if (document.getElementById(id) === null) id = setWatermark(str); +} + +function del() { + let id = '1.23452384164.123412416'; + if (document.getElementById(id) !== null) document.body.removeChild(document.getElementById(id) as any); +} + const watermark = { + use: () => { + setTimeout(() => { + const userinfo = getUserInfo4Session() + if (userinfo && getUseWatermark4Session()) { + set(`${userinfo.username} ${dateFormat('yyyy-MM-dd HH:mm:ss', new Date())}`) + } else { + del(); + } + }, 1500) + }, // 设置水印 set: (str: any) => { - let id = setWatermark(str); - if (document.getElementById(id) === null) id = setWatermark(str); + set(str) }, // 删除水印 del: () => { - let id = '1.23452384164.123412416'; - if (document.getElementById(id) !== null) document.body.removeChild(document.getElementById(id) as any); + del(); }, }; diff --git a/mayfly_go_web/src/router/imports.ts b/mayfly_go_web/src/router/imports.ts index 6bac20b6..57467264 100644 --- a/mayfly_go_web/src/router/imports.ts +++ b/mayfly_go_web/src/router/imports.ts @@ -2,6 +2,7 @@ import RouterParent from '@/views/layout/routerView/parent.vue'; export const imports = { 'RouterParent': RouterParent, + "Home": () => import('@/views/home/index.vue'), 'Personal': () => import('@/views/personal/index.vue'), // machine @@ -11,6 +12,8 @@ export const imports = { "RoleList": () => import('@/views/system/role'), "AccountList": () => import('@/views/system/account'), "SyslogList": () => import('@/views/system/syslog/SyslogList.vue'), + "ConfigList": () => import('@/views/system/config/ConfigList.vue'), + // project "ProjectList": () => import('@/views/ops/project/ProjectList.vue'), // db diff --git a/mayfly_go_web/src/views/layout/navBars/breadcrumb/setings.vue b/mayfly_go_web/src/views/layout/navBars/breadcrumb/setings.vue index 71ed7839..0f9126ed 100644 --- a/mayfly_go_web/src/views/layout/navBars/breadcrumb/setings.vue +++ b/mayfly_go_web/src/views/layout/navBars/breadcrumb/setings.vue @@ -273,23 +273,6 @@ -
-
开启水印
-
- -
-
-
-
水印文案
-
- -
-
其他设置 @@ -440,8 +423,6 @@ import { ElMessage } from 'element-plus'; import ClipboardJS from 'clipboard'; import { useStore } from '@/store/index.ts'; import { getLightColor } from '@/common/utils/theme.ts'; -import Watermark from '@/common/utils/wartermark.ts'; -import { verifyAndSpace } from '@/common/utils/toolsValidate.ts'; import { setLocal, getLocal, removeLocal } from '@/common/utils/storage.ts'; export default defineComponent({ name: 'layoutBreadcrumbSeting', @@ -572,18 +553,6 @@ export default defineComponent({ setLocalThemeConfig(); setLocal('appFilterStyle', appEle.style.cssText); }; - // 4、界面显示 --> 开启水印 - const onWartermarkChange = () => { - getThemeConfig.value.isWartermark ? Watermark.set(getThemeConfig.value.wartermarkText) : Watermark.del(); - setLocalThemeConfig(); - }; - // 4、界面显示 --> 水印文案 - const onWartermarkTextInput = (val: string) => { - getThemeConfig.value.wartermarkText = verifyAndSpace(val); - if (getThemeConfig.value.wartermarkText === '') return false; - if (getThemeConfig.value.isWartermark) Watermark.set(getThemeConfig.value.wartermarkText); - setLocalThemeConfig(); - }; // 5、布局切换 const onSetLayout = (layout: string) => { setLocal('oldLayout', layout); @@ -735,8 +704,6 @@ export default defineComponent({ const appEl: any = document.querySelector('#app'); appEl.style.cssText = getLocal('appFilterStyle'); } - // 开启水印 - onWartermarkChange(); // // 语言国际化 // if (getLocal('themeConfig')) proxy.$i18n.locale = getLocal('themeConfig').globalI18n; }, 1100); @@ -762,8 +729,6 @@ export default defineComponent({ getThemeConfig, onDrawerClose, onAddFilterChange, - onWartermarkChange, - onWartermarkTextInput, onSetLayout, setLocalThemeConfig, onClassicSplitMenuChange, diff --git a/mayfly_go_web/src/views/login/component/AccountLogin.vue b/mayfly_go_web/src/views/login/component/AccountLogin.vue index 600be29d..5d5ae519 100644 --- a/mayfly_go_web/src/views/login/component/AccountLogin.vue +++ b/mayfly_go_web/src/views/login/component/AccountLogin.vue @@ -9,7 +9,7 @@ - + { + onMounted(async () => { // 移除公钥, 方便后续重新获取 - sessionStorage.removeItem('RsaPublicKey') + sessionStorage.removeItem('RsaPublicKey'); + state.useLoginCaptcha = await useLoginCaptcha(); getCaptcha(); }); const getCaptcha = async () => { + if (!state.useLoginCaptcha) { + return; + } let res: any = await openApi.captcha(); state.captchaImage = res.base64Captcha; state.loginForm.cid = res.cid; @@ -198,7 +204,7 @@ export default defineComponent({ }; // 存储用户信息到浏览器缓存 - setSession('userInfo', userInfos); + setUserInfo2Session(userInfos); // 1、请注意执行顺序(存储用户信息到vuex) store.dispatch('userInfos/setUserInfos', userInfos); if (!store.state.themeConfig.themeConfig.isRequestRoutes) { @@ -224,10 +230,13 @@ export default defineComponent({ // 如果是复制粘贴的路径,非首页/登录页,那么登录成功后重定向到对应的路径中 route.query?.redirect ? router.push(route.query.redirect as string) : router.push('/'); // 登录成功提示 - setTimeout(() => { + setTimeout(async () => { // 关闭 loading state.loading.signIn = true; ElMessage.success(`${currentTimeInfo},欢迎回来!`); + if (await useWartermark()) { + setUseWatermark2Session(true); + } }, 300); }; diff --git a/mayfly_go_web/src/views/ops/db/SqlExec.vue b/mayfly_go_web/src/views/ops/db/SqlExec.vue index 1269653a..6905115c 100644 --- a/mayfly_go_web/src/views/ops/db/SqlExec.vue +++ b/mayfly_go_web/src/views/ops/db/SqlExec.vue @@ -1,9 +1,5 @@