@kyfe/ks-query-table 0.0.9 → 0.0.10
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/{qt-npm/ks-query-table.common.js → index.js} +1 -1
- package/{qt-npm/ks-query-table.umd.js → ks-query-table.umd.js} +1 -1
- package/{qt-npm/ks-query-table.umd.min.js → ks-query-table.umd.min.js} +1 -1
- package/{qt-npm/ks-query-table.umd.min.js.map → ks-query-table.umd.min.js.map} +1 -1
- 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 -6
- 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/package.json +0 -13
- package/src/App.vue +0 -204
- 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 -139
- 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 -184
- 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 -841
- 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 -119
- package/src/view/home/query-table/components/pe-table/table-total.vue +0 -53
- 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 -496
- 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 -511
- 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 -115
- package/src/view/home/query-table/components/query-table/mixins/table-horizontal.js +0 -118
- 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 -128
- /package/{qt-npm/ks-query-table.common.js.map → ks-query-table.common.js.map} +0 -0
- /package/{qt-npm/ks-query-table.css → ks-query-table.css} +0 -0
- /package/{qt-npm/ks-query-table.umd.js.map → ks-query-table.umd.js.map} +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// 键盘顶出的高度
|
|
2
|
-
const getScrollTop = () => {
|
|
3
|
-
return window.pageYOffset ||
|
|
4
|
-
document.documentElement.scrollTop ||
|
|
5
|
-
document.body.scrollTop ||
|
|
6
|
-
0
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const onFocusin = (el) => {
|
|
10
|
-
// 等待键盘弹起延迟200毫秒
|
|
11
|
-
setTimeout(() => {
|
|
12
|
-
let scrollTop = getScrollTop()
|
|
13
|
-
if (scrollTop) {
|
|
14
|
-
if (el) {
|
|
15
|
-
el.style.transform = `translateY(${scrollTop}px)`
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
18
|
-
// 滚动高度0,重试一次
|
|
19
|
-
setTimeout(() => {
|
|
20
|
-
if (el) {
|
|
21
|
-
el.style.transform = `translateY(${getScrollTop()}px)`
|
|
22
|
-
}
|
|
23
|
-
}, 100)
|
|
24
|
-
}
|
|
25
|
-
}, 200)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const onFocusout = (el) => {
|
|
29
|
-
if (el) {
|
|
30
|
-
el.style.transform = 'translateY(0)'
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let timer
|
|
35
|
-
const onScroll = (el) => {
|
|
36
|
-
el.style.opacity = 0
|
|
37
|
-
clearTimeout(timer)
|
|
38
|
-
timer = setTimeout(() => {
|
|
39
|
-
el.style.transform = `translateY(${getScrollTop()}px)`
|
|
40
|
-
el.style.opacity = 1
|
|
41
|
-
}, 100)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const sticky = {
|
|
45
|
-
bind (el) {
|
|
46
|
-
if (navigator.userAgent.includes('iPhone')) {
|
|
47
|
-
document.body.addEventListener('focusin', onFocusin.bind(this, el))
|
|
48
|
-
document.body.addEventListener('focusout', onFocusout.bind(this, el))
|
|
49
|
-
window.addEventListener('scroll', onScroll.bind(this, el))
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
unbind () {
|
|
53
|
-
document.body.removeEventListener('focusin', onFocusin)
|
|
54
|
-
document.body.removeEventListener('focusout', onFocusout)
|
|
55
|
-
window.removeEventListener('scroll', onScroll)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
## 指令
|
|
2
|
-
|
|
3
|
-
### v-sticky
|
|
4
|
-
- 该指令用于解决ios平台键盘弹出时导航被顶出可视区的问题
|
|
5
|
-
|
|
6
|
-
#### 用法:
|
|
7
|
-
- 该指令已在ksui中全局注入
|
|
8
|
-
|
|
9
|
-
``` javascript
|
|
10
|
-
<header v-sticky class="ksui-header">
|
|
11
|
-
<div class="ksui-nav">
|
|
12
|
-
<ks-nav-bar
|
|
13
|
-
:title="title"
|
|
14
|
-
:left-arrow="showArrow"
|
|
15
|
-
@click-left="goBack"
|
|
16
|
-
/>
|
|
17
|
-
</div>
|
|
18
|
-
</header>
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
#### 注意:
|
|
22
|
-
- 自定义导航请参考demo项目的布局结构和定位方式使用该指令
|
|
23
|
-
- 该指令使用transform样式来修正导航的位置,使用该指令的容器要避免使用transform样式
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
let rules = []
|
|
3
|
-
let stopUpload = false
|
|
4
|
-
const vmSet = new Set()
|
|
5
|
-
const maxLength = 10
|
|
6
|
-
const wait = 2000 // ms
|
|
7
|
-
const poll = 3000 // ms
|
|
8
|
-
let pollInterval = null
|
|
9
|
-
let http = null
|
|
10
|
-
let lastCheckTime = +new Date()
|
|
11
|
-
|
|
12
|
-
const headers = {
|
|
13
|
-
'X-menu-id': '2820215716730110',
|
|
14
|
-
$config: {
|
|
15
|
-
_tips: true,
|
|
16
|
-
_log: false
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function installDRCheck(Vue) {
|
|
21
|
-
if (isProd()) return
|
|
22
|
-
if (!Vue) {
|
|
23
|
-
createEvent()
|
|
24
|
-
mixVue(window.Vue)
|
|
25
|
-
}
|
|
26
|
-
createPoll()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function createEvent() {
|
|
30
|
-
window.addEventListener('__ks_ready__', function (e) {
|
|
31
|
-
delayInit(e.detail)
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async function delayInit(option) {
|
|
36
|
-
http = option.http
|
|
37
|
-
try {
|
|
38
|
-
let data = await getRulesByHttp()
|
|
39
|
-
rules = data[0] && data[0].childrenLookupValues || []
|
|
40
|
-
if (!rules.length) failedToGetRules()
|
|
41
|
-
} catch (e) {
|
|
42
|
-
failedToGetRules()
|
|
43
|
-
console.log('[drCheck-plugin] ', e)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function failedToGetRules() {
|
|
48
|
-
rules = []
|
|
49
|
-
stopUpload = true
|
|
50
|
-
clearInterval(pollInterval)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function getRulesByHttp() {
|
|
54
|
-
return http('system.lookupValue.BatchByCode', 10124, ['sys_frontend_drcheck_h5'], { headers })
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function isProd() {
|
|
58
|
-
return window.location.origin.indexOf('www.kye-erp.com') >= 0 || window.navigator.userAgent.indexOf('prod') > 0
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function getModuleId() {
|
|
62
|
-
let erp = (window.__ERPMODULE__ && window.__ERPMODULE__.id) || ''
|
|
63
|
-
let h5 = (window.ksui && window.ksui.menu && window.ksui.menu.id) || ''
|
|
64
|
-
return erp || h5
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function mixVue(Vue) {
|
|
68
|
-
Vue.mixin({
|
|
69
|
-
mounted() {
|
|
70
|
-
let env = {
|
|
71
|
-
url: window.location.href,
|
|
72
|
-
menuId: getModuleId()
|
|
73
|
-
}
|
|
74
|
-
this.__drcheck_env__ = env
|
|
75
|
-
addVm(this)
|
|
76
|
-
// console.log('collect: ', vmSet)
|
|
77
|
-
},
|
|
78
|
-
// destroyed () {
|
|
79
|
-
// remove(this)
|
|
80
|
-
// console.log('collect: ', vmSet)
|
|
81
|
-
// }
|
|
82
|
-
})
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function addVm(vm) {
|
|
86
|
-
if (stopUpload) return
|
|
87
|
-
try {
|
|
88
|
-
vmSet.add(vm)
|
|
89
|
-
setTimeout(checkForUpload, 0)
|
|
90
|
-
resetPoll()
|
|
91
|
-
} catch (e) {
|
|
92
|
-
console.log('[drCheck-plugin] ', e)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function createPoll() {
|
|
97
|
-
pollInterval = window.setInterval(checkForUpload, poll)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function resetPoll() {
|
|
101
|
-
clearInterval(pollInterval)
|
|
102
|
-
createPoll()
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// function remove (vm) {
|
|
106
|
-
// vmSet.delete(vm)
|
|
107
|
-
// }
|
|
108
|
-
|
|
109
|
-
function checkForUpload() {
|
|
110
|
-
if (vmSet.size === 0) return
|
|
111
|
-
if (!rules.length) return
|
|
112
|
-
let isTimeout = +new Date() - lastCheckTime > wait
|
|
113
|
-
if (vmSet.size > maxLength || isTimeout) {
|
|
114
|
-
lastCheckTime = +new Date()
|
|
115
|
-
const willUpload = []
|
|
116
|
-
vmSet.forEach(vm => {
|
|
117
|
-
let props = extractDataAndProps(vm)
|
|
118
|
-
let el = vm.$el
|
|
119
|
-
let currentRule = null
|
|
120
|
-
let canUpload = rules.some(rule => {
|
|
121
|
-
try {
|
|
122
|
-
let option = {
|
|
123
|
-
props,
|
|
124
|
-
el,
|
|
125
|
-
vm
|
|
126
|
-
}
|
|
127
|
-
if (createFunction(rule.func || rule.lookupValue)(option)) {
|
|
128
|
-
currentRule = rule
|
|
129
|
-
return true
|
|
130
|
-
}
|
|
131
|
-
} catch (_) {
|
|
132
|
-
return false
|
|
133
|
-
}
|
|
134
|
-
})
|
|
135
|
-
if (canUpload) {
|
|
136
|
-
willUpload.push(extractForUpload(vm, currentRule))
|
|
137
|
-
}
|
|
138
|
-
vmSet.delete(vm)
|
|
139
|
-
})
|
|
140
|
-
upload(willUpload)
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function upload(list) {
|
|
145
|
-
if (list.length === 0) return
|
|
146
|
-
console.warn('[drCheck-plugin] will-upload: ', list)
|
|
147
|
-
try {
|
|
148
|
-
// http('cts.framework.uploadWebActionLog', 50159, list, {headers})
|
|
149
|
-
} catch (e) {
|
|
150
|
-
console.log('[drCheck-plugin] dcCheck http: ', e)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function createFunction(body) {
|
|
155
|
-
// eslint-disable-next-line
|
|
156
|
-
return new Function('option', body)
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function extractForUpload(vm, rule) {
|
|
160
|
-
let detail = ''
|
|
161
|
-
try {
|
|
162
|
-
detail = JSON.stringify(extractPrimitive(extractDataAndProps(vm)))
|
|
163
|
-
} catch (e) {
|
|
164
|
-
console.log(e)
|
|
165
|
-
detail = '[drCheck-plugin] extract error'
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
menuId: vm.__drcheck_env__.menuId,
|
|
169
|
-
url: vm.__drcheck_env__.url,
|
|
170
|
-
ruleId: rule.lookupCode,
|
|
171
|
-
tag: vm.$vnode && vm.$vnode.tag,
|
|
172
|
-
detail,
|
|
173
|
-
navigator: window.navigator.userAgent,
|
|
174
|
-
ext1: `xpath: ${getPathTo(vm.$el)}, version: ${document.lastModified}`
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function extractDataAndProps(vm) {
|
|
179
|
-
return {
|
|
180
|
-
...vm._props,
|
|
181
|
-
...vm._data
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function extractPrimitive(obj) {
|
|
186
|
-
let result = Object.create(null)
|
|
187
|
-
Object.keys(obj).forEach(k => {
|
|
188
|
-
if (isObject(obj[k])) {
|
|
189
|
-
result[k] = `_ignore_`
|
|
190
|
-
} else {
|
|
191
|
-
result[k] = obj[k]
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
return result
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function isObject(obj) {
|
|
198
|
-
return obj !== null && typeof obj === 'object'
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function getPathTo(element) {
|
|
202
|
-
if (!element) {
|
|
203
|
-
return 'Error Dom'
|
|
204
|
-
}
|
|
205
|
-
try {
|
|
206
|
-
if (element.id !== '') { return 'id("' + element.id + '")' }
|
|
207
|
-
if (element === document.body) { return element.tagName }
|
|
208
|
-
|
|
209
|
-
let ix = 0
|
|
210
|
-
let siblings = element.parentNode.childNodes
|
|
211
|
-
for (let i = 0; i < siblings.length; i++) {
|
|
212
|
-
let sibling = siblings[i]
|
|
213
|
-
if (sibling === element) { return getPathTo(element.parentNode) + '/' + element.tagName + '[' + (ix + 1) + ']' }
|
|
214
|
-
if (sibling.nodeType === 1 && sibling.tagName === element.tagName) { ix++ }
|
|
215
|
-
}
|
|
216
|
-
} catch (_) {
|
|
217
|
-
return element.tagName || 'Error Dom'
|
|
218
|
-
}
|
|
219
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 前端错误日志上报
|
|
3
|
-
*/
|
|
4
|
-
class ErrorPlugin {
|
|
5
|
-
/**
|
|
6
|
-
* @param {*} option 参数包含user、menu、type字段
|
|
7
|
-
*/
|
|
8
|
-
constructor(option = {}) {
|
|
9
|
-
this.user = option.user
|
|
10
|
-
this.menu = option.menu
|
|
11
|
-
this.type = option.type || 'H5'
|
|
12
|
-
this.platform = 'H5'
|
|
13
|
-
this.addEvent()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
addEvent() {
|
|
17
|
-
window.addEventListener('error', this.windowErrorHandler.bind(this), false)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* 处理window error报错
|
|
22
|
-
*/
|
|
23
|
-
windowErrorHandler(e) {
|
|
24
|
-
this.handleError(e.error, {
|
|
25
|
-
info: e.filename,
|
|
26
|
-
colno: e.colno,
|
|
27
|
-
lineno: e.lineno
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 处理vue报错
|
|
33
|
-
*/
|
|
34
|
-
vueErrorHandler(Vue) {
|
|
35
|
-
Vue.config.errorHandler = (error, vm, info) => {
|
|
36
|
-
if (vm) {
|
|
37
|
-
this.handleError(error, {
|
|
38
|
-
info,
|
|
39
|
-
component: vm._original && vm._original.$vnode ? vm._original.$vnode.tag : vm.$vnode.tag
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 处理react报错
|
|
47
|
-
*/
|
|
48
|
-
reactErrorHandler(error, info) {
|
|
49
|
-
this.handleError(error, {
|
|
50
|
-
info: info.componentStack,
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
handleError(error, option) {
|
|
55
|
-
if (!error) {
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
let user = this.user || (window.ksui && window.ksui.user) || {}
|
|
59
|
-
let menu = this.menu || (window.ksui && window.ksui.menu) || {}
|
|
60
|
-
let data = {
|
|
61
|
-
userId: user.id || '',
|
|
62
|
-
userName: user.name || '',
|
|
63
|
-
menuId: menu.id || '',
|
|
64
|
-
menuName: `${this.type}-${menu.title || ''}`,
|
|
65
|
-
platform: this.platform,
|
|
66
|
-
error: error && error.stack || '',
|
|
67
|
-
option: {
|
|
68
|
-
veriosn: document.lastModified,
|
|
69
|
-
url: decodeURIComponent(location.href),
|
|
70
|
-
ua: window.navigator.userAgent,
|
|
71
|
-
...option
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
this.report(data)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
report(data) {
|
|
78
|
-
data.option = JSON.stringify(data.option)
|
|
79
|
-
let headers = {
|
|
80
|
-
timestamp: Date.now(),
|
|
81
|
-
appkey: '10135'
|
|
82
|
-
}
|
|
83
|
-
// console.log('[error-log]', data)
|
|
84
|
-
// window.ks.request('syslog.frontendOperationLog.save', data, headers)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export default ErrorPlugin
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {date} date
|
|
4
|
-
* @param {string} fmt
|
|
5
|
-
*/
|
|
6
|
-
export const date = (date, fmt = 'YYYY-MM-DD HH:mm:ss') => {
|
|
7
|
-
var o = {
|
|
8
|
-
'M+': date.getMonth() + 1,
|
|
9
|
-
'D+': date.getDate(),
|
|
10
|
-
'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12,
|
|
11
|
-
'H+': date.getHours(),
|
|
12
|
-
'm+': date.getMinutes(),
|
|
13
|
-
's+': date.getSeconds(),
|
|
14
|
-
'q+': Math.floor((date.getMonth() + 3) / 3),
|
|
15
|
-
'S': date.getMilliseconds()
|
|
16
|
-
}
|
|
17
|
-
var week = {
|
|
18
|
-
'0': '\u65e5',
|
|
19
|
-
'1': '\u4e00',
|
|
20
|
-
'2': '\u4e8c',
|
|
21
|
-
'3': '\u4e09',
|
|
22
|
-
'4': '\u56db',
|
|
23
|
-
'5': '\u4e94',
|
|
24
|
-
'6': '\u516d'
|
|
25
|
-
}
|
|
26
|
-
if (/(Y+)/.test(fmt)) {
|
|
27
|
-
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
|
|
28
|
-
}
|
|
29
|
-
if (/(E+)/.test(fmt)) {
|
|
30
|
-
fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? '\u661f\u671f' : '\u5468') : '') + week[date.getDay() + ''])
|
|
31
|
-
}
|
|
32
|
-
for (var k in o) {
|
|
33
|
-
if (new RegExp('(' + k + ')').test(fmt)) {
|
|
34
|
-
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return fmt
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// 102000 -> 10万2千
|
|
41
|
-
export const numberSplit = val => {
|
|
42
|
-
if (!val) return val
|
|
43
|
-
let toNumberVal = Number(val)
|
|
44
|
-
if (isNaN(toNumberVal)) {
|
|
45
|
-
return val
|
|
46
|
-
}
|
|
47
|
-
let flag = ''
|
|
48
|
-
if (toNumberVal < 0) {
|
|
49
|
-
flag = '-'
|
|
50
|
-
toNumberVal = Math.abs(toNumberVal)
|
|
51
|
-
}
|
|
52
|
-
if (toNumberVal >= 10000) {
|
|
53
|
-
// 大于等于10000的数据要去掉小数位
|
|
54
|
-
const numStr = Math.floor(toNumberVal) + ''
|
|
55
|
-
const len = numStr.length
|
|
56
|
-
const numArr = []
|
|
57
|
-
// 每4位截取一次,截取小于10000部分的数据
|
|
58
|
-
let itemLast = Number(numStr.substring(len - 4, len))
|
|
59
|
-
// 只有个位数前面要加0 等于0则去掉,不加入数组拼接
|
|
60
|
-
if (itemLast < 10 && itemLast > 0) {
|
|
61
|
-
numArr.unshift('0' + itemLast)
|
|
62
|
-
} else if (itemLast >= 10) {
|
|
63
|
-
numArr.unshift(itemLast)
|
|
64
|
-
}
|
|
65
|
-
let itemCenter = 0
|
|
66
|
-
let itemFirst = 0
|
|
67
|
-
if (len <= 8) {
|
|
68
|
-
// 长度小于等于8, 没有亿位,这个时候万位可以从index = 0 开始截取
|
|
69
|
-
itemCenter = Number(numStr.substring(0, len - 4))
|
|
70
|
-
} else {
|
|
71
|
-
// 长度大于8才有亿, 万位不能再从index = 0开始截取
|
|
72
|
-
itemCenter = Number(numStr.substring(len - 8, len - 4))
|
|
73
|
-
itemFirst = Number(numStr.substring(0, len - 8))
|
|
74
|
-
}
|
|
75
|
-
// 万位和亿位如果大于0才加入数组拼接
|
|
76
|
-
if (itemCenter > 0) numArr.unshift(itemCenter + '万')
|
|
77
|
-
if (itemFirst > 0) numArr.unshift(itemFirst + '亿')
|
|
78
|
-
return flag + numArr.join('')
|
|
79
|
-
}
|
|
80
|
-
return flag + toNumberVal
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export const numberSplitFloat = (val, decimal = 2) => {
|
|
84
|
-
// 防止空字符返回为0
|
|
85
|
-
if (val === '') return val
|
|
86
|
-
let toNumberVal = Number(val)
|
|
87
|
-
if (isNaN(toNumberVal)) {
|
|
88
|
-
return val
|
|
89
|
-
}
|
|
90
|
-
let flag = ''
|
|
91
|
-
if (toNumberVal < 0) {
|
|
92
|
-
flag = '-'
|
|
93
|
-
toNumberVal = Math.abs(toNumberVal)
|
|
94
|
-
}
|
|
95
|
-
const numStrArr = String(toNumberVal).split('.')
|
|
96
|
-
const numStr = numStrArr[0]
|
|
97
|
-
const _decimal = decimal !== undefined ? decimal : (numStrArr[1] && numStrArr[1].length) || ''
|
|
98
|
-
const decimalNum = numStrArr[1] && decimal >= 1 ? `.${numStrArr[1].substring(0, _decimal)}` : ''
|
|
99
|
-
if (toNumberVal >= 10000) {
|
|
100
|
-
const len = numStr.length
|
|
101
|
-
const numArr = []
|
|
102
|
-
// 每4位截取一次,截取小于10000部分的数据
|
|
103
|
-
let itemLast = Number(numStr.substring(len - 4, len))
|
|
104
|
-
// 只有个位数前面要加0 等于0则去掉,不加入数组拼接
|
|
105
|
-
if (itemLast < 10 && itemLast > 0) {
|
|
106
|
-
numArr.unshift('0' + itemLast)
|
|
107
|
-
} else if (itemLast >= 10) {
|
|
108
|
-
numArr.unshift(itemLast)
|
|
109
|
-
}
|
|
110
|
-
let itemCenter = 0
|
|
111
|
-
let itemFirst = 0
|
|
112
|
-
if (len <= 8) {
|
|
113
|
-
// 长度小于等于8, 没有亿位,这个时候万位可以从index = 0 开始截取
|
|
114
|
-
itemCenter = Number(numStr.substring(0, len - 4))
|
|
115
|
-
} else {
|
|
116
|
-
// 长度大于8才有亿, 万位不能再从index = 0开始截取
|
|
117
|
-
itemCenter = Number(numStr.substring(len - 8, len - 4))
|
|
118
|
-
itemFirst = Number(numStr.substring(0, len - 8))
|
|
119
|
-
}
|
|
120
|
-
// 万位和亿位如果大于0才加入数组拼接
|
|
121
|
-
if (itemCenter > 0) numArr.unshift(itemCenter + '万')
|
|
122
|
-
if (itemFirst > 0) numArr.unshift(itemFirst + '亿')
|
|
123
|
-
return flag + numArr.join('') + decimalNum
|
|
124
|
-
}
|
|
125
|
-
return flag + Math.floor(toNumberVal) + decimalNum
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export function formatMoneySeparators(number, decimal = 2) {
|
|
129
|
-
if (number === '') return number
|
|
130
|
-
number = Number(number)
|
|
131
|
-
if (typeof number !== 'number') {
|
|
132
|
-
throw new Error('Input must be a number')
|
|
133
|
-
}
|
|
134
|
-
const parts = truncateDecimals(number, decimal).toString().split('.')
|
|
135
|
-
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
136
|
-
return parts.join('.')
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function hasDecimal(number) {
|
|
140
|
-
return Number.isFinite(number) && number % 1 !== 0
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function truncateDecimals(number, decimal) {
|
|
144
|
-
if (!hasDecimal(number)) return number
|
|
145
|
-
const factor = Math.pow(10, decimal)
|
|
146
|
-
return Math.floor(number * factor) / factor
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const Toast = window.vant && window.vant.Toast
|
|
2
|
-
/**
|
|
3
|
-
* 响应拦截-针对接口响应添加了灰度标识,判断路由meta标识是否需要弹窗提示接口正在灰度
|
|
4
|
-
*/
|
|
5
|
-
export function handleResponseGrayTips (response) {
|
|
6
|
-
const data = typeof response.data === 'object' ? response.data : {}
|
|
7
|
-
const method = response.config.headers.method || response.config.url
|
|
8
|
-
if (data.code === 0) {
|
|
9
|
-
// 判断该接口是否存在灰度标识
|
|
10
|
-
if (response.headers['x-framework-isgray'] && response.headers['x-framework-isgray'] === '1') {
|
|
11
|
-
// 灰度标识接口且判断当前路由meta是否配置弹窗
|
|
12
|
-
if (window.isCheckApiGray) {
|
|
13
|
-
Toast(`${method}接口正在灰度`)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return response
|
|
18
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { getToken } from './token'
|
|
2
|
-
import { md5Http, random, getXWebTraceId, isKSClient, getKsEnvUrl } from './common'
|
|
3
|
-
import { handleResponseGrayTips } from './http-interceptors'
|
|
4
|
-
import adapter from './axios-adapter.js'
|
|
5
|
-
import bus from './bus'
|
|
6
|
-
|
|
7
|
-
const axios = window.axios
|
|
8
|
-
const Toast = window.vant && window.vant.Toast
|
|
9
|
-
|
|
10
|
-
let TIMEOUT = 20000
|
|
11
|
-
|
|
12
|
-
let getErrors = function () {
|
|
13
|
-
return {
|
|
14
|
-
'Network Error': '网络错误,请检查网络',
|
|
15
|
-
[`timeout of ${TIMEOUT}ms exceeded`]: window.networkTimeoutMessage || '请求超时,服务器未响应',
|
|
16
|
-
'Internal Server Error': '请求服务器错误',
|
|
17
|
-
'Request failed with status code 502': '请求服务器错误',
|
|
18
|
-
api: '接口错误'
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let baseUrl = '/router/rest'
|
|
23
|
-
|
|
24
|
-
const isKsClient = isKSClient()
|
|
25
|
-
|
|
26
|
-
// 判断请求是不是ajax 类型
|
|
27
|
-
const isKsHttpByAJAX = window.__KSUICONFIGHTTP === 'ajax'
|
|
28
|
-
|
|
29
|
-
// 在容器且为 ajax 请求时需要手动设置 baseUrl
|
|
30
|
-
if (isKsClient && isKsHttpByAJAX) {
|
|
31
|
-
baseUrl = getKsEnvUrl() + '/router/rest'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let options = {
|
|
35
|
-
baseURL: baseUrl,
|
|
36
|
-
timeout: TIMEOUT,
|
|
37
|
-
headers: { 'format': 'JSON' }
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!isKsHttpByAJAX) {
|
|
41
|
-
options = isKsClient ? { ...options, adapter } : options
|
|
42
|
-
} else {
|
|
43
|
-
// 走 ajax 请求需要关闭自定义上报 http 至 APM
|
|
44
|
-
window.__APMCUSTOMHTTP = true
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const httpClient = axios.create(options)
|
|
48
|
-
|
|
49
|
-
httpClient.interceptors.request.use(config => {
|
|
50
|
-
// headers对象中设置_tips属性,合并到config中并从headers中删除
|
|
51
|
-
let $config = config.headers.$config
|
|
52
|
-
if ($config) {
|
|
53
|
-
config.$config = { ...$config }
|
|
54
|
-
delete config.headers.$config
|
|
55
|
-
}
|
|
56
|
-
bus.$emit('httpStart', config)
|
|
57
|
-
return config
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
httpClient.interceptors.response.use(handleResponseGrayTips)
|
|
61
|
-
|
|
62
|
-
httpClient.interceptors.response.use(res => {
|
|
63
|
-
bus.$emit('httpEnd', res)
|
|
64
|
-
if (String(res.data.code) === '0') {
|
|
65
|
-
return res.data.data
|
|
66
|
-
}
|
|
67
|
-
// options参数中有_tips属性不提示错误
|
|
68
|
-
if (res.config.$config === undefined || res.config.$config._tips === undefined) {
|
|
69
|
-
Toast(res.data.msg)
|
|
70
|
-
}
|
|
71
|
-
return Promise.reject(res)
|
|
72
|
-
}, error => {
|
|
73
|
-
const msg = error.message || error.msg
|
|
74
|
-
const config = error._config || {}
|
|
75
|
-
if (msg && (config.$config === undefined || config.$config._tips === undefined)) {
|
|
76
|
-
const ERRORS = getErrors()
|
|
77
|
-
error.message = ERRORS[msg] || msg || ERRORS.api
|
|
78
|
-
Toast(error.message)
|
|
79
|
-
}
|
|
80
|
-
return Promise.reject(error)
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* @param {string} method 开放平台的apiCode
|
|
88
|
-
* @param {number | string} appkey 开放平台的appkey
|
|
89
|
-
* @param {object} data
|
|
90
|
-
* @param {object} options 其他配置
|
|
91
|
-
*/
|
|
92
|
-
const http = async (method, appkey, data, options) => {
|
|
93
|
-
|
|
94
|
-
if (options && options.timeout) {
|
|
95
|
-
TIMEOUT = options.timeout
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
let token = getToken()
|
|
99
|
-
let menu = window.ksui.menu || { id: '156439900739872047', title: '股票' }
|
|
100
|
-
|
|
101
|
-
// 先从window上获取user,没有再调sdk获取
|
|
102
|
-
let user = window.ksui && window.ksui.user
|
|
103
|
-
if (!(user && user.id)) {
|
|
104
|
-
user = { id: '' }
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
let now = Date.now()
|
|
108
|
-
let headers = {
|
|
109
|
-
method,
|
|
110
|
-
appkey,
|
|
111
|
-
token,
|
|
112
|
-
timestamp: now,
|
|
113
|
-
sign: md5Http(token, now, data),
|
|
114
|
-
'X-menu-id': menu.id,
|
|
115
|
-
webTraceId: `${user.id}-${now}-${random(4)}-${menu.id || 'xxxx'}`,
|
|
116
|
-
'x-webtrace-id': getXWebTraceId(user.id, menu.id, now)
|
|
117
|
-
}
|
|
118
|
-
if (options && options.headers) {
|
|
119
|
-
headers = { ...headers, ...options.headers }
|
|
120
|
-
}
|
|
121
|
-
let config = {
|
|
122
|
-
url: `?${method}`,
|
|
123
|
-
method: 'POST',
|
|
124
|
-
data,
|
|
125
|
-
...options,
|
|
126
|
-
headers,
|
|
127
|
-
}
|
|
128
|
-
return httpClient(config)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// 换token
|
|
132
|
-
const token = (data) => {
|
|
133
|
-
let headers = {
|
|
134
|
-
method: 'cas.oauth.ticketValidate',
|
|
135
|
-
appkey: 10184
|
|
136
|
-
}
|
|
137
|
-
return httpClient({ method: 'POST', data, headers })
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export { http, token }
|