mirror of
https://gitee.com/ice-gl/icegl-three-vue-tres.git
synced 2025-04-05 06:22:43 +08:00
1、修复了插件中 深层目录存在config.js的bug
2、增加了eslint排除 guard-for-in 的规则
This commit is contained in:
parent
2b8c551df3
commit
552c091039
@ -26,6 +26,7 @@ module.exports = {
|
||||
'vue/space-unary-ops': 'off',
|
||||
'vue/comma-dangle': 'off',
|
||||
'no-debugger': 'off',
|
||||
'guard-for-in': 'off',
|
||||
// "semi": "off",
|
||||
// "init-declarations": "off",
|
||||
// "space-unary-ops": "off",
|
||||
@ -36,4 +37,4 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @Autor: 地虎降天龙
|
||||
* @Date: 2024-03-25 15:39:04
|
||||
* @LastEditors: 地虎降天龙
|
||||
* @LastEditTime: 2024-03-25 21:18:49
|
||||
* @LastEditTime: 2024-05-15 08:10:03
|
||||
*/
|
||||
const path = require('path')
|
||||
const fs = require('fs').promises
|
||||
@ -27,11 +27,11 @@ const getPluginsConfig = () => {
|
||||
}
|
||||
// getPluginsConfig()
|
||||
|
||||
export default function addExtraScriptPlugin () {
|
||||
export default function addExtraScriptPlugin() {
|
||||
return {
|
||||
name: 'add-extra-script-plugin',
|
||||
async generateBundle () {
|
||||
async function writeToFile () {
|
||||
async generateBundle() {
|
||||
async function writeToFile() {
|
||||
try {
|
||||
// 初始化要写入的文件内容
|
||||
const pluginsConfig = getPluginsConfig()
|
||||
@ -47,6 +47,6 @@ export default function addExtraScriptPlugin () {
|
||||
}
|
||||
|
||||
await writeToFile()
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
@ -4,83 +4,82 @@
|
||||
* @Autor: 地虎降天龙
|
||||
* @Date: 2023-10-16 10:53:09
|
||||
* @LastEditors: 地虎降天龙
|
||||
* @LastEditTime: 2024-04-09 08:35:22
|
||||
* @LastEditTime: 2024-05-15 08:20:09
|
||||
*/
|
||||
// 放工具函数
|
||||
import { request } from '@fesjs/fes'
|
||||
// import { format } from 'echarts'
|
||||
import { FMessage } from '@fesjs/fes-design'
|
||||
|
||||
const findStringBetween = (str) => {
|
||||
const regex = /\/([^/]+)(?=\/[^/]*$)/;
|
||||
const match = str.match(regex);
|
||||
const regex = /\/([^/]+)(?=\/[^/]*$)/
|
||||
const match = str.match(regex)
|
||||
if (match && match[1]) {
|
||||
return match[1];
|
||||
return match[1]
|
||||
}
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
|
||||
export const getPluginsConfig = () => {
|
||||
// 获得插件列表 根据插件目录
|
||||
const modulePaths = import.meta.glob('PLS/**/config.js', { eager: true })
|
||||
const config = {};
|
||||
const modulePaths = import.meta.glob('PLS/*/config.js', { eager: true })
|
||||
const config = {}
|
||||
for (const path of Object.keys(modulePaths)) {
|
||||
const name = findStringBetween(path)
|
||||
if (!name) {
|
||||
continue;
|
||||
continue
|
||||
}
|
||||
config[name] = modulePaths[path].default
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
const formatMenu = (online, local) => {
|
||||
// 复制本地菜单
|
||||
const result = { ...local };
|
||||
|
||||
for (const olKey in online) {
|
||||
if (olKey === 'basic') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const olItem = online[olKey];
|
||||
const loItem = local[olKey];
|
||||
|
||||
// 如果在线和本地都存在该键,比较它们的预览项
|
||||
if (loItem) {
|
||||
const localPreviews = new Map(loItem.preview.map(item => [item.name, item]));
|
||||
|
||||
// 检查并添加在线中缺少的预览到结果中
|
||||
olItem.preview.forEach(preview => {
|
||||
if (!localPreviews.has(preview.name)) {
|
||||
preview.waitForGit = true;
|
||||
result[olKey].preview.push(preview);
|
||||
showWarning();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//如果本地不存在该键,则从在线添加整个部分
|
||||
olItem.waitForGit = true;
|
||||
result[olKey] = olItem;
|
||||
showWarning();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// 警告函数
|
||||
function showWarning() {
|
||||
FMessage.warning?.({
|
||||
content: '官网已经更新的插件功能,请git 更新代码!',
|
||||
colorful: true,
|
||||
duration: 5,
|
||||
});
|
||||
})
|
||||
}
|
||||
const formatMenu = (online, local) => {
|
||||
// 复制本地菜单
|
||||
const result = { ...local }
|
||||
|
||||
for (const olKey in online) {
|
||||
if (olKey === 'basic') {
|
||||
continue
|
||||
}
|
||||
|
||||
const olItem = online[olKey]
|
||||
const loItem = local[olKey]
|
||||
|
||||
// 如果在线和本地都存在该键,比较它们的预览项
|
||||
if (loItem) {
|
||||
const localPreviews = new Map(loItem.preview.map((item) => [item.name, item]))
|
||||
|
||||
// 检查并添加在线中缺少的预览到结果中
|
||||
olItem.preview.forEach((preview) => {
|
||||
if (!localPreviews.has(preview.name)) {
|
||||
preview.waitForGit = true
|
||||
result[olKey].preview.push(preview)
|
||||
showWarning()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
//如果本地不存在该键,则从在线添加整个部分
|
||||
olItem.waitForGit = true
|
||||
result[olKey] = olItem
|
||||
showWarning()
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
export const getOnlinePluginConfig = (plConfig) => {
|
||||
request(
|
||||
'https://www.icegl.cn/addons/tvt/index/getRelaseMenuList', {},
|
||||
'https://www.icegl.cn/addons/tvt/index/getRelaseMenuList',
|
||||
{},
|
||||
{
|
||||
method: 'get',
|
||||
},
|
||||
@ -94,45 +93,43 @@ export const getOnlinePluginConfig = (plConfig) => {
|
||||
})
|
||||
}
|
||||
|
||||
// 通过名称查找预览配置
|
||||
function findPreviewByName(previews, name) {
|
||||
return previews.find((preview) => preview.name === name)
|
||||
}
|
||||
// 在子配置中查找预览配置
|
||||
function findChildPreviewByName(children, childName, previewName) {
|
||||
const child = children.find((chi) => chi.name === childName)
|
||||
if (child && child.preview) {
|
||||
return child.preview.find((preview) => preview.name === previewName)
|
||||
}
|
||||
return null
|
||||
}
|
||||
export const getOnePluginConfig = (pName, oName, cName) => {
|
||||
// 获得所有插件配置
|
||||
const modulePaths = import.meta.glob('PLS/**/config.js', { eager: true });
|
||||
const modulePaths = import.meta.glob('PLS/*/config.js', { eager: true })
|
||||
|
||||
// 遍历插件配置路径
|
||||
for (const path in modulePaths) {
|
||||
const config = modulePaths[path].default;
|
||||
const pluginName = findStringBetween(path);
|
||||
const config = modulePaths[path].default
|
||||
const pluginName = findStringBetween(path)
|
||||
|
||||
// 匹配插件名称
|
||||
if (pluginName === pName) {
|
||||
// 根据页面参数名查找预览配置
|
||||
if (oName && config.preview) {
|
||||
const preview = findPreviewByName(config.preview, oName);
|
||||
if (preview) return preview;
|
||||
const preview = findPreviewByName(config.preview, oName)
|
||||
if (preview) return preview
|
||||
}
|
||||
// 根据子页面参数名查找子配置
|
||||
else if (cName && config.child) {
|
||||
const childPreview = findChildPreviewByName(config.child, oName, cName);
|
||||
if (childPreview) return childPreview;
|
||||
const childPreview = findChildPreviewByName(config.child, oName, cName)
|
||||
if (childPreview) return childPreview
|
||||
}
|
||||
// 如果没有找到具体配置,返回默认配置
|
||||
return config;
|
||||
return config
|
||||
}
|
||||
}
|
||||
// 如果没有找到匹配的插件配置,返回null
|
||||
return null;
|
||||
}
|
||||
|
||||
// 通过名称查找预览配置
|
||||
function findPreviewByName(previews, name) {
|
||||
return previews.find(preview => preview.name === name);
|
||||
}
|
||||
|
||||
// 在子配置中查找预览配置
|
||||
function findChildPreviewByName(children, childName, previewName) {
|
||||
const child = children.find(child => child.name === childName);
|
||||
if (child && child.preview) {
|
||||
return child.preview.find(preview => preview.name === previewName);
|
||||
}
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user