Ver código fonte

把平台名称改成可以动态配置的

jishenghua 5 meses atrás
pai
commit
ac1ff1065f

+ 22 - 0
gyj-iot-boot/gyjiot-admin/src/main/java/com/gyjiot/web/controller/system/SysIndexController.java

@@ -1,11 +1,18 @@
 package com.gyjiot.web.controller.system;
 
+import com.gyjiot.common.core.domain.AjaxResult;
+import com.gyjiot.system.service.ISysConfigService;
+import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import com.gyjiot.common.config.RuoYiConfig;
 import com.gyjiot.common.utils.StringUtils;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
 /**
  * 首页
  *
@@ -14,6 +21,9 @@ import com.gyjiot.common.utils.StringUtils;
 @RestController
 public class SysIndexController
 {
+    @Autowired
+    private ISysConfigService configService;
+
     /** 系统基础配置 */
     @Autowired
     private RuoYiConfig ruoyiConfig;
@@ -26,4 +36,16 @@ public class SysIndexController
     {
         return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
     }
+
+    /**
+     * 获取平台名称
+     */
+    @ApiOperation("获取平台名称")
+    @GetMapping("/platformName")
+    public AjaxResult platformName(HttpServletResponse response) throws IOException {
+        AjaxResult ajax = AjaxResult.success();
+        String platformName = configService.selectConfigByKey("sys.index.platformName");
+        ajax.put("platformName", platformName);
+        return ajax;
+    }
 }

+ 1 - 1
gyj-iot-boot/gyjiot-framework/src/main/java/com/gyjiot/framework/config/SecurityConfig.java

@@ -114,7 +114,7 @@ public class SecurityConfig
                 permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                 // 静态资源,可匿名访问
