调整结构

This commit is contained in:
2021-02-10 01:28:56 +08:00
parent 183508ce44
commit ce91d2ce57
4 changed files with 538 additions and 335 deletions

View File

@@ -1,64 +1,20 @@
import { Loading } from 'element-ui';
import config from './config.js';
class Utils {
constructor() { }
/**
* 初始化链接列表设置唯一ID
* 改变网页标题
*
* @param {string} value 新的标题
*/
initNavLinkID() {
// 载入中提示
var loading = Loading.service({
customClass: 'loading-link',
lock: true,
spinner: 'el-icon-loading',
text: '载入中,请稍候'
});
var currentIndex = 0;
var currentIndexCpy = 0;
var fn = (obj) => {
currentIndex += 1;
obj.id = currentIndex;
// 有链接,无子路径
if (obj.links != undefined && obj.sub === undefined) {
obj.sub = [];
}
// 递归
if (obj.links != undefined) {
obj.links.forEach(item => {
// 添加到子路径(适配 Element UI - Tree
obj.sub.push(item);
});
}
// 递归
if (obj.sub != undefined) {
obj.sub.forEach(item => {
setTimeout(() => {
fn(item);
}, 0);
});
}
};
// 检测 currentIndex 是否已停止变化
var timer = setInterval(() => {
if (currentIndex == currentIndexCpy) {
clearInterval(timer);
// 载入中提示
loading.close();
}
// 同步
currentIndexCpy = currentIndex;
}, 1000);
return fn;
changeTitle(value) {
if (value) {
document.title = config.siteName + ' - ' + value;
} else {
document.title = config.siteName;
}
}
/**