@kyfe/ks-query-table 0.0.22 → 0.0.23
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/index.js +11 -0
- package/package.json +10 -81
- package/.bitmap +0 -38
- package/.editorconfig +0 -5
- package/.env.dev +0 -2
- package/.env.gray +0 -2
- package/.env.prod +0 -2
- package/.env.stg +0 -3
- package/.env.uat +0 -2
- package/.eslintignore +0 -1
- package/.eslintrc.js +0 -25
- package/.gitmodules +0 -4
- package/.prettierrc +0 -11
- package/README.md +0 -15
- package/babel.config.js +0 -10
- package/build-apm.sh +0 -9
- package/build.sh +0 -16
- package/config/index.js +0 -20
- package/jsconfig.json +0 -7
- package/kuasheng-sdk/index.js +0 -80
- package/kuasheng-sdk/lib/assets.js +0 -304
- package/kuasheng-sdk/lib/context.js +0 -199
- package/kuasheng-sdk/lib/layout.js +0 -346
- package/kuasheng-sdk/lib/location.js +0 -46
- package/kuasheng-sdk/lib/media.js +0 -342
- package/kuasheng-sdk/lib/navigation.js +0 -30
- package/kuasheng-sdk/lib/request.js +0 -76
- package/kuasheng-sdk/lib/system.js +0 -190
- package/kuasheng-sdk/lib/userinfo.js +0 -98
- package/kuasheng-sdk/util/check.js +0 -102
- package/kuasheng-sdk/util/config.js +0 -47
- package/kuasheng-sdk/util/device.js +0 -25
- package/kuasheng-sdk/util/error.js +0 -19
- package/kuasheng-sdk/util/funtional.js +0 -153
- package/kuasheng-sdk/util/mixin.js +0 -36
- package/kuasheng-sdk/util/requestUtil.js +0 -41
- package/kuasheng-sdk/util/response.js +0 -33
- package/kuasheng-sdk/util/warn.js +0 -35
- package/kuasheng-ui/CHANGELOG.md +0 -9
- package/kuasheng-ui/components/card.vue +0 -57
- package/kuasheng-ui/components/ks-area-select/README.md +0 -43
- package/kuasheng-ui/components/ks-area-select/area-picker.vue +0 -554
- package/kuasheng-ui/components/ks-area-select/area-search.vue +0 -363
- package/kuasheng-ui/components/ks-area-select/areas-pop.vue +0 -56
- package/kuasheng-ui/components/ks-area-select/common.js +0 -183
- package/kuasheng-ui/components/ks-area-select/index.vue +0 -355
- package/kuasheng-ui/components/ks-area-select/mixins.js +0 -216
- package/kuasheng-ui/components/ks-area-single-select/README.md +0 -50
- package/kuasheng-ui/components/ks-area-single-select/hot-city.js +0 -45
- package/kuasheng-ui/components/ks-area-single-select/index.vue +0 -324
- package/kuasheng-ui/components/ks-calendar/index.vue +0 -269
- package/kuasheng-ui/components/ks-call-phone/call-tips.vue +0 -70
- package/kuasheng-ui/components/ks-call-phone/call.vue +0 -178
- package/kuasheng-ui/components/ks-call-phone/index.js +0 -48
- package/kuasheng-ui/components/ks-call-phone/index.vue +0 -131
- package/kuasheng-ui/components/ks-call-phone//345/221/274/345/217/253/347/273/204/344/273/266.md +0 -0
- package/kuasheng-ui/components/ks-date-picker/README.md +0 -23
- package/kuasheng-ui/components/ks-date-picker/date-picker-bottom.vue +0 -123
- package/kuasheng-ui/components/ks-date-picker/date-picker-dropdown.vue +0 -80
- package/kuasheng-ui/components/ks-date-picker/date-picker-right.vue +0 -87
- package/kuasheng-ui/components/ks-date-picker/date-picker-top.vue +0 -88
- package/kuasheng-ui/components/ks-date-picker/date-picker.js +0 -15
- package/kuasheng-ui/components/ks-date-picker/date-range-select.vue +0 -92
- package/kuasheng-ui/components/ks-date-picker/date-select.vue +0 -65
- package/kuasheng-ui/components/ks-date-picker/date-week-month.vue +0 -131
- package/kuasheng-ui/components/ks-date-picker/index.js +0 -12
- package/kuasheng-ui/components/ks-date-picker/mixin.js +0 -92
- package/kuasheng-ui/components/ks-date-picker/month-range-select.vue +0 -129
- package/kuasheng-ui/components/ks-date-picker/month-select.vue +0 -85
- package/kuasheng-ui/components/ks-date-picker/quarter-select.vue +0 -94
- package/kuasheng-ui/components/ks-date-picker/style.less +0 -121
- package/kuasheng-ui/components/ks-date-picker/utils.js +0 -109
- package/kuasheng-ui/components/ks-date-picker/week-select.vue +0 -99
- package/kuasheng-ui/components/ks-decrypt/index.vue +0 -159
- package/kuasheng-ui/components/ks-employee/README.md +0 -78
- package/kuasheng-ui/components/ks-employee/employee-input.vue +0 -173
- package/kuasheng-ui/components/ks-employee/employee-list.vue +0 -662
- package/kuasheng-ui/components/ks-employee/employee-popup.vue +0 -197
- package/kuasheng-ui/components/ks-employee/employee-search.vue +0 -250
- package/kuasheng-ui/components/ks-employee/employee-selected.vue +0 -173
- package/kuasheng-ui/components/ks-employee/index.js +0 -17
- package/kuasheng-ui/components/ks-employee/package-lock.json +0 -5
- package/kuasheng-ui/components/ks-employee/package.json +0 -15
- package/kuasheng-ui/components/ks-employee/yarn.lock +0 -4
- package/kuasheng-ui/components/ks-field-money/index.js +0 -8
- package/kuasheng-ui/components/ks-field-money/index.vue +0 -212
- package/kuasheng-ui/components/ks-field-money/package.json +0 -11
- package/kuasheng-ui/components/ks-field-money/utils.js +0 -65
- package/kuasheng-ui/components/ks-field-money//351/207/221/351/242/235/350/275/254/346/215/242/345/231/250.md +0 -0
- package/kuasheng-ui/components/ks-history-search/history-input.vue +0 -131
- package/kuasheng-ui/components/ks-history-search/history-list.vue +0 -188
- package/kuasheng-ui/components/ks-history-search/img/delete.png +0 -0
- package/kuasheng-ui/components/ks-history-search/index.js +0 -9
- package/kuasheng-ui/components/ks-history-search/index.vue +0 -125
- package/kuasheng-ui/components/ks-history-search/package-lock.json +0 -5
- package/kuasheng-ui/components/ks-history-search/package.json +0 -15
- package/kuasheng-ui/components/ks-history-search/utils.js +0 -35
- package/kuasheng-ui/components/ks-input-search/index.vue +0 -106
- package/kuasheng-ui/components/ks-list/index.vue +0 -75
- package/kuasheng-ui/components/ks-loading/index.js +0 -16
- package/kuasheng-ui/components/ks-month/index.vue +0 -47
- package/kuasheng-ui/components/ks-month/package.json +0 -3
- package/kuasheng-ui/components/ks-month/range.vue +0 -172
- package/kuasheng-ui/components/ks-month/single.vue +0 -136
- package/kuasheng-ui/components/ks-month/style.less +0 -125
- package/kuasheng-ui/components/ks-month/utils.js +0 -35
- package/kuasheng-ui/components/ks-nav/index.vue +0 -264
- package/kuasheng-ui/components/ks-nav-bar.js +0 -35
- package/kuasheng-ui/components/ks-org/ks-org-tree.vue +0 -247
- package/kuasheng-ui/components/ks-org/ks-popup-tree.vue +0 -154
- package/kuasheng-ui/components/ks-org/ks-tree-input.vue +0 -240
- package/kuasheng-ui/components/ks-org/ks-tree-node.vue +0 -94
- package/kuasheng-ui/components/ks-org/ks-tree.vue +0 -229
- package/kuasheng-ui/components/ks-org/utils.js +0 -54
- package/kuasheng-ui/components/ks-popover/index.vue +0 -457
- package/kuasheng-ui/components/ks-popover/mixin.js +0 -28
- package/kuasheng-ui/components/ks-popover/utils.js +0 -60
- package/kuasheng-ui/components/ks-pull-refresh/index.vue +0 -43
- package/kuasheng-ui/components/ks-quarter/index.vue +0 -256
- package/kuasheng-ui/components/ks-table/README.md +0 -103
- package/kuasheng-ui/components/ks-table/cell.vue +0 -31
- package/kuasheng-ui/components/ks-table/index.js +0 -8
- package/kuasheng-ui/components/ks-table/index.less +0 -486
- package/kuasheng-ui/components/ks-table/index.vue +0 -1088
- package/kuasheng-ui/components/ks-table/package.json +0 -12
- package/kuasheng-ui/components/ks-table/release.md +0 -7
- package/kuasheng-ui/components/ks-toast.js +0 -35
- package/kuasheng-ui/components/ks-upload/index.vue +0 -174
- package/kuasheng-ui/components/ks-user-access.vue +0 -229
- package/kuasheng-ui/components/no-data/README.md +0 -45
- package/kuasheng-ui/components/no-data/image.js +0 -1
- package/kuasheng-ui/components/no-data/index.vue +0 -83
- package/kuasheng-ui/components/notice-bar.vue +0 -16
- package/kuasheng-ui/components/steps.js +0 -11
- package/kuasheng-ui/components/tabs.vue +0 -40
- package/kuasheng-ui/index.js +0 -239
- package/kuasheng-ui/patch/datetime-picker/datetimePicker.md +0 -0
- package/kuasheng-ui/patch/datetime-picker/index.js +0 -46
- package/kuasheng-ui/patch/datetime-picker/utils.js +0 -78
- package/kuasheng-ui/patch/field/field.md +0 -1
- package/kuasheng-ui/patch/field/index.js +0 -122
- package/kuasheng-ui/patch/field/utils.js +0 -36
- package/kuasheng-ui/patch/form/form.md +0 -7
- package/kuasheng-ui/patch/form/index.js +0 -106
- package/kuasheng-ui/patch/index.js +0 -12
- package/kuasheng-ui/patch/pagination/index.js +0 -78
- package/kuasheng-ui/style/animation-ui.less +0 -31
- package/kuasheng-ui/style/font/number/font-number1.otf +0 -0
- package/kuasheng-ui/style/font/number/font-number2.ttf +0 -0
- package/kuasheng-ui/style/images/checked.svg +0 -1
- package/kuasheng-ui/style/images/success.svg +0 -1
- package/kuasheng-ui/style/index.less +0 -6
- package/kuasheng-ui/style/kuasheng-ui.less +0 -207
- package/kuasheng-ui/style/reset-vant.less +0 -307
- package/kuasheng-ui/style/vant-var.less +0 -138
- package/kuasheng-ui/utils/apis.js +0 -17
- package/kuasheng-ui/utils/axios-adapter.js +0 -47
- package/kuasheng-ui/utils/bem.js +0 -39
- package/kuasheng-ui/utils/bus.js +0 -97
- package/kuasheng-ui/utils/common.js +0 -88
- package/kuasheng-ui/utils/decrypt/config.js +0 -12
- package/kuasheng-ui/utils/decrypt/decrypt-api.js +0 -139
- package/kuasheng-ui/utils/decrypt/index.js +0 -6
- package/kuasheng-ui/utils/decrypt/mask.js +0 -36
- package/kuasheng-ui/utils/decrypt/virtual.js +0 -44
- package/kuasheng-ui/utils/directive.js +0 -57
- package/kuasheng-ui/utils/directive.md +0 -23
- package/kuasheng-ui/utils/drcheck-plugin.js +0 -219
- package/kuasheng-ui/utils/error-plugin.js +0 -88
- package/kuasheng-ui/utils/filter.js +0 -149
- package/kuasheng-ui/utils/http-interceptors.js +0 -18
- package/kuasheng-ui/utils/http.js +0 -140
- package/kuasheng-ui/utils/index.js +0 -5
- package/kuasheng-ui/utils/init-event.js +0 -20
- package/kuasheng-ui/utils/log.js +0 -309
- package/kuasheng-ui/utils/token.js +0 -9
- package/kuasheng-ui/utils/type.js +0 -45
- package/kuasheng-ui/utils/validate.js +0 -20
- package/kuasheng-ui/utils/watermark.js +0 -67
- package/kuasheng-ui/version.js +0 -1
- package/ky-apm/client.js +0 -37
- package/ky-apm/customHttp.js +0 -38
- package/ky-apm/index.js +0 -68
- package/ky-apm/plugins/performance.js +0 -84
- package/ky-apm/plugins/self-error.js +0 -26
- package/ky-apm/warn-log.js +0 -3
- package/plugin/ks-chii-webpack-html/index.js +0 -53
- package/plugin/ks-chii-webpack-html/package.json +0 -16
- package/postcss.config.js +0 -15
- package/public/capsule-positon.js +0 -50
- package/public/fonts/DingTalkJinBuTi.ttf +0 -0
- package/public/framework/axios@0.19.0.min.js +0 -9
- package/public/framework/fastclick@1.0.6.min.js +0 -1
- package/public/framework/iconfont/iconfont.css +0 -91
- package/public/framework/iconfont/iconfont.js +0 -1
- package/public/framework/iconfont/iconfont.json +0 -142
- package/public/framework/iconfont/iconfont.ttf +0 -0
- package/public/framework/iconfont/iconfont.woff +0 -0
- package/public/framework/iconfont/iconfont.woff2 +0 -0
- package/public/framework/vant@2.5.6.min.js +0 -7
- package/public/framework/vue-router@3.1.3.min.js +0 -6
- package/public/framework/vue@2.6.10.runtime.min.js +0 -6
- package/public/framework/vuex@3.1.1.min.js +0 -6
- package/public/index.html +0 -260
- package/public/ks@3.0.8.umd.min.js +0 -1
- package/public/ksui@4.0.27.umd.min.js +0 -10
- package/public/status-bar-preset.js +0 -39
- package/qt-npm/index.js +0 -11
- package/qt-npm/package.json +0 -13
- package/src/App.vue +0 -204
- package/src/README.md +0 -15
- package/src/common/README.md +0 -94
- package/src/common/http/axios-adapter.js +0 -47
- package/src/common/http/common.js +0 -88
- package/src/common/http/http-interceptors.js +0 -18
- package/src/common/http/http-lock.js +0 -45
- package/src/common/http/index.js +0 -163
- package/src/common/http/token.js +0 -9
- package/src/common/styles/font/AlibabaSans102Ver2-Md.ttf +0 -0
- package/src/common/styles/font.less +0 -12
- package/src/common/styles/variables.less +0 -43
- package/src/common/utils/index.js +0 -1
- package/src/common/utils/platform/README.md +0 -1
- package/src/common/utils/platform/android/.gitkeep +0 -0
- package/src/common/utils/platform/core/index.js +0 -24
- package/src/common/utils/platform/index.js +0 -164
- package/src/common/utils/platform/ios/.gitkeep +0 -0
- package/src/common/utils/platform/subscribe/helper.js +0 -38
- package/src/common/utils/platform/subscribe/index.js +0 -204
- package/src/common/utils/platform/subscribe/table-animation.js +0 -75
- package/src/config/index.js +0 -31
- package/src/config.js +0 -1
- package/src/main.js +0 -73
- package/src/router.js +0 -52
- package/src/view/home/config.js +0 -101
- package/src/view/home/demo1.vue +0 -223
- package/src/view/home/demo2.vue +0 -124
- package/src/view/home/demo3.vue +0 -51
- package/src/view/home/demo4.vue +0 -140
- package/src/view/home/index.vue +0 -97
- package/src/view/home/query-table/README.md +0 -45
- package/src/view/home/query-table/api/index.js +0 -12
- package/src/view/home/query-table/assets/horizontal-back.svg +0 -1
- package/src/view/home/query-table/components/pe-table/cell.js +0 -181
- package/src/view/home/query-table/components/pe-table/collapse.js +0 -334
- package/src/view/home/query-table/components/pe-table/empty.vue +0 -48
- package/src/view/home/query-table/components/pe-table/header.js +0 -328
- package/src/view/home/query-table/components/pe-table/images/abnormal.png +0 -0
- package/src/view/home/query-table/components/pe-table/images/empty.png +0 -0
- package/src/view/home/query-table/components/pe-table/images/fold.svg +0 -1
- package/src/view/home/query-table/components/pe-table/images/sort.svg +0 -1
- package/src/view/home/query-table/components/pe-table/images/sorting.svg +0 -1
- package/src/view/home/query-table/components/pe-table/images/unfold.svg +0 -1
- package/src/view/home/query-table/components/pe-table/index.vue +0 -847
- package/src/view/home/query-table/components/pe-table/load-more.js +0 -46
- package/src/view/home/query-table/components/pe-table/props/index.js +0 -193
- package/src/view/home/query-table/components/pe-table/row.vue +0 -118
- package/src/view/home/query-table/components/pe-table/scrollbar.js +0 -424
- package/src/view/home/query-table/components/pe-table/stretch-damping.js +0 -112
- package/src/view/home/query-table/components/pe-table/style/cell.less +0 -89
- package/src/view/home/query-table/components/pe-table/style/empty.less +0 -48
- package/src/view/home/query-table/components/pe-table/style/header.less +0 -141
- package/src/view/home/query-table/components/pe-table/style/index.less +0 -88
- package/src/view/home/query-table/components/pe-table/style/load-more.less +0 -61
- package/src/view/home/query-table/components/pe-table/style/row.less +0 -6
- package/src/view/home/query-table/components/pe-table/table-loading.vue +0 -120
- package/src/view/home/query-table/components/pe-table/table-total.vue +0 -57
- package/src/view/home/query-table/components/pe-table/utils/animate.js +0 -80
- package/src/view/home/query-table/components/pe-table/utils/columns.js +0 -290
- package/src/view/home/query-table/components/pe-table/utils/data.js +0 -12
- package/src/view/home/query-table/components/pe-table/utils/fixed.js +0 -69
- package/src/view/home/query-table/components/pe-table/utils/formatter.js +0 -327
- package/src/view/home/query-table/components/pe-table/utils/render-cells.js +0 -424
- package/src/view/home/query-table/components/pe-table/utils/slot.js +0 -28
- package/src/view/home/query-table/components/pe-table/utils/tools.js +0 -84
- package/src/view/home/query-table/components/pe-table/utils/touch-scroll.js +0 -417
- package/src/view/home/query-table/components/query-table/index.vue +0 -497
- package/src/view/home/query-table/components/query-table/mixins/column-mixin.js +0 -102
- package/src/view/home/query-table/components/query-table/mixins/column-setting.js +0 -143
- package/src/view/home/query-table/components/query-table/mixins/data-mixin.js +0 -519
- package/src/view/home/query-table/components/query-table/mixins/pagination-mixin.js +0 -26
- package/src/view/home/query-table/components/query-table/mixins/table-fixed.js +0 -130
- package/src/view/home/query-table/components/query-table/mixins/table-horizontal.js +0 -119
- package/src/view/home/query-table/components/table-horizontal.vue +0 -99
- package/src/view/home/query-table/components/table-pagination.vue +0 -32
- package/src/view/home/query-table/components/table-settings/assets/arrpw-up.svg +0 -1
- package/src/view/home/query-table/components/table-settings/assets/disabled-down.svg +0 -1
- package/src/view/home/query-table/components/table-settings/assets/disabled-up.svg +0 -1
- package/src/view/home/query-table/components/table-settings/assets/down.svg +0 -1
- package/src/view/home/query-table/components/table-settings/assets/up.svg +0 -1
- package/src/view/home/query-table/components/table-settings/index.less +0 -294
- package/src/view/home/query-table/components/table-settings/index.vue +0 -260
- package/src/view/home/query-table/components/table-settings/settings.vue +0 -479
- package/src/view/home/query-table/components/table-settings/test.js +0 -626
- package/src/view/home/query-table/components/table-settings//344/270/252/346/200/247/350/256/276/347/275/256.md +0 -0
- package/src/view/home/query-table/components/tooltip.js +0 -124
- package/src/view/home/query-table/hooks/use-cache-promise.js +0 -27
- package/src/view/home/query-table/hooks/use-column-config.js +0 -190
- package/src/view/home/query-table/hooks/use-encryption.js +0 -0
- package/src/view/home/query-table/hooks/use-generic-search.js +0 -95
- package/src/view/home/query-table/index.js +0 -7
- package/src/view/home/query-table/store/column-store.js +0 -0
- package/src/view/home/query-table/styles/table.less +0 -24
- package/src/view/home/query-table/utils/column.js +0 -36
- package/src/view/home/query-table/utils/config.js +0 -12
- package/src/view/home/query-table/utils/encryption.js +0 -32
- package/src/view/home/query-table/utils/http.js +0 -1
- package/src/view/home/query-table/utils/localStorage.js +0 -35
- package/src/view/home//351/246/226/351/241/265.md +0 -0
- package/src/web.js +0 -99
- package/vue.config.js +0 -131
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {http} from './http'
|
|
2
|
-
// 检查request有没有加载
|
|
3
|
-
export function initEvent() {
|
|
4
|
-
if (window.ks && window.ks.request) {
|
|
5
|
-
dispatchEvent()
|
|
6
|
-
} else {
|
|
7
|
-
setTimeout(() => {
|
|
8
|
-
if (window.ks && window.ks.request) {
|
|
9
|
-
_dispatchEvent()
|
|
10
|
-
} else {
|
|
11
|
-
initEvent()
|
|
12
|
-
}
|
|
13
|
-
}, 300)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function _dispatchEvent() {
|
|
17
|
-
window.dispatchEvent(new CustomEvent('__ks_ready__', {
|
|
18
|
-
detail: {http}
|
|
19
|
-
}))
|
|
20
|
-
}
|
package/kuasheng-ui/utils/log.js
DELETED
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
import bus from './bus'
|
|
2
|
-
import { getToken } from './token'
|
|
3
|
-
import { md5Http, getKsEnv } from './common'
|
|
4
|
-
// import {http} from './http'
|
|
5
|
-
|
|
6
|
-
const axios = window.axios
|
|
7
|
-
const API_CODE = 'cts.trace.uploadWebActionLog'
|
|
8
|
-
|
|
9
|
-
const collectApiMap = {
|
|
10
|
-
uat: 'https://collect-uat.ky-express.com/json/collector',
|
|
11
|
-
prd: 'https://collect.ky-express.com/json/collector'
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
class LogPlugin {
|
|
15
|
-
constructor (option = {}) {
|
|
16
|
-
this.userId = option.userId
|
|
17
|
-
this.menuId = option.menuId
|
|
18
|
-
this.countThreshold = option.countThreshold || 10
|
|
19
|
-
this.timeThreshold = option.timeThreshold || 10 //秒
|
|
20
|
-
this.sizeThreshold = option.sizeThreshold || 10 //kb
|
|
21
|
-
this.deounceThreshold = option.deounceThreshold || 300 //毫秒
|
|
22
|
-
this.uploadDebouncTime = null
|
|
23
|
-
this.initTime = Date.now()
|
|
24
|
-
this.reportList = []
|
|
25
|
-
this.lastActionName = ''
|
|
26
|
-
this.lastActionId = ''
|
|
27
|
-
this.immediateReport = false
|
|
28
|
-
this.ignoreUrl = [API_CODE].concat(option.ignoreUrl || [])
|
|
29
|
-
this.ignoreClass = ['log-disabled','el-dialog__wrapper','main-panel'].concat(option.ignoreClass || [])
|
|
30
|
-
this.ignoreTag = ['canvas'].concat(option.ignoreTag || [])
|
|
31
|
-
this.init()
|
|
32
|
-
// this.firstReport()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
init () {
|
|
36
|
-
this.ignoreUrl.push('mcs.user.menu.access.report')
|
|
37
|
-
window.setInterval(this.checkReport.bind(this), this.timeThreshold * 1000)
|
|
38
|
-
this.addEventListener()
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
setOption(option) {
|
|
42
|
-
Object.keys(option).forEach(item => {
|
|
43
|
-
if (this.hasOwnProperty(item)) {
|
|
44
|
-
this[item] = option[item]
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
console.log(this)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async reportOnInit() {
|
|
51
|
-
let menu = window.ksui && window.ksui.menu
|
|
52
|
-
let info = await window.ks.getUserInfo()
|
|
53
|
-
let user = info.userInfo || {}
|
|
54
|
-
let userId = this.userId || user.id
|
|
55
|
-
if (!userId || !menu.id) {
|
|
56
|
-
console.warn(`[log-plugin 首次上报] userId或menuId未获取到`)
|
|
57
|
-
return
|
|
58
|
-
}
|
|
59
|
-
let report = this.getNormalizerReport()
|
|
60
|
-
report.menuId = menu.id
|
|
61
|
-
report.userId = userId
|
|
62
|
-
report.location = 'h5'
|
|
63
|
-
report.navigator = navigator.appVersion || navigator.userAgent
|
|
64
|
-
report.navigator = report.navigator + ' KSUI:' + window.ksui.version
|
|
65
|
-
report.xpath = this.makeActionId()
|
|
66
|
-
report.action = '首次进入'
|
|
67
|
-
report.startTime = String(this.initTime)
|
|
68
|
-
report.endTime = '0'
|
|
69
|
-
report.url = 'h5'
|
|
70
|
-
report.httpStatus = '200'
|
|
71
|
-
// `${user.id}-${now}-${random(4)}-${menu.id || 'xxxx'}`
|
|
72
|
-
report.webTraceId = `${userId}-${menu && menu.id || 'xxxx'}-${String(this.initTime)}-${this.lastActionId || this.randomCode()}-${Math.floor(1000 + 1000 * Math.random())}`
|
|
73
|
-
// report.webTraceId = userId + '-' + Date.now() + '-' + Math.floor(1000 + 1000 * Math.random()) + '-' + menu.id
|
|
74
|
-
report.requestHeaders = `${userId}-${String(menu.id)}-${String(this.initTime)}`
|
|
75
|
-
report.resCode = 0
|
|
76
|
-
console.log('首次上报', report)
|
|
77
|
-
report.immediate = true
|
|
78
|
-
this.reportList.push(report)
|
|
79
|
-
this.checkReport()
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
firstReport() {
|
|
83
|
-
if (window.ks && window.ks.request) {
|
|
84
|
-
this.reportOnInit()
|
|
85
|
-
} else {
|
|
86
|
-
setTimeout(() => {
|
|
87
|
-
if (window.ks && window.ks.request) {
|
|
88
|
-
this.reportOnInit()
|
|
89
|
-
} else {
|
|
90
|
-
this.firstReport()
|
|
91
|
-
}
|
|
92
|
-
}, 10)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
getNormalizerReport () {
|
|
97
|
-
return {
|
|
98
|
-
xpath: '', // 事件id
|
|
99
|
-
action: '', // 事件名称
|
|
100
|
-
userId: this.userId || window.ksui && window.ksui.user && window.ksui.user.id,
|
|
101
|
-
menuId: '',
|
|
102
|
-
startTime: '',
|
|
103
|
-
endTime: '',
|
|
104
|
-
url: '',
|
|
105
|
-
requestHeaders: '', // 模块首次进入时间
|
|
106
|
-
requestBody: '', // 弃用
|
|
107
|
-
responseHeaders: '', // 弃用
|
|
108
|
-
responseData: '', // 弃用
|
|
109
|
-
httpStatus: '',
|
|
110
|
-
webTraceId: '',
|
|
111
|
-
resCode: '',
|
|
112
|
-
immediate: this.immediateReport
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
checkReport () {
|
|
117
|
-
|
|
118
|
-
if (this.reportList.some(item => item.immediate)) {
|
|
119
|
-
console.log(`[log-plugin] 触发立即上报`)
|
|
120
|
-
this.upload()
|
|
121
|
-
this.clear()
|
|
122
|
-
return
|
|
123
|
-
}
|
|
124
|
-
if (this.uploadDebouncTime) {
|
|
125
|
-
clearTimeout(this.uploadDebouncTime)
|
|
126
|
-
}
|
|
127
|
-
if (this.reportList.length >= this.countThreshold) {
|
|
128
|
-
console.log(`[log-plugin] 达到采集条数: ${this.countThreshold}上报`)
|
|
129
|
-
this.upload()
|
|
130
|
-
this.clear()
|
|
131
|
-
} else {
|
|
132
|
-
this.uploadDebouncTime = setTimeout(() => {
|
|
133
|
-
this.upload()
|
|
134
|
-
this.clear()
|
|
135
|
-
}, this.deounceThreshold)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
clear () {
|
|
140
|
-
this.reportList = []
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
upload () {
|
|
144
|
-
if (!this.reportList.length) return
|
|
145
|
-
const data = this.reportList
|
|
146
|
-
const token = getToken()
|
|
147
|
-
const menu = window.ksui.menu
|
|
148
|
-
const env = getKsEnv()
|
|
149
|
-
const now = Date.now()
|
|
150
|
-
const headers = {
|
|
151
|
-
// timestamp: Date.now(),
|
|
152
|
-
// $config: {
|
|
153
|
-
// _tips: false
|
|
154
|
-
// }
|
|
155
|
-
format: 'JSON',
|
|
156
|
-
method: API_CODE,
|
|
157
|
-
appkey: '50159',
|
|
158
|
-
token: getToken(),
|
|
159
|
-
timestamp: now,
|
|
160
|
-
'X-Env': env || 'uat',
|
|
161
|
-
'X-menu-id': menu.id,
|
|
162
|
-
sign: md5Http(token, now, data)
|
|
163
|
-
}
|
|
164
|
-
const BaseUrl = collectApiMap[env] || collectApiMap['uat']
|
|
165
|
-
axios({
|
|
166
|
-
method: 'post',
|
|
167
|
-
url: `${BaseUrl}?${API_CODE}`,
|
|
168
|
-
data,
|
|
169
|
-
headers
|
|
170
|
-
}).then(() => {
|
|
171
|
-
console.log(`[log-plugin] 日志上报成功`)
|
|
172
|
-
}).catch(error => {
|
|
173
|
-
console.log(error)
|
|
174
|
-
console.log(`[log-plugin] 日志上报失败`)
|
|
175
|
-
})
|
|
176
|
-
// http(API_CODE, 50159, data, {headers}).then(() => {
|
|
177
|
-
// console.log(`[log-plugin] 日志上报成功`)
|
|
178
|
-
// }).catch(error => {
|
|
179
|
-
// console.log(error)
|
|
180
|
-
// console.log(`[log-plugin] 日志上报失败`)
|
|
181
|
-
// })
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
makeReport(axiosResponse) {
|
|
185
|
-
let ua = navigator.appVersion || navigator.userAgent
|
|
186
|
-
let config = axiosResponse.config
|
|
187
|
-
let menuId = this.menuId || config.headers['X-menu-id']
|
|
188
|
-
let report = this.getNormalizerReport()
|
|
189
|
-
if (!report.userId) {
|
|
190
|
-
console.warn(`[log-plugin] userId未获取到,请设置userId: ksui.log.userId = "用户id"`)
|
|
191
|
-
return false
|
|
192
|
-
}
|
|
193
|
-
if (!menuId) {
|
|
194
|
-
console.warn(`[log-plugin] menuId未获取到,请设置menuId: ksui.log.menuId = "菜单id"`)
|
|
195
|
-
return false
|
|
196
|
-
}
|
|
197
|
-
if (!/^[0-9]+$/.test(menuId)) {
|
|
198
|
-
console.warn(`[log-plugin] menuId格式错误: ${menuId}, 应该是全数字`)
|
|
199
|
-
return false
|
|
200
|
-
}
|
|
201
|
-
report.menuId = String(menuId)
|
|
202
|
-
report.location = config.location || ''
|
|
203
|
-
report.navigator = ua
|
|
204
|
-
report.xpath = config.lastActionId || ''
|
|
205
|
-
report.action = config.lastActionName || ''
|
|
206
|
-
report.startTime = String(config.startTime || 0)
|
|
207
|
-
report.endTime = String(Date.now())
|
|
208
|
-
report.url = config.url || ''
|
|
209
|
-
report.httpStatus = String(axiosResponse.status || '')
|
|
210
|
-
report.webTraceId = config.headers['x-webtrace-id']
|
|
211
|
-
report.requestHeaders = `${report.userId}-${String(menuId)}-${String(this.initTime)}`
|
|
212
|
-
if (axiosResponse.data && axiosResponse.data.code !== undefined) {
|
|
213
|
-
report.resCode = String(axiosResponse.data.code)
|
|
214
|
-
}
|
|
215
|
-
return report
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
collectRequest (config) {
|
|
219
|
-
config.startTime = config.headers.timestamp || Date.now()
|
|
220
|
-
config.lastActionName = this.lastActionName
|
|
221
|
-
config.lastActionId = this.lastActionId
|
|
222
|
-
config.location = location.host
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
collectResponse (axiosResponse) {
|
|
226
|
-
let conf = axiosResponse.config
|
|
227
|
-
// 过滤掉不走开放平台的接口,第三方接口不采集
|
|
228
|
-
if (!conf.headers || !conf.headers.method) {
|
|
229
|
-
return
|
|
230
|
-
}
|
|
231
|
-
// 过滤掉标注为不上报日志的接口
|
|
232
|
-
if (conf.$config && conf.$config._log === false) {
|
|
233
|
-
return
|
|
234
|
-
}
|
|
235
|
-
// 过滤不上报的method
|
|
236
|
-
if (this.ignoreUrl.some(url => conf.headers.method.indexOf(url) >= 0) || this.ignoreUrl.some(url => conf.url.indexOf(url) >= 0)) {
|
|
237
|
-
return
|
|
238
|
-
}
|
|
239
|
-
if (conf.lastActionName && conf.lastActionId ) {
|
|
240
|
-
let report = this.makeReport(axiosResponse)
|
|
241
|
-
if (report) {
|
|
242
|
-
this.immediateReport = false
|
|
243
|
-
this.reportList.push(report)
|
|
244
|
-
this.checkReport()
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
randomCode () {
|
|
250
|
-
let id = this.userId || window.ksui && window.ksui.user && window.ksui.user.id || ''
|
|
251
|
-
return '' + id + Date.now() + Math.floor(1000 + 1000 * Math.random())
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
isIgnore (dom) {
|
|
255
|
-
if (!dom) return true
|
|
256
|
-
let classList = dom.className
|
|
257
|
-
let tagName = dom.tagName && dom.tagName.toLocaleLowerCase()
|
|
258
|
-
let ignore = this.ignoreClass.some(c => typeof classList === 'string' && classList.indexOf(c) >= 0) || this.ignoreTag.some(t => tagName.indexOf(t) >= 0)
|
|
259
|
-
return ignore
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
handleEvent (e) {
|
|
263
|
-
if (this.isIgnore(e.target)) {
|
|
264
|
-
this.lastActionName = ''
|
|
265
|
-
this.lastActionId = ''
|
|
266
|
-
} else {
|
|
267
|
-
let text = e.target.textContent || ''
|
|
268
|
-
this.lastActionName = text ? text.trim().replace(/\s/g, '').substr(0, 10) : text
|
|
269
|
-
this.lastActionId = this.randomCode()
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// 自定义日志事件名称
|
|
274
|
-
click (option = {}) {
|
|
275
|
-
if (typeof option === 'string') {
|
|
276
|
-
this.lastActionName = option
|
|
277
|
-
return
|
|
278
|
-
}
|
|
279
|
-
if (option.actionName) {
|
|
280
|
-
this.lastActionName = option.actionName
|
|
281
|
-
}
|
|
282
|
-
if (option.actionId) {
|
|
283
|
-
this.lastActionId = option.actionId
|
|
284
|
-
}
|
|
285
|
-
if (option.immediate) {
|
|
286
|
-
this.immediateReport = option.immediate
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
addEventListener () {
|
|
291
|
-
document.addEventListener('click', this.handleEvent.bind(this), true)
|
|
292
|
-
bus.$on('httpStart', this.collectRequest.bind(this))
|
|
293
|
-
bus.$on('httpEnd', this.collectResponse.bind(this))
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
makeActionId() {
|
|
297
|
-
return this.randomCode()
|
|
298
|
-
}
|
|
299
|
-
// httpStart(request) {
|
|
300
|
-
// this.collectRequest(request)
|
|
301
|
-
// }
|
|
302
|
-
|
|
303
|
-
// httpEnd(response) {
|
|
304
|
-
// this.collectResponse(response)
|
|
305
|
-
// }
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export default new LogPlugin()
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export const toString = Object.prototype.toString;
|
|
2
|
-
|
|
3
|
-
export const is = (type, primitive = false) => {
|
|
4
|
-
return function (obj) {
|
|
5
|
-
return primitive
|
|
6
|
-
? typeof obj === type.toLowerCase()
|
|
7
|
-
: toString.call(obj) === `[object ${type}]`;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @method 检测当前类型是否为函数
|
|
13
|
-
* @param item 检测当前类型
|
|
14
|
-
* @returns { Boolean } 如果是函数则返回true、否则返回false
|
|
15
|
-
*/
|
|
16
|
-
export function isFunction(item) {
|
|
17
|
-
return is('Function')(item);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @method 检测当前类型是否为字符串
|
|
22
|
-
* @param item 检测当前类型
|
|
23
|
-
* @returns { Boolean } 如果是字符串则返回true、否则返回false
|
|
24
|
-
*/
|
|
25
|
-
export function isString(item) {
|
|
26
|
-
return is('String', true)(item);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @method 检测当前类型是否为数字
|
|
31
|
-
* @param item 检测当前类型
|
|
32
|
-
* @returns { Boolean } 如果是数字则返回true、否则返回false
|
|
33
|
-
*/
|
|
34
|
-
export function isNumber(item) {
|
|
35
|
-
return is('Number', true)(item);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @method 检测当前类型是否为布尔
|
|
40
|
-
* @param item 检测当前类型
|
|
41
|
-
* @returns { Boolean } 如果是布尔则返回true、否则返回false
|
|
42
|
-
*/
|
|
43
|
-
export function isBoolean(item) {
|
|
44
|
-
return is('Boolean', true)(item);
|
|
45
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const valid = (data, schema) => {
|
|
2
|
-
Object.keys(schema).forEach(key => {
|
|
3
|
-
validate(data[key], schema[key])
|
|
4
|
-
})
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const validate = (value, rules) => {
|
|
8
|
-
rules.forEach(rule => {
|
|
9
|
-
Object.keys(rule).forEach(item => {
|
|
10
|
-
[item](value, rule[item])
|
|
11
|
-
})
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const type = (value, type) => {
|
|
16
|
-
if (typeof value === type) {
|
|
17
|
-
return true
|
|
18
|
-
}
|
|
19
|
-
return false
|
|
20
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// 添加自定义水印
|
|
2
|
-
export const customWatermark = (text = '', el = '.ksui-container, .van-dialog, .ksui-card, .ks-table', color = 'rgba(0,0,0,0.1)', rotate = 30) => {
|
|
3
|
-
let canvas = document.createElement('canvas')
|
|
4
|
-
let ctx = canvas.getContext('2d')
|
|
5
|
-
ctx.font = '100 12px PingFangSC'
|
|
6
|
-
// 角度转弧度
|
|
7
|
-
rotate = (rotate * Math.PI) / 180
|
|
8
|
-
let text1 = ''
|
|
9
|
-
let text2 = ''
|
|
10
|
-
// text参数是数组则文本分两行
|
|
11
|
-
if (Array.isArray(text)) {
|
|
12
|
-
text1 = text[0]
|
|
13
|
-
text2 = text[1]
|
|
14
|
-
} else {
|
|
15
|
-
text1 = text
|
|
16
|
-
}
|
|
17
|
-
let text1Width = ctx.measureText(text1).width
|
|
18
|
-
let text2Width = ctx.measureText(text2).width
|
|
19
|
-
let l = text1Width > text2Width ? text1Width : text2Width
|
|
20
|
-
// 将文本长度作为斜边求两个直角边
|
|
21
|
-
let top = Math.floor(l * Math.sin(rotate))
|
|
22
|
-
let left = Math.floor(l * Math.cos(rotate))
|
|
23
|
-
|
|
24
|
-
let dpr = window.devicePixelRatio
|
|
25
|
-
const cssWidth = left + 50
|
|
26
|
-
const cssHeight = top + 80
|
|
27
|
-
|
|
28
|
-
// canvas.style.width = cssWidth + 'px'
|
|
29
|
-
// canvas.style.height = cssHeight + 'px'
|
|
30
|
-
|
|
31
|
-
canvas.width = cssWidth * dpr
|
|
32
|
-
canvas.height = cssHeight * dpr
|
|
33
|
-
|
|
34
|
-
ctx.scale(dpr, dpr)
|
|
35
|
-
ctx.fillStyle = color
|
|
36
|
-
ctx.textBaseline = 'middle'
|
|
37
|
-
ctx.rotate(-rotate)
|
|
38
|
-
ctx.fillText(text1, 0, top)
|
|
39
|
-
ctx.fillText(text2, 0, top + 10)
|
|
40
|
-
|
|
41
|
-
let encode = canvas.toDataURL('image/png')
|
|
42
|
-
let style = document.createElement('style')
|
|
43
|
-
style.type = 'text/css'
|
|
44
|
-
style.innerHTML = `${el}{background-image:url(${encode});background-size: ${cssWidth}px ${cssHeight}px;}`
|
|
45
|
-
document.querySelector('head').appendChild(style)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 添加水印方法,调用ksui.watermark
|
|
50
|
-
* @param {string} employeeNumber 工号
|
|
51
|
-
* @param {sting} el css选择器
|
|
52
|
-
* @param {string} color 水印文字颜色(格式rgba)
|
|
53
|
-
*/
|
|
54
|
-
const watermark = (employeeNumber = '', el = '.ksui-container, .van-dialog, .ksui-card, .ks-table', color = '#F0F3F9') => {
|
|
55
|
-
let date = new Date()
|
|
56
|
-
const f = num => {
|
|
57
|
-
let str = String(num)
|
|
58
|
-
return str.length === 1 ? '0' + str : str
|
|
59
|
-
}
|
|
60
|
-
let text = [
|
|
61
|
-
`${employeeNumber}`,
|
|
62
|
-
`${date.getFullYear()}/${f(date.getMonth() + 1)}/${f(date.getDate())} ${f(date.getHours())}:${f(date.getMinutes())}:${f(date.getSeconds())}`
|
|
63
|
-
]
|
|
64
|
-
customWatermark(text, el, color)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export default watermark
|
package/kuasheng-ui/version.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default '3.0.43'
|
package/ky-apm/client.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ky-apm 采集上报模块
|
|
3
|
-
* 白名单 white-list
|
|
4
|
-
* http
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
import {warnLog} from './warn-log';
|
|
8
|
-
|
|
9
|
-
class Client {
|
|
10
|
-
constructor(appConfig) {
|
|
11
|
-
this.appConfig = appConfig;
|
|
12
|
-
}
|
|
13
|
-
getConfig() {
|
|
14
|
-
return this.appConfig
|
|
15
|
-
}
|
|
16
|
-
// 上报模块
|
|
17
|
-
reportData (data) {
|
|
18
|
-
// 判断类型(轻应用、erp、自定义上传)
|
|
19
|
-
try {
|
|
20
|
-
if (this.appConfig.customReport && typeof this.appConfig.customReport === 'function') {
|
|
21
|
-
this.appConfig.customReport(data)
|
|
22
|
-
} else if (this.appConfig.app === 'apm-ks') {
|
|
23
|
-
// 轻应用
|
|
24
|
-
window.ksui && window.ksui.http(this.appConfig.reportUrl, this.appConfig.appkey, data)
|
|
25
|
-
} else if (this.appConfig.app === 'apm-erp') {
|
|
26
|
-
// 铸剑(需要将铸剑的http实例传入)
|
|
27
|
-
if (this.appConfig.$http && typeof this.appConfig.$http === 'function') {
|
|
28
|
-
this.appConfig.$http(this.appConfig.reportUrl, data, { log: false, cancel: true, appkey: this.appConfig.appkey })
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
console.log('[kyApm上报成功]')
|
|
32
|
-
} catch (error) {
|
|
33
|
-
warnLog(error)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
export default Client
|
package/ky-apm/customHttp.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// 该 js 是提供给客户端帮忙注入到轻应用,hook了请求,自定义上报请求到 apm 平台(走原生请求采集不到请求日志)
|
|
2
|
-
if (window.ks && window.ks.request && !window.__APMCUSTOMHTTP) {
|
|
3
|
-
window.ks.request = function (method, body = {}, headers = {}) {
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
window.ks.callFunc({
|
|
6
|
-
method: 'request',
|
|
7
|
-
params: {
|
|
8
|
-
method,
|
|
9
|
-
body,
|
|
10
|
-
headers
|
|
11
|
-
}
|
|
12
|
-
}).then(resp => {
|
|
13
|
-
resolve(resp)
|
|
14
|
-
try {
|
|
15
|
-
if (window._apm ) {
|
|
16
|
-
let now = Date.now()
|
|
17
|
-
const rt = now - headers.timestamp
|
|
18
|
-
window._apm('sendAPILog', {
|
|
19
|
-
url: method || '', // 请求地址
|
|
20
|
-
method: 2, // 请求类型:2=POST
|
|
21
|
-
rc: 200, // 请求状态
|
|
22
|
-
rt: rt,
|
|
23
|
-
traceid: headers.webTraceId || '',
|
|
24
|
-
req_body: '',
|
|
25
|
-
req_query: ''
|
|
26
|
-
})
|
|
27
|
-
window.__APMCUSTOMHTTP = true
|
|
28
|
-
console.log('上报apm自定义')
|
|
29
|
-
}
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error('【apm自定义上报http错误】:', error)
|
|
32
|
-
}
|
|
33
|
-
}).catch(err => {
|
|
34
|
-
reject(err)
|
|
35
|
-
})
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
}
|
package/ky-apm/index.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ky-apm 采集上报模块
|
|
3
|
-
* 白名单 white-list
|
|
4
|
-
* http
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
import {warnLog} from './warn-log';
|
|
8
|
-
import Client from './client'
|
|
9
|
-
import SelfError from './plugins/self-error.js'
|
|
10
|
-
import PerformancePlugin from './plugins/performance.js'
|
|
11
|
-
var plugins = [PerformancePlugin]
|
|
12
|
-
var defaultConfig = {
|
|
13
|
-
reportUrl: 'fmk.monitor.frontexception.log.report',
|
|
14
|
-
appkey: '55212',
|
|
15
|
-
performance: { // 性能相关参数
|
|
16
|
-
durationTime: 2000, // 性能采集的统计时长阀值
|
|
17
|
-
},
|
|
18
|
-
navigator: navigator && navigator.userAgent || '',
|
|
19
|
-
app: 'apm-ks', // apm-ks, apm-erp
|
|
20
|
-
module: '', // 当前模块名称
|
|
21
|
-
userName: '', // 当前用户姓名
|
|
22
|
-
userId: '', // 当前用户userId
|
|
23
|
-
logType: 'performance', // 性能采集: performance
|
|
24
|
-
logId: 'kyApm',
|
|
25
|
-
whiteList: [] // 需要监控的白名单userId列表
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
var kyApm = {
|
|
29
|
-
init (config = {}) {
|
|
30
|
-
try {
|
|
31
|
-
if (this.isInit) {
|
|
32
|
-
warnLog('KyApm已经初始化,请勿重复初始化!')
|
|
33
|
-
return false
|
|
34
|
-
}
|
|
35
|
-
if (config.whiteList && config.whiteList.length && !config.whiteList.includes(config.userId)) {
|
|
36
|
-
warnLog('该用户不在收集白名单中,KyApm不采集数据!')
|
|
37
|
-
return false
|
|
38
|
-
}
|
|
39
|
-
this.isInit = false
|
|
40
|
-
this.config = { ...defaultConfig, ...config }
|
|
41
|
-
this.client = new Client(this.config)
|
|
42
|
-
this.selfError = new SelfError(this.client, this.config)
|
|
43
|
-
this.initPlugins(this.client, this.selfError)
|
|
44
|
-
this.isInit = true
|
|
45
|
-
console.log('KyApm初始化成功')
|
|
46
|
-
} catch (error) {
|
|
47
|
-
console.log('----', this.selfError)
|
|
48
|
-
warnLog(error)
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
initPlugins (client, selfError) {
|
|
52
|
-
try {
|
|
53
|
-
plugins.forEach(plugin => {
|
|
54
|
-
new plugin(client, selfError)
|
|
55
|
-
})
|
|
56
|
-
} catch (error) {
|
|
57
|
-
this.selfError.error(error)
|
|
58
|
-
warnLog(error)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 浏览器环境直接挂载插件
|
|
64
|
-
if (typeof window !== 'undefined' && !window.kyApm) {
|
|
65
|
-
window.kyApm = kyApm
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export default kyApm
|