byt-ui 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "byt-ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "byt组件库",
6
6
  "author": {
@@ -16,6 +16,8 @@
16
16
  },
17
17
  "main": "lib/byt-ui.umd.min.js",
18
18
  "dependencies": {
19
+ "@sentry/vue": "^7.110.1",
20
+ "axios": "^1.6.8",
19
21
  "core-js": "^3.8.3",
20
22
  "element-ui": "^2.15.10",
21
23
  "js-cookie": "^3.0.1",
@@ -70,4 +72,4 @@
70
72
  "access": "public",
71
73
  "registry": "https://registry.npmjs.com/"
72
74
  }
73
- }
75
+ }
@@ -1,20 +1,20 @@
1
1
  /*
2
- * @Description:
2
+ * @Description:
3
3
  * @Author: 王国火
4
4
  * @Date: 2022-09-19 10:17:14
5
- * @LastEditTime: 2022-10-25 09:48:55
5
+ * @LastEditTime: 2024-04-18 16:26:34
6
6
  * @LastEditors: 王国火
7
7
  */
8
8
  // 动态引入
9
9
  let conmmon = {};
10
10
  const requireContext = require.context('./modules', true, /.*\.js/)
11
11
  requireContext.keys().map(key => {
12
- const reg=/\w+/
13
- const k=key.match(reg)[0]
14
- if(requireContext(key).default){
15
- conmmon[k]=requireContext(key).default
16
- }else{
17
- conmmon=Object.assign(conmmon,requireContext(key))
12
+ const reg = /\w+/
13
+ const k = key.match(reg)[0]
14
+ if (requireContext(key).default) {
15
+ conmmon[k] = requireContext(key).default
16
+ } else {
17
+ conmmon = Object.assign(conmmon, requireContext(key))
18
18
  }
19
19
  })
20
- export default conmmon
20
+ export default conmmon
@@ -0,0 +1,157 @@
1
+ /*
2
+ * @Description:
3
+ * @Author: 王国火
4
+ * @Date: 2024-04-18 15:37:44
5
+ * @LastEditTime: 2024-04-19 13:50:16
6
+ * @LastEditors: 王国火
7
+ */
8
+ import * as sentry from '@sentry/vue'
9
+ import { getCookie } from './cookie'
10
+ import { getStore } from './store'
11
+ class Sentry {
12
+ constructor(config = {}) {
13
+ const { axios, Vue, project, router, options = {}} = config
14
+ this.axios = axios;
15
+ this.Vue = Vue || window.Vue;
16
+ this.project = project;
17
+ this.router = router;
18
+ this.options = options;
19
+
20
+ // 注册调用获取dsn;
21
+ this.register();
22
+ }
23
+
24
+ captureEvent({
25
+ message = '',
26
+ level = 'error',
27
+ tags = {
28
+ type: 'xhr-error',
29
+ category: 'xhr-category'
30
+ },
31
+ extra = {},
32
+ breadcrumbs = []
33
+ }) {
34
+ sentry.captureEvent({
35
+ message,
36
+ level,
37
+ tags,
38
+ extra,
39
+ breadcrumbs
40
+ })
41
+ }
42
+ init(dsn) {
43
+ const params = {
44
+ Vue: this.Vue,
45
+ dsn,
46
+ logErrors: false,
47
+ integrations: [
48
+ sentry.browserTracingIntegration(),
49
+ sentry.replayIntegration({
50
+ maskAllText: false,
51
+ blockAllMedia: false
52
+ }),
53
+ sentry.breadcrumbsIntegration({
54
+ // 关闭控制台打印捕获
55
+ console: false
56
+ })
57
+ ],
58
+ initialScope: (scope) => {
59
+ return scope
60
+ },
61
+ beforeSend: (e) => {
62
+ // 请求发送前添加用户信息
63
+ const { fullPath } = this.router.currentRoute;
64
+ const userInfo = getCookie('userInfo') || getStore('userInfo');
65
+ const tenantId = getCookie('tenantId') || ''
66
+ const params = {
67
+ path: fullPath,
68
+ title: document.title,
69
+ ip: window.location.host
70
+ }
71
+ if (userInfo) {
72
+ const info = JSON.parse(userInfo);
73
+ const { username, email } = info;
74
+ e.user = Object.assign(params, info, {
75
+ id: tenantId,
76
+ username,
77
+ email
78
+ })
79
+ } else {
80
+ e.user = params
81
+ }
82
+ return e;
83
+ },
84
+ beforeSendTransaction: (e) => {
85
+ e.transaction = document.title
86
+ return e
87
+ },
88
+ // 任何请求都会调用的函数,处理请求status_code不是200时,自定义上报错误信息
89
+ beforeBreadcrumb: (scope, hint) => {
90
+ if (scope.category == 'xhr') {
91
+ const statusCode = scope.data.status_code;
92
+ const response = JSON.parse(hint.xhr.responseText);
93
+ const { code, msg } = response;
94
+ switch (statusCode * 1) {
95
+ case 200:
96
+ if (code == 1) {
97
+ this.captureEvent({
98
+ message: msg,
99
+ level: 'error',
100
+ extra: {
101
+ message: hint.xhr.__sentry_xhr_v3__,
102
+ type: 'request'
103
+ }
104
+ })
105
+ }
106
+ break;
107
+ default:
108
+ this.captureEvent({
109
+ message: msg,
110
+ level: 'error',
111
+ extra: {
112
+ message: hint.xhr.__sentry_xhr_v3__,
113
+ type: 'request'
114
+ }
115
+ })
116
+ break;
117
+ }
118
+ }
119
+ return scope
120
+ },
121
+ // 版本号,默认情况下会自动设置或读取环境变量中 SENTRY_RELEASE 的值,一般需要搭配其他插件配套使用。
122
+ release: this.project, // 区分项目版本号
123
+ // Sentry SDK 将任何上下文数据标准化到给定的深度。任何包含结构比这更深的数据的 key 都将使用其类型([Object] 或 [Array])进行修剪和标记,而不会进一步遍历树。默认情况下,步行执行 3 级深度。
124
+ normalizeDepth: 3, // 默认3
125
+ // 该变量控制应捕获的面包屑总量。该默认为100,但您可以将其设置为任何数字。但是,您应该知道Sentry有一个最大有效负载大小,任何超过该有效负载大小的事件都将被丢弃。
126
+ maxBreadcrumbs: 50,
127
+ // Performance Monitoring
128
+ tracesSampleRate: 1.0, // Capture 100% of the transactions
129
+ // Set 'tracePropagationTargets' to control for which URLs distributed tracing should be enabled
130
+ tracePropagationTargets: ['localhost'],
131
+ // Session Replay
132
+ replaysSessionSampleRate: 0.1, // This sets the sample rate at 10%. You may want to change it to 100% while in development and then sample at a lower rate in production.
133
+ replaysOnErrorSampleRate: 1.0 // If you're not already sampling the entire session, change the sample rate to 100% when sampling sessions where errors occur.
134
+ }
135
+ // 允许自定义配置覆盖、合并默认配置
136
+ sentry.init(Object.assign({}, params, this.options))
137
+ }
138
+ register() {
139
+ this.axios({
140
+ url: '/leo-tech-bridge/sysParam/getSentryDsn',
141
+ method: 'GET'
142
+ }).then((res) => {
143
+ // 需要兼容商城和业务中台
144
+ const val = res instanceof Object ? res.data : res
145
+ if (val) {
146
+ // 重新处理拼接dsn地址
147
+ const localhost = window.location;
148
+ const result = val.split('@');
149
+ const dsn = `${localhost.protocol}//${result[0]}@${localhost.host}${result[1]}`;
150
+ this.init(dsn);
151
+ }
152
+ })
153
+ }
154
+ }
155
+
156
+ export default Sentry
157
+
@@ -1,27 +1,15 @@
1
1
  /*
2
- * @Description:
2
+ * @Description:
3
3
  * @Author: 王国火
4
4
  * @Date: 2022-10-18 12:37:03
5
- * @LastEditTime: 2023-07-11 14:28:17
5
+ * @LastEditTime: 2024-04-19 13:27:26
6
6
  * @LastEditors: 王国火
7
7
  */
8
8
  import Cookie from 'js-cookie'
9
9
  import website from './website'
10
- export const getCookie = (key, context) => {
10
+ export const getCookie = (key) => {
11
11
  const searchKey = `${website.key}-${key}`
12
- if (context && context.req) {
13
- if (context.req.headers.cookie) {
14
- const arr = context.req.headers.cookie.split(';')
15
- const cookie = arr.find((item) => {
16
- return (item.split('=')[0]).trim() === searchKey
17
- })
18
- return cookie ? cookie.split('=')[1] : ''
19
- } else {
20
- return ''
21
- }
22
- } else {
23
- return Cookie.get(searchKey) ? Cookie.get(searchKey) : ''
24
- }
12
+ return Cookie.get(searchKey) || ''
25
13
  }
26
14
 
27
15
  export const setCookie = (key, value, expires = 7, path = '/') => {
@@ -29,9 +17,8 @@ export const setCookie = (key, value, expires = 7, path = '/') => {
29
17
  }
30
18
 
31
19
  export const removeCookie = (key, path = '/') => {
32
- console.log(`${website.key}-${key}`)
33
- return Cookie.remove(`${website.key}-${key}`, {
20
+ return Cookie.remove(`${website.key}-${key}`, {
34
21
  path,
35
- domain:window.location.hostname
22
+ domain: window.location.hostname
36
23
  })
37
- }
24
+ }
@@ -1,18 +1,18 @@
1
1
  /*
2
- * @Description:
2
+ * @Description:
3
3
  * @Author: 王国火
4
4
  * @Date: 2022-10-08 09:10:49
5
- * @LastEditTime: 2022-10-25 11:03:35
5
+ * @LastEditTime: 2024-04-18 16:26:42
6
6
  * @LastEditors: 王国火
7
7
  */
8
8
  import { validatenull } from './validate'
9
9
  import website from './website'
10
- //存储前缀 避免与同域的其它项目冲突
10
+ // 存储前缀 避免与同域的其它项目冲突
11
11
  const keyName = website.key
12
12
  /**
13
13
  * 存储localStorage
14
14
  */
15
- export const setStore = (key,value,type=0) => {
15
+ export const setStore = (key, value, type = 0) => {
16
16
  const name = `${keyName}-${key}`
17
17
  const obj = {
18
18
  dataType: typeof (value),
@@ -30,9 +30,9 @@ export const setStore = (key,value,type=0) => {
30
30
  * 获取localStorage
31
31
  */
32
32
 
33
- export const getStore = (key,debug = false) => {
33
+ export const getStore = (key, debug = false) => {
34
34
  const name = `${keyName}-${key}`
35
- let obj = window.sessionStorage.getItem(name)||window.localStorage.getItem(name)
35
+ let obj = window.sessionStorage.getItem(name) || window.localStorage.getItem(name)
36
36
  let content
37
37
  if (validatenull(obj)) return null
38
38
  try {
@@ -66,7 +66,7 @@ export const removeStore = (key) => {
66
66
  /**
67
67
  * 获取全部localStorage
68
68
  */
69
- export const getAllStore = (type=0) => {
69
+ export const getAllStore = (type = 0) => {
70
70
  const list = []
71
71
  if (type) {
72
72
  for (let i = 0; i <= window.sessionStorage.length; i++) {
@@ -94,7 +94,7 @@ export const getAllStore = (type=0) => {
94
94
  /**
95
95
  * 清空全部localStorage
96
96
  */
97
- export const clearStore = (type=0) => {
97
+ export const clearStore = (type = 0) => {
98
98
  if (type) {
99
99
  window.sessionStorage.clear()
100
100
  } else {
@@ -2,12 +2,12 @@
2
2
  * @Description:
3
3
  * @Author: 王国火
4
4
  * @Date: 2022-07-13 12:31:34
5
- * @LastEditTime: 2022-10-08 10:51:37
5
+ * @LastEditTime: 2024-04-18 16:26:47
6
6
  * @LastEditors: 王国火
7
7
  */
8
- export default{
8
+ export default {
9
9
  key: 'bonyear', // 配置主键,目前用于存储
10
10
  formLoginClient: 'pig:pig', // 用户名密码登录的 client 信息
11
11
  smsLoginClient: 'app:app', // 验证码登录的 client 信息
12
- socialLoginClient: 'social:social', // 社交登录的 client 信息
13
- }
12
+ socialLoginClient: 'social:social' // 社交登录的 client 信息
13
+ }
@@ -2,8 +2,8 @@
2
2
  * @Description:
3
3
  * @Author: 王国火
4
4
  * @Date: 2022-07-12 17:47:20
5
- * @LastEditTime: 2024-03-04 15:16:54
6
- * @LastEditors: hcm
5
+ * @LastEditTime: 2024-04-18 16:27:18
6
+ * @LastEditors: 王国火
7
7
  -->
8
8
 
9
9
  <template>
@@ -212,11 +212,11 @@ export default {
212
212
  }
213
213
  },
214
214
  mounted() {
215
-
215
+
216
216
  },
217
217
  methods: {
218
- init(form){
219
- this.searchForm=Object.assign({},this.searchForm,form);
218
+ init(form) {
219
+ this.searchForm = Object.assign({}, this.searchForm, form);
220
220
  // 有些特殊情况需要手动请求列表数据
221
221
  if (this.autoLoad) this.fetchData();
222
222
  },
@@ -279,7 +279,7 @@ export default {
279
279
  this.searchForm = {};
280
280
  this.fetchData();
281
281
  },
282
- clear(){
282
+ clear() {
283
283
  this.$refs.search.init();
284
284
  },
285
285
  onSizeChange(size) {
@@ -2,8 +2,8 @@
2
2
  * @Description:
3
3
  * @Author: 王国火
4
4
  * @Date: 2022-07-13 08:46:34
5
- * @LastEditTime: 2023-10-16 10:21:19
6
- * @LastEditors: hcm
5
+ * @LastEditTime: 2024-04-19 13:29:06
6
+ * @LastEditors: 王国火
7
7
  -->
8
8
  <!-- -->
9
9
  <template>
@@ -60,7 +60,7 @@
60
60
  >
61
61
  </el-date-picker>
62
62
  </template>
63
-
63
+
64
64
  <!-- add by hcm 加时间区间类型-->
65
65
  <template v-if="item.type=='datetimerange'">
66
66
  <el-date-picker
@@ -96,11 +96,11 @@ export default {
96
96
  props: {
97
97
  labelWidth: {
98
98
  type: Number,
99
- defualt: 80
99
+ default: 80
100
100
  },
101
101
  inline: {
102
102
  type: Boolean,
103
- defualt: false
103
+ default: false
104
104
  },
105
105
  searchList: {
106
106
  type: Array,
@@ -148,7 +148,7 @@ export default {
148
148
  components: {},
149
149
  computed: {},
150
150
  mounted() {
151
-
151
+
152
152
  },
153
153
  methods: {
154
154
  formateDate(type) {
@@ -204,24 +204,24 @@ export default {
204
204
  }
205
205
  },
206
206
  formatForm(list) {
207
- //有些查询条件初始携带默认值,需要处理;
207
+ // 有些查询条件初始携带默认值,需要处理;
208
208
  this.form = Object.assign({}, this.form, list.reduce((obj, el) => {
209
209
  obj[el.key] = this.setDefaultVal(el)
210
210
  return obj
211
211
  }, {}))
212
212
  },
213
- init(){
213
+ init() {
214
214
  this.formatForm(this.searchList);
215
215
  this.$emit('init', this.form)
216
216
  }
217
217
  },
218
218
  watch: {
219
- searchList:{
220
- handler(){
219
+ searchList: {
220
+ handler() {
221
221
  this.init();
222
222
  },
223
- immediate:true,
224
- deep:true
223
+ immediate: true,
224
+ deep: true
225
225
  },
226
226
  form: {
227
227
  handler(val) {
@@ -1,8 +1,8 @@
1
1
  <!--
2
2
  * @Author: hcm
3
3
  * @Date: 2023-05-29 13:18:19
4
- * @LastEditors: hcm
5
- * @LastEditTime: 2024-04-10 17:09:38
4
+ * @LastEditors: 王国火
5
+ * @LastEditTime: 2024-04-18 17:59:13
6
6
  * @Description: 消息推送选择目标组件
7
7
  -->
8
8
  <template>
@@ -68,12 +68,8 @@ export default {
68
68
  type: Object,
69
69
  default: null
70
70
  },
71
- value: { // 单选时,传入值,如'user$$111'
72
- type: [String, Number],
73
- default: null
74
- },
75
- valueList: { // 多选时,传入数组,如['user$$111', 'dept$$221']
76
- type: Array,
71
+ value: { // 单选时,传入值,如'user$$111' // 多选时,传入数组,如['user$$111', 'dept$$221']
72
+ type: [String, Number, Array],
77
73
  default: null
78
74
  },
79
75
  multiple: { // 推送目标允许多选
@@ -127,22 +123,19 @@ export default {
127
123
  }
128
124
  },
129
125
  watch: {
130
- value() {
131
- if (this.value) {
132
- const list = this.value.split('$$')
133
- this.currentValue = [list[0], list[1]]
134
- this.$emit('labelMapInit', this.labelMap, this.channelType)
135
- console.log('value转化:', this.currentValue)
136
- }
137
- },
138
- valueList: {
126
+ value: {
139
127
  handler() {
140
- if (this.valueList) {
141
- this.currentValue = this.valueList.map(value => {
128
+ if (this.value && Array.isArray(this.value)) {
129
+ this.currentValue = this.value.map(value => {
142
130
  const list = value.split('$$')
143
131
  return [list[0], list[1]]
144
132
  })
145
- console.log('valueList转化:', this.currentValue)
133
+ // console.log('value list转化:', this.currentValue)
134
+ this.$emit('labelMapInit', this.labelMap, this.channelType)
135
+ } else if (this.value && typeof this.value === 'string') {
136
+ const list = this.value.split('$$')
137
+ this.currentValue = [list[0], list[1]]
138
+ // console.log('value转化:', this.currentValue)
146
139
  this.$emit('labelMapInit', this.labelMap, this.channelType)
147
140
  } else {
148
141
  this.currentValue = []
@@ -199,7 +192,7 @@ export default {
199
192
  // -----其他方法 start-----
200
193
  // 按钮点击事件
201
194
  handleClick() {
202
- console.log(this.$refs.mptCascader)
195
+ // console.log(this.$refs.mptCascader)
203
196
  // 主动触发点击事件
204
197
  this.$refs.mptCascader.$el.click()
205
198
  // dispatchEvent(new MouseEvent('click'));
@@ -213,7 +206,11 @@ export default {
213
206
  })
214
207
  }
215
208
  } else {
216
- val = `${this.currentValue[0]}$$${this.currentValue[1]}`
209
+ if (this.currentValue && this.currentValue[1]) {
210
+ val = `${this.currentValue[0]}$$${this.currentValue[1]}`
211
+ } else {
212
+ val = ''
213
+ }
217
214
  }
218
215
  // console.log('MessageOne返回值:', val, this.channelType, this.labelMap, this.currentValue)
219
216
  this.$emit('change', val, this.channelType, this.labelMap, this.currentValue)
@@ -2,7 +2,7 @@
2
2
  * @Author: hcm
3
3
  * @Date: 2023-05-29 13:18:19
4
4
  * @LastEditors: hcm
5
- * @LastEditTime: 2024-04-11 09:37:02
5
+ * @LastEditTime: 2024-04-12 11:51:14
6
6
  * @Description: 消息推送选择目标
7
7
  -->
8
8
  <template>
@@ -11,7 +11,7 @@
11
11
  <div v-if="!titleHide" class="mpt-title">{{ channelTypeMap[multiKey] }}</div>
12
12
  <MessageOne
13
13
  :channel-type="multiKey"
14
- :value-list="formMap[multiKey]"
14
+ :value="formMap[multiKey]"
15
15
  :box-class="boxClass"
16
16
  :target-class="targetClass"
17
17
  :type-class="typeClass"
@@ -29,7 +29,7 @@
29
29
  <!-- multiKeys null 为单框模式 -->
30
30
  <MessageOne
31
31
  v-if="!multiKeys"
32
- :value-list="formMap.value"
32
+ :value="formMap.value"
33
33
  :box-class="boxClass"
34
34
  :target-class="targetClass"
35
35
  :type-class="typeClass"
@@ -168,9 +168,19 @@ export default {
168
168
  if (this.multiKeys) {
169
169
  this.formMap[channelType] = value
170
170
  this.formNameMap[this.channelTypeMap[channelType]] = labelMap
171
+ for (const key in this.formMap) { // 去空
172
+ if (this.formMap[key].length === 0) {
173
+ delete this.formMap[key]
174
+ delete this.formNameMap[this.channelTypeMap[key]]
175
+ }
176
+ }
171
177
  this.$emit('change', this.formMap, this.formNameMap)
172
178
  } else {
173
- this.$emit('change', value, labelMap)
179
+ if (value) {
180
+ this.$emit('change', value, labelMap)
181
+ } else {
182
+ this.$emit('change', value, {})
183
+ }
174
184
  }
175
185
  },
176
186
  labelMapInit(labelMap, channelType) {
@@ -1,20 +1,20 @@
1
1
  /*
2
- * @Description:
2
+ * @Description:
3
3
  * @Author: 王国火
4
4
  * @Date: 2022-09-19 14:31:00
5
- * @LastEditTime: 2024-02-27 16:36:04
6
- * @LastEditors: hcm
5
+ * @LastEditTime: 2024-04-18 16:27:09
6
+ * @LastEditors: 王国火
7
7
  */
8
- import BaseView from "./components/basic-view/index"
9
- import FormView from "./components/form-view/index"
10
- import BytMessagePushTarget from "./components/message-push-target/index"
11
- import BytMessageOne from "./components/message-push-target/MessageOne"
8
+ import BaseView from './components/basic-view/index'
9
+ import FormView from './components/form-view/index'
10
+ import BytMessagePushTarget from './components/message-push-target/index'
11
+ import BytMessageOne from './components/message-push-target/MessageOne'
12
12
 
13
- const components=[
13
+ const components = [
14
14
  BaseView,
15
15
  FormView,
16
16
  BytMessagePushTarget,
17
17
  BytMessageOne
18
18
  ]
19
19
 
20
- export default components
20
+ export default components
package/packages/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  /*
2
- * @Description:
2
+ * @Description:
3
3
  * @Author: 王国火
4
4
  * @Date: 2022-09-15 17:02:55
5
- * @LastEditTime: 2022-10-25 09:47:57
5
+ * @LastEditTime: 2024-04-18 16:27:33
6
6
  * @LastEditors: 王国火
7
7
  */
8
8
  import Vue from 'vue'
9
- //通用组件
10
- import components from "./components.js"
11
- //公用方法
12
- import Common from "./common/index"
9
+ // 通用组件
10
+ import components from './components.js'
11
+ // 公用方法
12
+ import Common from './common/index'
13
13
 
14
14
  // 第三方依赖
15
15
  import 'xe-utils'
@@ -23,25 +23,26 @@ Vue.use(ElementUI, {
23
23
  menuType: 'text'
24
24
  })
25
25
 
26
- const Cmps={}
26
+ const Cmps = {}
27
27
  components.map(component => {
28
- Cmps[component.name]=component
28
+ Cmps[component.name] = component
29
29
  })
30
30
 
31
-
32
31
  // install组件api
33
32
  const install = function (Vue) {
34
33
  components.map(component => {
35
34
  Vue.component(component.name, component);
36
35
  })
37
- Vue.prototype.$byt=Common;
36
+ Vue.prototype.$byt = Common;
38
37
  }
39
38
 
40
-
41
- export default{
39
+ const BytUI = {
42
40
  install,
43
41
  ...Cmps,
44
42
  ...Common
45
43
  }
44
+ export default {
45
+ ...BytUI
46
+ }
46
47
 
47
- export const utils=Common
48
+ export const utils = Common