-                requests.antMatchers("/login", "/register", "/registerFlag", "/captchaImage","/iot/tool/register",
+                requests.antMatchers("/login", "/register", "/registerFlag", "/captchaImage","/platformName","/iot/tool/register",
                         "/iot/tool/ntp", "/iot/tool/download", "/iot/tool/mqtt/auth","/iot/tool/mqtt/authv5","/iot/tool/mqtt/webhook",
                         "/iot/tool/mqtt/webhookv5","/auth/**/**", "/wechat/mobileLogin", "/wechat/miniLogin", "/wechat/wxBind/callback").permitAll()
                     .antMatchers("/zlmhook/**").permitAll()

+ 1 - 0
gyj-iot-boot/sql/gyj_iot.sql

@@ -1624,6 +1624,7 @@ INSERT INTO `sys_config` VALUES (2, '用户管理-账号初始密码', 'sys.user
 INSERT INTO `sys_config` VALUES (3, '主框架页-侧边栏主题', 'sys.index.sideTheme', 'theme-dark', 'Y', 'admin', '2021-12-15 21:36:18', '', NULL, '深色主题theme-dark,浅色主题theme-light');
 INSERT INTO `sys_config` VALUES (5, '账号自助-是否开启用户注册功能', 'sys.account.registerUser', 'true', 'Y', 'admin', '2021-12-15 21:36:18', 'admin', '2021-12-24 22:43:33', '是否开启注册用户功能(true开启,false关闭)');
 INSERT INTO `sys_config` VALUES (6, '账号自助-验证码开关', 'sys.account.captchaEnabled', 'true', 'Y', 'admin', '2023-03-10 23:29:21', '', NULL, '是否开启验证码功能(true开启,false关闭)');
+INSERT INTO `sys_config` VALUES (7, '平台名称', 'sys.index.platformName', '管伊佳物联', 'Y', 'admin', '2025-12-10 23:29:21', '', NULL, '平台名称');
 
 -- ----------------------------
 -- Table structure for sys_dept

+ 2 - 2
gyj-iot-web/.env.development

@@ -1,10 +1,10 @@
 # 页面标题
-VITE_APP_TITLE = 管伊佳物联
+VITE_APP_TITLE =
 
 # 开发环境配置
 VITE_APP_ENV = 'development'
 
-# 管伊佳物联/开发环境
+# 开发环境
 VITE_APP_BASE_API = '/dev-api'
 
 # 路由懒加载

+ 2 - 2
gyj-iot-web/.env.production

@@ -1,10 +1,10 @@
 # 页面标题
-VITE_APP_TITLE = 管伊佳物联
+VITE_APP_TITLE =
 
 # 生产环境配置
 VITE_APP_ENV = 'production'
 
-# 管伊佳物联/生产环境
+# 生产环境
 VITE_APP_BASE_API = '/prod-api'
 
 # 是否在打包时开启压缩,支持 gzip 和 brotli

+ 2 - 2
gyj-iot-web/.env.staging

@@ -1,10 +1,10 @@
 # 页面标题
-VITE_APP_TITLE = 管伊佳物联
+VITE_APP_TITLE =
 
 # 生产环境配置
 VITE_APP_ENV = 'staging'
 
-# 管伊佳物联/生产环境
+# 生产环境
 VITE_APP_BASE_API = '/stage-api'
 
 # 是否在打包时开启压缩,支持 gzip 和 brotli

+ 29 - 2
gyj-iot-web/index.html

@@ -12,8 +12,8 @@
   <script type="text/javascript" src="/js/EasyWasmPlayer.js"></script>
   <script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=2cd74056ead5ced85589e398b621c955"></script>
   <script>var _hmt = _hmt || [];(function() {var hm = document.createElement("script");hm.src = "https://hm.baidu.com/hm.js?2742bc99fd6c8a9569359b4d583cf507";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(hm, s);   })();</script>
-  <title>管伊佳物联</title>
-  <meta name="description" content="管伊佳物联-让连接更稳定,简单易用,更适合中小企业和个人学习使用。 适用于智能家居、智慧办公、智慧社区、工业控制、农业监测、水利监测等。" />
+  <title></title>
+  <meta name="description" content="让连接更稳定,简单易用,更适合中小企业和个人学习使用。 适用于智能家居、智慧办公、智慧社区、工业控制、农业监测、水利监测等。" />
   <meta name="keywords" content="物联网,工业物联,IOT,modbus,GB28181" />
   <!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
   <style>
@@ -205,6 +205,33 @@
       opacity: 0.5;
     }
   </style>
+  <script>
+    function getPlatform(type) {
+      let res = '';
+      let ajax = new XMLHttpRequest();
+      let url = ''
+      if(window.location.hostname === '127.0.0.1' || window.location.hostname === 'localhost' || window.location.hostname.concat('192.168')) {
+          // 开发环境
+          url = '/dev-api/' + type
+      } else {
+          // 生产环境
+          url = '/prod-api/' + type
+      }
+      ajax.onreadystatechange = function () {
+          if (ajax.readyState===4 &&ajax.status===200) {
+              let obj = JSON.parse(ajax.responseText)
+              res = obj.platformName;
+          } else {
+              res = '物联网系统';
+          }
+      }
+      ajax.open('get', url, false);
+      ajax.send(null);
+      return res;
+    }
+    window.SYS_TITLE = getPlatform("platformName");
+    document.title = window.SYS_TITLE;
+  </script>
 </head>
 
 <body>

+ 13 - 0
gyj-iot-web/src/api/index.js

@@ -0,0 +1,13 @@
+import request from '@/utils/request'
+
+// 获取平台名称
+export function getPlatformName() {
+  return request({
+    url: '/platformName',
+    headers: {
+      isToken: false
+    },
+    method: 'get',
+    timeout: 20000
+  })
+}

+ 5 - 1
gyj-iot-web/src/layout/components/Sidebar/Logo.vue

@@ -17,6 +17,7 @@
 import variables from '@/assets/styles/variables.module.scss'
 import logo from '@/assets/logo/logo.png'
 import useSettingsStore from '@/store/modules/settings'
+import { getPlatformName } from '@/api/index'
 
 defineProps({
   collapse: {
@@ -25,9 +26,12 @@ defineProps({
   }
 })
 
-const title = import.meta.env.VITE_APP_TITLE;
+const title = ref("");
 const settingsStore = useSettingsStore();
 const sideTheme = computed(() => settingsStore.sideTheme);
+getPlatformName().then(res => {
+  title.value = res.platformName
+})
 </script>
 
 <style lang="scss" scoped>

+ 1 - 1
gyj-iot-web/src/settings.js

@@ -2,7 +2,7 @@ export default {
   /**
    * 网页标题
    */
-  title: import.meta.env.VITE_APP_TITLE,
+  title: '',
   /**
    * 侧边栏主题 深色主题theme-dark,浅色主题theme-light
    */

+ 1 - 1
gyj-iot-web/src/store/modules/settings.js

@@ -30,7 +30,7 @@ const useSettingsStore = defineStore(
       // 设置网页标题
       setTitle(title) {
         this.title = title
-        useDynamicTitle();
+        // useDynamicTitle();
       }
     }
   })

+ 7 - 5
gyj-iot-web/src/views/bigScreen/home.vue

@@ -10,7 +10,7 @@
                 <div class="guang"></div>
                 <div class="d-flex jc-center">
                     <div class="title">
-                        <span class="title-text">管伊佳物联网平台</span>
+                        <span class="title-text">{{ title }}</span>
                     </div>
                 </div>
                 <div class="timers ">
@@ -29,9 +29,8 @@
 </template>
 
 <script setup name="bigScreen-home">
-import {
-    formatTime
-} from "../../utils/bigScreen/index.js";
+import { formatTime } from "../../utils/bigScreen/index.js";
+import { getPlatformName } from '@/api/index'
 import Setting from './setting.vue'
 import index from './indexs/index.vue'
 import {onMounted} from "vue";
@@ -44,7 +43,7 @@ const dateYear = ref(null);
 const dateWeek = ref(null);
 const weekday = ref(["周日", "周一", "周二", "周三", "周四", "周五", "周六"]);
 
-
+const title = ref("");
 const drawTiming = ref(null);
 
 // * 默认缩放值
@@ -64,6 +63,9 @@ const isScale = computed(() => {
     return proxy.$store.state.settings.isScale
 })
 
+getPlatformName().then(res => {
+  title.value = res.platformName
+})
 
 // const { drawMixin } = drawMixin();
 

+ 7 - 1
gyj-iot-web/src/views/index.vue

@@ -145,7 +145,7 @@
     <div style="width: 100%; text-align: center; font-size: 14px; color: #666; line-height: 32px; margin-top: 150px">
       <span>
         Copyright © 2025-2035
-        <a href="http://iot.gyjerp.com/" target="_blank">管伊佳物联</a> | Apache License
+        <a href="http://iot.gyjerp.com/" target="_blank">{{ title }}</a> | Apache License
       </span>
       <br />
       <span>
@@ -162,12 +162,14 @@ import { listNotice, getNotice } from '@/api/system/notice';
 import CountTo from '@/components/CountTo/CountTo';
 import { getServer } from '@/api/monitor/server';
 import { listAllDeviceShort } from '@/api/iot/device';
+import { getPlatformName } from '@/api/index'
 import * as echarts from 'echarts';
 import useUserStore from '@/store/modules/user'
 
 const userStore = useUserStore()
 const { proxy } = getCurrentInstance();
 
+const title = ref("");
 const map = ref(null);
 const pieCpu = ref(null);
 const pieMemery = ref(null);
@@ -222,6 +224,10 @@ const data = reactive({
 });
 const { server } = toRefs(data);
 
+getPlatformName().then(res => {
+  title.value = res.platformName
+})
+
 function init() {
   if (userStore.roles.indexOf("tenant") === -1 && userStore.roles.indexOf('general') === -1) {
     isAdmin.value = true

+ 8 - 3
gyj-iot-web/src/views/login.vue

@@ -1,15 +1,14 @@
 <template>
   <div class="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">
         <el-input
           v-model="loginForm.username"
           type="text"
           size="large"
           auto-complete="off"
-          placeholder="账号"
-        >
+          placeholder="账号">
           <template #prefix><svg-icon icon-class="user" class="el-input__icon input-icon" /></template>
         </el-input>
       </el-form-item>
@@ -68,6 +67,7 @@
 
 <script setup>
 import { getCodeImg, getRegisterFlag } from "@/api/login";
+import { getPlatformName } from '@/api/index'
 import Cookies from "js-cookie";
 import { encrypt, decrypt } from "@/utils/jsencrypt";
 import useUserStore from '@/store/modules/user'
@@ -91,6 +91,7 @@ const loginRules = {
   code: [{ required: true, trigger: "change", message: "请输入验证码" }]
 };
 
+const title = ref("");
 const codeUrl = ref("");
 const loading = ref(false);
 // 验证码开关
@@ -99,6 +100,10 @@ const captchaEnabled = ref(true);
 const register = ref(false);
 const redirect = ref(undefined);
 
+getPlatformName().then(res => {
+  title.value = res.platformName
+})
+
 watch(route, (newRoute) => {
     redirect.value = newRoute.query && newRoute.query.redirect;
 }, { immediate: true });

+ 7 - 1
gyj-iot-web/src/views/register.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="register">
     <el-form ref="registerRef" :model="registerForm" :rules="registerRules" class="register-form">
-      <h3 class="title">管伊佳物联系统</h3>
+      <h3 class="title">{{ title }}</h3>
       <el-form-item prop="username">
         <el-input
           v-model="registerForm.username"
@@ -78,6 +78,7 @@
 <script setup>
 import { ElMessageBox } from "element-plus";
 import { getCodeImg } from "@/api/login";
+import { getPlatformName } from '@/api/index'
 import { register } from '@/api/iot/tool';
 
 const router = useRouter();
@@ -115,10 +116,15 @@ const registerRules = {
   code: [{ required: true, trigger: "change", message: "请输入验证码" }]
 };
 
+const title = ref("");
 const codeUrl = ref("");
 const loading = ref(false);
 const captchaEnabled = ref(true);
 
+getPlatformName().then(res => {
+  title.value = res.platformName
+})
+
 function handleRegister() {
   proxy.$refs.registerRef.validate(valid => {
     if (valid) {