更新
This commit is contained in:
55
src/core/config.js
Normal file
55
src/core/config.js
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 网站配置文件
|
||||
*/
|
||||
import packageInfo from '../../package.json'
|
||||
|
||||
const greenText = (text) => `\x1b[32m${text}\x1b[0m`
|
||||
|
||||
export const config = {
|
||||
appName: 'Gin-Vue-Admin',
|
||||
showViteLogo: true,
|
||||
KeepAliveTabs: true,
|
||||
logs: []
|
||||
}
|
||||
|
||||
export const viteLogo = (env) => {
|
||||
if (config.showViteLogo) {
|
||||
console.log(
|
||||
greenText(
|
||||
`> 欢迎使用Gin-Vue-Admin,开源地址:https://github.com/flipped-aurora/gin-vue-admin`
|
||||
)
|
||||
)
|
||||
console.log(greenText(`> 当前版本:v${packageInfo.version}`))
|
||||
console.log(greenText(`> 加群方式:微信:shouzi_1994 QQ群:470239250`))
|
||||
console.log(
|
||||
greenText(`> 项目地址:https://github.com/flipped-aurora/gin-vue-admin`)
|
||||
)
|
||||
console.log(greenText(`> 插件市场:https://plugin.gin-vue-admin.com`))
|
||||
console.log(
|
||||
greenText(`> GVA讨论社区:https://support.qq.com/products/371961`)
|
||||
)
|
||||
console.log(
|
||||
greenText(
|
||||
`> 默认自动化文档地址:http://127.0.0.1:${env.VITE_SERVER_PORT}/swagger/index.html`
|
||||
)
|
||||
)
|
||||
console.log(
|
||||
greenText(`> 默认前端文件运行地址:http://127.0.0.1:${env.VITE_CLI_PORT}`)
|
||||
)
|
||||
console.log(
|
||||
greenText(
|
||||
`--------------------------------------版权声明--------------------------------------`
|
||||
)
|
||||
)
|
||||
console.log(greenText(`** 版权所有方:flipped-aurora开源团队 **`))
|
||||
console.log(greenText(`** 版权持有公司:北京翻转极光科技有限责任公司 **`))
|
||||
console.log(
|
||||
greenText(
|
||||
`** 剔除授权标识需购买商用授权:https://gin-vue-admin.com/empower/index.html **`
|
||||
)
|
||||
)
|
||||
console.log('\n')
|
||||
}
|
||||
}
|
||||
|
||||
export default config
|
||||
51
src/core/error-handel.js
Normal file
51
src/core/error-handel.js
Normal file
@@ -0,0 +1,51 @@
|
||||
function sendErrorTip(errorInfo) {
|
||||
console.groupCollapsed(`捕获到错误: ${errorInfo.type}`);
|
||||
console.log('错误类型:', errorInfo.type);
|
||||
console.log('错误信息:', errorInfo.message);
|
||||
console.log('调用栈:', errorInfo.stack);
|
||||
if (errorInfo.component) {
|
||||
console.log('组件名:', errorInfo.component.name)
|
||||
console.log('组件地址:', errorInfo.component.__file)
|
||||
}
|
||||
if (errorInfo.vueInfo) console.log('Vue 信息:', errorInfo.vueInfo);
|
||||
if (errorInfo.source) console.log('来源文件:', errorInfo.source);
|
||||
if (errorInfo.lineno) console.log('行号:', errorInfo.lineno);
|
||||
if (errorInfo.colno) console.log('列号:', errorInfo.colno);
|
||||
console.groupEnd();
|
||||
}
|
||||
|
||||
function initVueErrorHandler(app) {
|
||||
app.config.errorHandler = (err, vm, info) => {
|
||||
let errorType = 'Vue Error';
|
||||
|
||||
sendErrorTip({
|
||||
type: errorType,
|
||||
message: err.message,
|
||||
stack: err.stack,
|
||||
component: vm.$options || 'Unknown Vue Component',
|
||||
vueInfo: info
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
function initJsErrorHandler() {
|
||||
window.onerror = (message, source, lineno, colno, error) => {
|
||||
let errorType = 'JS Error';
|
||||
|
||||
sendErrorTip({
|
||||
type: errorType,
|
||||
message: message,
|
||||
stack: error ? error.stack : 'No stack available',
|
||||
source: source,
|
||||
lineno: lineno,
|
||||
colno: colno
|
||||
});
|
||||
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
export function initErrorHandler(app) {
|
||||
initVueErrorHandler(app)
|
||||
initJsErrorHandler()
|
||||
}
|
||||
29
src/core/gin-vue-admin.js
Normal file
29
src/core/gin-vue-admin.js
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* gin-vue-admin web框架组
|
||||
*
|
||||
* */
|
||||
// 加载网站配置文件夹
|
||||
import { register } from './global'
|
||||
import packageInfo from '../../package.json'
|
||||
|
||||
export default {
|
||||
install: (app) => {
|
||||
register(app)
|
||||
console.log(`
|
||||
欢迎使用 Gin-Vue-Admin
|
||||
当前版本:v${packageInfo.version}
|
||||
加群方式:微信:shouzi_1994 QQ群:622360840
|
||||
项目地址:https://github.com/flipped-aurora/gin-vue-admin
|
||||
插件市场:https://plugin.gin-vue-admin.com
|
||||
GVA讨论社区:https://support.qq.com/products/371961
|
||||
默认自动化文档地址:http://127.0.0.1:${import.meta.env.VITE_SERVER_PORT}/swagger/index.html
|
||||
默认前端文件运行地址:http://127.0.0.1:${import.meta.env.VITE_CLI_PORT}
|
||||
如果项目让您获得了收益,希望您能请团队喝杯可乐:https://www.gin-vue-admin.com/coffee/index.html
|
||||
--------------------------------------版权声明--------------------------------------
|
||||
** 版权所有方:flipped-aurora开源团队 **
|
||||
** 版权持有公司:北京翻转极光科技有限责任公司 **
|
||||
** 剔除授权标识需购买商用授权:https://gin-vue-admin.com/empower/index.html **
|
||||
** 感谢您对Gin-Vue-Admin的支持与关注 合法授权使用更有利于项目的长久发展**
|
||||
`)
|
||||
}
|
||||
}
|
||||
63
src/core/global.js
Normal file
63
src/core/global.js
Normal file
@@ -0,0 +1,63 @@
|
||||
import config from './config'
|
||||
import { h } from 'vue'
|
||||
|
||||
// 统一导入el-icon图标
|
||||
import * as ElIconModules from '@element-plus/icons-vue'
|
||||
import svgIcon from '@/components/svgIcon/svgIcon.vue'
|
||||
// 导入转换图标名称的函数
|
||||
|
||||
const createIconComponent = (name) => ({
|
||||
name: 'SvgIcon',
|
||||
render() {
|
||||
return h(svgIcon, {
|
||||
localIcon: name
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const registerIcons = async (app) => {
|
||||
const iconModules = import.meta.glob('@/assets/icons/**/*.svg') // 系统目录 svg 图标
|
||||
const pluginIconModules = import.meta.glob(
|
||||
'@/plugin/**/assets/icons/**/*.svg'
|
||||
) // 插件目录 svg 图标
|
||||
const mergedIconModules = Object.assign({}, iconModules, pluginIconModules) // 合并所有 svg 图标
|
||||
let allKeys = []
|
||||
for (const path in mergedIconModules) {
|
||||
let pluginName = ''
|
||||
if (path.startsWith('/src/plugin/')) {
|
||||
pluginName = `${path.split('/')[3]}-`
|
||||
}
|
||||
const iconName = path
|
||||
.split('/')
|
||||
.pop()
|
||||
.replace(/\.svg$/, '')
|
||||
// 如果iconName带空格则不加入到图标库中并且提示名称不合法
|
||||
if (iconName.indexOf(' ') !== -1) {
|
||||
console.error(`icon ${iconName}.svg includes whitespace in ${path}`)
|
||||
continue
|
||||
}
|
||||
const key = `${pluginName}${iconName}`
|
||||
const iconComponent = createIconComponent(key)
|
||||
config.logs.push({
|
||||
key: key,
|
||||
label: key
|
||||
})
|
||||
app.component(key, iconComponent)
|
||||
|
||||
// 开发模式下列出所有 svg 图标,方便开发者直接查找复制使用
|
||||
allKeys.push(key)
|
||||
}
|
||||
|
||||
import.meta.env.MODE == 'development' &&
|
||||
console.log(`所有可用的本地图标: ${allKeys.join(', ')}`)
|
||||
}
|
||||
|
||||
export const register = (app) => {
|
||||
// 统一注册el-icon图标
|
||||
for (const iconName in ElIconModules) {
|
||||
app.component(iconName, ElIconModules[iconName])
|
||||
}
|
||||
app.component('SvgIcon', svgIcon)
|
||||
registerIcons(app)
|
||||
app.config.globalProperties.$GIN_VUE_ADMIN = config
|
||||
}
|
||||
Reference in New Issue
Block a user