From 8b63f4b2f84185ce7201307b5e7d07dcb1c9ae01 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期三, 26 六月 2024 14:49:36 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/HangZhouMes
---
UI-Project/src/layout/MainErpView.vue | 182 ++++++++++++++++++++++++++++++++++----------
1 files changed, 139 insertions(+), 43 deletions(-)
diff --git a/UI-Project/src/layout/MainErpView.vue b/UI-Project/src/layout/MainErpView.vue
index 3bd4a05..85cd1aa 100644
--- a/UI-Project/src/layout/MainErpView.vue
+++ b/UI-Project/src/layout/MainErpView.vue
@@ -1,14 +1,17 @@
<script setup>
-import {useRouter} from 'vue-router'
import useUserInfoStore from '@/stores/userInfo'
import userInfo from '@/stores/userInfo'
import request from '@/utils/request'
import {ElMessage} from 'element-plus'
-import {ref, watch} from 'vue'
+import {ref, watch, onMounted } from 'vue'
import deepClone from '@/utils/deepClone'
-
+import { useRouter } from 'vue-router';
+import { useI18n } from 'vue-i18n'
+ const { t } = useI18n()
+ let language = ref(localStorage.getItem('lang') || 'zh')
const store = userInfo()
+// const { $i18n } = useI18n(); // 鑾峰彇 i18n 瀹炰緥
const router = useRouter()
const userStore = useUserInfoStore()
const user = userStore.user.userName
@@ -19,27 +22,32 @@
// let userInfo = userInfoStr.user.token;
let token = userInfo; // 鎻愬彇 token
// 閫�鍑虹櫥褰曟柟娉�
-const quit = async () => {
- try {
- const response = await request.get('/loadGlass/sys/user/logout', {
- token: token,
- user: null,
- })
- if (response.code === 200) {
- // 鐧诲嚭鎴愬姛锛屾竻闄ゆ湰鍦板瓨鍌ㄧ殑 userInfo
- localStorage.removeItem('userInfo');
- // 鍙互鍦ㄨ繖閲岄噸缃簲鐢ㄧ姸鎬侊紝濡傚鑸埌鐧诲綍椤电瓑
- console.log('鐧诲嚭鎴愬姛');
- } else {
- // 澶勭悊閿欒鎯呭喌
- console.error('鐧诲嚭澶辫触', response);
- }
+function quit() {
+ // removeToken()
+ router.push('/login')
}
-catch (error) {
- // 澶勭悊閿欒
- console.error(error);
- }
-}
+// const quit = async () => {
+// try {
+
+// const response = await request.get('/loadGlass/sys/user/logout', {
+// token: token,
+// user: null,
+// })
+// if (response.code === 200) {
+// // 鐧诲嚭鎴愬姛锛屾竻闄ゆ湰鍦板瓨鍌ㄧ殑 userInfo
+// localStorage.removeItem('userInfo');
+// // 鍙互鍦ㄨ繖閲岄噸缃簲鐢ㄧ姸鎬侊紝濡傚鑸埌鐧诲綍椤电瓑
+// console.log('鐧诲嚭鎴愬姛');
+// } else {
+// // 澶勭悊閿欒鎯呭喌
+// console.error('鐧诲嚭澶辫触', response);
+// }
+// }
+// catch (error) {
+// // 澶勭悊閿欒
+// console.error(error);
+// }
+// }
// store.createWebSocket();
// function quit() {
// userStore.$patch({
@@ -57,26 +65,79 @@
// });
// }
+
+ function replaceChineseWithEnglish(menuData) {
+ // 瀹氫箟涓嫳鏂囧鐓у叧绯诲璞�
+ const translation = {
+ '涓婄墖鏈�': '小褌芯谢 蟹邪谐褉褍蟹泻懈',
+ '鎺扮墖/璇嗗埆': '袪邪蟹谢芯屑/懈写械薪褌懈褎懈泻邪褑懈褟',
+ '鍗у紡缂撳瓨': ' 袚芯褉懈蟹芯薪褌邪谢褜薪褘泄 斜褍褎械褉',
+ '纾ㄨ竟鍓嶅崸寮忕紦瀛�': '袚芯褉懈蟹芯薪褌邪谢褜薪褘泄 斜褍褎械褉 锌械褉械写 褕谢懈褎芯胁泻芯泄',
+ '涓嬬墖鍗у紡缂撳瓨': '袚芯褉懈蟹芯薪褌邪谢褜薪褘泄 斜褍褎械褉 褋褌械泻谢邪 褉邪蟹谐褉褍蟹泻懈',
+ '纾ㄨ竟锛堝喎鍔犲伐锛�': '楔谢懈褎芯胁邪褌褜 泻褉邪褟 (褏芯谢芯写薪邪褟 芯斜褉邪斜芯褌泻邪)',
+ '1绾跨(杈�(鍐峰姞宸�)': '楔谢懈褎芯胁邪褌褜 泻褉邪褟 1 谢懈薪懈懈 (褏芯谢芯写薪邪褟 芯斜褉邪斜芯褌泻邪)',
+ '2绾跨(杈�(鍐峰姞宸�)': '楔谢懈褎芯胁邪褌褜 泻褉邪褟 2 谢懈薪懈懈 (褏芯谢芯写薪邪褟 芯斜褉邪斜芯褌泻邪)',
+ '澶х悊鐗囩': '袘褍褎械褉薪邪褟 褋懈褋褌械屑邪',
+ '閽㈠寲': '袟邪泻邪谢泻邪',
+ '閽㈠寲鍓�': '袩械褉械写 蟹邪泻邪谢泻懈',
+ '閽㈠寲鍚�': '袩芯褋谢械 蟹邪泻邪谢泻懈',
+ '涓嬬墖鍙�': '小褌芯谢 褉邪蟹谐褉褍蟹泻懈',
+ '绯荤粺绠$悊': '校锌褉邪胁谢械薪懈械 褋懈褋褌械屑芯泄',
+ '鐢ㄦ埛绠$悊': '校锌褉邪胁谢械薪懈械 锌芯谢褜蟹芯胁邪褌械谢械屑',
+ '鏉冮檺绠$悊': '校锌褉邪胁谢械薪懈械 锌芯谢薪芯屑芯褔懈褟屑懈',
+ '瑙掕壊绠$悊': '校锌褉邪胁谢械薪懈械 褉芯谢褜褞',
+ };
+ menuData.forEach(menu => {
+ menu.menuName = translation[menu.menuName] || menu.menuName;
+ // if (menu.children) {
+ menu.children && menu.children.forEach(submenu => {
+ submenu.menuName = translation[submenu.menuName] || submenu.menuName;
+ });
+ // }
+ });
+}
//鎻愬彇鑿滃崟妯″潡鍒楄〃
let menuList = $ref([])
-// request.get('/loadGlass/menu/sysMenu/list').then((res) => {
+
+// onMounted(async () => {
+// try {
+// const res = await request.get('/loadGlass/sys/menu/getMenuTree'); // 鍋囪 request.get 杩斿洖 Promise
+// if (res.code == 200) {
+// // 浣跨敤 value 灞炴�ф潵淇敼 ref 寮曠敤鐨勫��
+// menuList.value = deepClone(res.data);
+// const language = $i18n.locale;
+// if (language === 'en') {
+// replaceChineseWithEnglish(menuList.value); // 浼犲叆 ref 鐨� value
+// }
+// console.log(res.data.token); // 濡傛灉 res.data 涓湁 token 鐨勮瘽
+// } else {
+// ElMessage.warning(res.msg);
+// router.push('/login');
+// }
+// } catch (error) {
+// // 澶勭悊璇锋眰閿欒
+// console.error('鑾峰彇鑿滃崟鍒楄〃鏃跺嚭閿�:', error);
+// }
+// });
request.get('/loadGlass/sys/menu/getMenuTree').then((res) => {
if (res.code == 200) {
- menuList = deepClone(res.data)
- console.log(response.data.token);
+ menuList = res.data
+ console.log(language.value)
+ if (language.value === 'en') {
+
+ replaceChineseWithEnglish(menuList);
+ }
} else {
ElMessage.warning(res.msg)
router.push('/login')
}
})
-
const menu = ref(null)
let indexKey = ref(null)
function handleOpen(key) {
indexKey.value = key
}
-
watch(
indexKey,
(newVal, oldVal) => {
@@ -110,13 +171,20 @@
<img src="../assets/northGlass.ico"
alt=""
style="max-width: 100%;max-height: 100%">
- <h3 style="margin: 1rem ;font-weight: bold;width: 20vw;"> 娆㈣繋{{ user }}浣跨敤鍖楃幓MES绯荤粺锛�</h3>
+ <h3 style="margin: 1rem ;font-weight: bold;width: 33vw;"> {{ $t('main.titleFirst') }}{{ user }}{{ $t('main.titleLast') }}</h3>
<span style="height: 70%;width: 78vw;margin-top: 1rem;">
+ <!-- <el-button class="sys-quit"
+ @click="quit"
+ round>
+ <el-icon size="large">
+ <SwitchButton size=""/>{{ $t('main.quit') }}
+ </el-icon>
+ </el-button> -->
<el-button class="sys-quit"
@click="quit"
round>
<el-icon size="large">
- <SwitchButton size=""/>閫�鍑�
+ <SwitchButton size=""/>{{ $t('main.quit') }}
</el-icon>
</el-button>
</span>
@@ -124,33 +192,45 @@
</el-header>
<div id="line"></div>
<el-container>
- <el-aside width="160px"
+ <!-- <el-aside width="160px"
style="height: 99%; background-color: #fff;">
<div class="menu">
<div v-for="items in menuList">
<div class='menu_title'
@click="openMenu(items.id)">
- <!-- <span class='indicator' >鈱�</span> -->
- <!-- <span class='indicator' >鈮�</span> -->
- <!-- <img src="../assets/9.png" alt="" style="max-width: 50%;max-height: 50%;"> -->
<span>鈽�</span>
{{ items.menuName }}
</div>
<ul class='enter-x-left'
v-show="openFlag==items.id">
-
<li v-for="menuItem in items.children"
style="margin-bottom:2px">
<router-link :to="{path:menuItem.url}">
{{ menuItem.menuName }}
</router-link>
-
- </li>
- </ul>
- </div>
- </div>
- </el-aside>
-
+ </el-aside> -->
+ <el-row :span="20">
+ <el-menu :default-active="activePath" class="el-menu-vertical-demo" background-color="#fff">
+ <div class="menu">
+ <div v-for="items in menuList">
+ <div class='menu_title'
+ @click="openMenu(items.id)">
+ <span>鈽�</span>
+ {{ items.menuName }}
+ </div>
+ <ul class='enter-x-left'
+ v-show="openFlag==items.id">
+ <li v-for="menuItem in items.children"
+ style="margin-bottom:2px">
+ <router-link :to="{path:menuItem.url}">
+ {{ menuItem.menuName }}
+ </router-link>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </el-menu>
+ </el-row>
<el-main>
<div id="main">
<router-view></router-view>
@@ -163,6 +243,17 @@
</template>
<style scoped>
+
+.el-menu-vertical-demo:not(.el-menu--collapse) {
+ width: 200px;
+ min-height: 400px;
+ text-align: left;
+
+}
+
+
+
+
#all {
background-color: #eee;
height: 100%;
@@ -256,6 +347,7 @@
ul li {
height: 28px;
+ width: 200px;
line-height: 30px;
/* background: rgb(128, 128, 128); */
color: #000000;
@@ -304,7 +396,11 @@
}
.menu_title {
- width: 140px;
+ width: 180px;
+ /* white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis; */
+
height: 45px;
line-height: 55px;
/* background: #fafafa; */
--
Gitblit v1.8.0