feat(admin): add msh_single_admin project and harden ignore rules
Introduce the new Vue admin project into version control while tightening gitignore patterns to keep env files, logs, build artifacts, and test outputs out of commits. Made-with: Cursor
This commit is contained in:
44
msh_single_admin/src/utils/error-log.js
Executable file
44
msh_single_admin/src/utils/error-log.js
Executable file
@@ -0,0 +1,44 @@
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
import Vue from 'vue';
|
||||
import store from '@/store';
|
||||
import { isString, isArray } from '@/utils/validate';
|
||||
import settings from '@/settings';
|
||||
|
||||
// you can set in settings.js
|
||||
// errorLog:'production' | ['production', 'development']
|
||||
const { errorLog: needErrorLog } = settings;
|
||||
|
||||
function checkNeed() {
|
||||
const env = process.env.NODE_ENV;
|
||||
if (isString(needErrorLog)) {
|
||||
return env === needErrorLog;
|
||||
}
|
||||
if (isArray(needErrorLog)) {
|
||||
return needErrorLog.includes(env);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (checkNeed()) {
|
||||
Vue.config.errorHandler = function (err, vm, info) {
|
||||
// Don't ask me why I use Vue.nextTick, it just a hack.
|
||||
// detail see https://forum.vuejs.org/t/dispatch-in-vue-config-errorhandler-has-some-problem/23500
|
||||
Vue.nextTick(() => {
|
||||
store.dispatch('errorLog/addErrorLog', {
|
||||
err,
|
||||
vm,
|
||||
info,
|
||||
url: window.location.href,
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user