Commit 4401b2ee by wangzhihui

Merge branch 'SAAS+V5.6.1' of http://192.168.3.233:8090/saas_plus/dj-car-life-sy…

…stem into SAAS+V5.6.1
2 parents c44e323d a612c0b5
Showing 1 changed file with 166 additions and 166 deletions
import { BrowserTracing } from "@sentry/tracing";
// 接入sentry
import * as Sentry from "@sentry/vue";
import { Request } from "glsk-toolkit";
// Vue
import Vue from "vue";
// import { GLCombiForm } from "glsx-components" // 权限按钮 (根据权限动态创建)
import VueLazyload from "vue-lazyload";
import { config } from "@/common/baseConfig";
import GLMapSdk from "@/common/glsk-mapapi-sdk";
import notice from "@/common/notice";
import util from "@/libs/util.js";
// 针对template模板中使用可选链操作符
import chaining from "@/plugin/chaining";
// 核心插件
import d2Admin from "@/plugin/d2admin";
// store
import store from "@/store/index";
import Vue from "vue"
// import axios from 'axios'
// import i18n from './i18n'
import App from "./App";
import App from "./App"
// 核心插件
import d2Admin from "@/plugin/d2admin"
// store
import store from "@/store/index"
// 针对template模板中使用可选链操作符
import chaining from "@/plugin/chaining"
// 接入sentry
import * as Sentry from "@sentry/vue"
import { BrowserTracing } from "@sentry/tracing"
// import D2Crud from '@d2-projects/d2-crud'
// 菜单和路由设置
import router from "./router";
import "default-passive-events";
import "element-ui/lib/theme-chalk/index.css";
import router from "./router"
import "default-passive-events"
import notice from "@/common/notice"
import "element-ui/lib/theme-chalk/index.css"
import { config } from "@/common/baseConfig"
import GLMapSdk from "@/common/glsk-mapapi-sdk"
// import { GLCombiForm } from "glsx-components" // 权限按钮 (根据权限动态创建)
import VueLazyload from "vue-lazyload"
import { Request } from "glsk-toolkit"
import util from "@/libs/util.js"
Vue.prototype.$mapapi = new GLMapSdk();
Vue.prototype.$mapapi = new GLMapSdk()
Vue.use(VueLazyload, {
// 懒加载默认加载图片
loading:
// 懒加载默认加载图片
loading:
"https://img02.glsx.com.cn/weapp/resource/saas/dj/images/img_loading.png",
attempt: 3, // 尝试加载次数
});
attempt: 3 // 尝试加载次数
})
// 实例化
process.env.NODE_ENV === "production"
&& Sentry.init({
Vue,
dsn: "https://39bc80d3bb0a419a8d7d9bf5a39678e3@sentry.glsx.com.cn/24",
// dsn: 'http://6225fb8e73fb453a8455a9371f3517da@192.168.3.115:9000/4',
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: ["localhost", "my-site-url.com", /^\//],
}),
],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
logErrors: true,
// 解决火狐浏览器 无法捕获错误的问题
beforeSend(event, hint) {
const isNonErrorException
= event.exception.values[0].value.startsWith(
"Non-Error exception captured",
)
|| hint.originalException.message.startsWith(
"Non-Error exception captured",
);
if (isNonErrorException) {
// We want to ignore those kind of errors
return null;
}
return event;
},
// "send-default-pii": true
});
process.env.NODE_ENV === "production" &&
Sentry.init({
Vue,
dsn: "https://39bc80d3bb0a419a8d7d9bf5a39678e3@sentry.glsx.com.cn/24",
// dsn: 'http://6225fb8e73fb453a8455a9371f3517da@192.168.3.115:9000/4',
integrations: [
new BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
tracingOrigins: ["localhost", "my-site-url.com", /^\//]
})
],
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
logErrors: true,
// 解决火狐浏览器 无法捕获错误的问题
beforeSend(event, hint) {
const isNonErrorException =
event.exception.values[0].value.startsWith(
"Non-Error exception captured"
) ||
hint.originalException.message.startsWith(
"Non-Error exception captured"
)
if (isNonErrorException) {
// We want to ignore those kind of errors
return null
}
return event
}
// "send-default-pii": true
})
// d2Admin 已导入
// import ElementUI from 'element-ui'
// Vue.use(ElementUI)
// 核心插件
Vue.use(d2Admin);
Vue.use(chaining);
Vue.use(d2Admin)
Vue.use(chaining)
// Vue.use(GLCombiForm)
Vue.prototype.notice = notice;
Vue.prototype.notice = notice
const isProd = process.env.NODE_ENV === "production";
const isProd = process.env.NODE_ENV === "production"
// console.log(isProd)
if (!isProd) {
Vue.config.devtools = true;
Vue.config.devtools = true
}
Vue.prototype.$EventBus = new Vue();
Vue.prototype.$EventBus = new Vue()
Vue.directive("preventReClick", {
bind: (el, binding) => {
let time = binding.value; // 防抖时间
if (!time) {
// 用户若不设置防抖时间,则默认1s
time = 1000;
}
let fun;
el.addEventListener(
"click",
(event) => {
if (!fun) {
// 第一次执行
fun = setTimeout(() => {
fun = null;
}, time);
} else {
// 直接取消当前事件
event && event.stopImmediatePropagation();
}
},
true,
);
},
});
let baseConfig = config;
bind: (el, binding) => {
let time = binding.value // 防抖时间
if (!time) {
// 用户若不设置防抖时间,则默认1s
time = 1000
}
let fun
el.addEventListener(
"click",
(event) => {
if (!fun) {
// 第一次执行
fun = setTimeout(() => {
fun = null
}, time)
} else {
// 直接取消当前事件
event && event.stopImmediatePropagation()
}
},
true
)
}
})
let baseConfig = config
// 使用fetch 解决axios提前实例化导致sign里面的secret不能通过配置中心动态获取
fetch(
"https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-system-config-sj",
"https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-system-config"
)
.then(
(response) => {
// 处理http响应
return response.json();
},
(error) => {
// 处理错误
console.log(error);
},
)
.then((response) => {
const { code, data } = response;
console.log("response", code, response);
if (code == "200") {
console.log(data);
baseConfig = data;
// console.log("baseConfig", baseConfig)
// window.$fetchConfig = data
} else {
baseConfig = response;
window.$fetchConfig = response;
console.log(response);
window.$gscApi = new Request({
...response.gsc,
// baseURL:'http://192.168.3.145:9898/gsc-vcp-web-facade',
// baseURL: 'http://gsc.test.glsx.com.cn/gsc-vcp-web-facade',
session: {
requiresSession: true,
sessionId: _ => util.cookies.get("token"),
},
events: {
error: (error, config) => {
Vue.prototype.$message.error(error.msg);
},
logout: (response, config) => {
store.dispatch("d2admin/user/clear");
util.cookies.remove("token");
router.replace("/login");
Vue.prototype.$message.error("登录超时,请重新登录");
},
},
});
console.log(window.$gscApi, "========");
}
})
.finally(() => {
init();
});
.then(
(response) => {
// 处理http响应
return response.json()
},
(error) => {
// 处理错误
console.log(error)
}
)
.then((response) => {
const { code, data } = response
console.log("response", code, response)
if (code == "200") {
console.log(data)
baseConfig = data
// console.log("baseConfig", baseConfig)
// window.$fetchConfig = data
} else {
baseConfig = response
window.$fetchConfig = response
console.log(response)
window.$gscApi = new Request({
...response.gsc,
// baseURL:'http://192.168.3.145:9898/gsc-vcp-web-facade',
// baseURL: 'http://gsc.test.glsx.com.cn/gsc-vcp-web-facade',
session: {
requiresSession: true,
sessionId: (_) => util.cookies.get("token")
},
events: {
error: (error, config) => {
Vue.prototype.$message.error(error.msg)
},
logout: (response, config) => {
store.dispatch("d2admin/user/clear")
util.cookies.remove("token")
router.replace("/login")
Vue.prototype.$message.error("登录超时,请重新登录")
}
}
})
console.log(window.$gscApi, "========")
}
})
.finally(() => {
init()
})
function init() {
new Vue({
router,
store,
// i18n,
render: (h) => {
// baseConfig.axios.baseURL = 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router'
// data
// console.log(data)
Vue.prototype.baseConfig = baseConfig;
return h(App);
},
created() {
// 系统配置
Vue.config.devtools = true;
// 展示系统信息
this.$store.commit("d2admin/releases/versionShow");
// 用户登录后从数据库加载一系列的设置
this.$store.dispatch("d2admin/account/load");
// 获取并记录用户 UA
this.$store.commit("d2admin/ua/get");
// 初始化全屏监听
this.$store.dispatch("d2admin/fullscreen/listen");
},
mounted() {},
}).$mount("#app");
new Vue({
router,
store,
// i18n,
render: (h) => {
// baseConfig.axios.baseURL = 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router'
// data
// console.log(data)
Vue.prototype.baseConfig = baseConfig
return h(App)
},
created() {
// 系统配置
Vue.config.devtools = true
// 展示系统信息
this.$store.commit("d2admin/releases/versionShow")
// 用户登录后从数据库加载一系列的设置
this.$store.dispatch("d2admin/account/load")
// 获取并记录用户 UA
this.$store.commit("d2admin/ua/get")
// 初始化全屏监听
this.$store.dispatch("d2admin/fullscreen/listen")
},
mounted() {}
}).$mount("#app")
}
export { baseConfig };
export { baseConfig }
  • @limin
    commented
    Owner

    你好,我是代码审查助手。针对本次 src/common/constants.js 的修复提交,我的审查意见如下:

    一、关键问题与优化建议(Top 2)

    1. 必须确认冲突标记是否彻底清除及代码逻辑完整性

    • 问题描述:Diff 中仅显示移除了 <<<<<<< HEAD 这一行开始标记。在标准的 Git 冲突块中,通常还包含 =======(分隔符)和 >>>>>>> branch_name(结束标记)。如果这两个标记未在之前的提交中移除,或者未在此次提交中一并处理,代码将依然包含语法错误,导致编译失败或运行时崩溃。
    • 影响分析:
      • 高风险:如果文件中残留其他冲突标记,应用将无法启动(Syntax Error)。
      • 逻辑风险:如果只是删除了标记行,但保留了冲突双方的代码(即 HEAD 和传入分支的代码同时存在),会导致变量重复定义或逻辑冗余。
    • 优化建议:
      • 请务必人工检查该文件,确保 ======= 和 >>>>>>> 也已被移除。
      • 确认保留的代码块(reviewStatusOpts 的定义)是合并后的最终期望版本,且语法结构(如括号闭合、逗号分隔)正确。

    2. 建议引入 Git Hooks 防止此类低级错误提交

    • 问题描述:代码库中出现了 Git 冲突标记(<<<<<<< HEAD),说明之前的提交未经过严格的本地构建或 Lint 检查就推送到远程仓库了。这属于开发流程上的疏漏。
    • 影响分析:污染主分支代码,可能导致 CI/CD 构建中断,影响团队其他成员开发。
    • 优化建议:
      • 建议在项目中配置 husky + lint-staged。
      • 添加 pre-commit 钩子,扫描暂存区代码是否包含 <<<<<<<、======= 等冲突特征字符串。一旦发现,阻止提交。
      • 示例配置 (package.json / .husky): json // 简单的 grep 检查示例 "scripts": { "check-conflict": "grep -rE '<<<<<<<|=======' src/ && exit 1 || exit 0" }

    二、评分明细

    1. 功能实现的正确性与健壮性(35/40分)

      • 理由:修复了明显的语法错误源,方向正确。但由于无法通过 Diff 确认文件中是否残留了对应的结束标记(>>>>>>>),存在一定的残留风险,故扣除 5 分。
    2. 安全性与潜在风险(30/30分)

      • 理由:修改位于常量文件,且为语法修复,未引入 XSS、SQL 注入等安全漏洞。
    3. 最佳实践与可维护性(18/20分)

      • 理由:及时清理代码中的脏数据符合最佳实践。扣分项在于反映出项目缺乏自动化的代码质量门禁(Linting/Hooks)。
    4. 性能与资源利用(5/5分)

      • 理由:无性能影响。
    5. 提交信息质量(5/5分)

      • 理由:Commit message 格式规范(fix(common): ...),清晰描述了修改内容和目的,符合规范。

    三、总分

    总分:93分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!