@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
package/src/common/http/index.js
DELETED
|
@@ -1,163 +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 axios from 'axios'
|
|
6
|
-
import { CanceledError } from 'axios'
|
|
7
|
-
import fetchAdapter from '@vespaiach/axios-fetch-adapter'
|
|
8
|
-
// import bus from './bus'
|
|
9
|
-
|
|
10
|
-
// const axios = window.axios
|
|
11
|
-
const Toast = window.vant && window.vant.Toast
|
|
12
|
-
const bus = ksui.bus || { $emit: () => {} }
|
|
13
|
-
|
|
14
|
-
let TIMEOUT = 20000
|
|
15
|
-
|
|
16
|
-
let getErrors = function () {
|
|
17
|
-
return {
|
|
18
|
-
'Network Error': '网络错误,请检查网络',
|
|
19
|
-
[`timeout of ${TIMEOUT}ms exceeded`]: window.networkTimeoutMessage || '请求超时,服务器未响应',
|
|
20
|
-
'Internal Server Error': '请求服务器错误',
|
|
21
|
-
'Request failed with status code 502': '请求服务器错误',
|
|
22
|
-
api: '接口错误',
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let baseUrl = '/router/rest'
|
|
27
|
-
|
|
28
|
-
const isKsClient = isKSClient()
|
|
29
|
-
|
|
30
|
-
const isHttp2 = window.__KSUICONFIGHTTP === 'http2'
|
|
31
|
-
// 判断请求是不是ajax 类型
|
|
32
|
-
const isKsHttpByAJAX = isHttp2 || window.__KSUICONFIGHTTP === 'ajax'
|
|
33
|
-
|
|
34
|
-
// 在容器且为 ajax 请求时需要手动设置 baseUrl
|
|
35
|
-
if (isKsClient && isKsHttpByAJAX) {
|
|
36
|
-
baseUrl = getKsEnvUrl() + '/router/rest'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let options = {
|
|
40
|
-
baseURL: baseUrl,
|
|
41
|
-
timeout: TIMEOUT,
|
|
42
|
-
headers: { format: 'JSON' },
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!isKsHttpByAJAX) {
|
|
46
|
-
options = isKsClient ? { ...options, adapter } : options
|
|
47
|
-
} else {
|
|
48
|
-
// 走 ajax 请求需要关闭自定义上报 http 至 APM
|
|
49
|
-
window.__APMCUSTOMHTTP = true
|
|
50
|
-
if (isHttp2) {
|
|
51
|
-
options = { ...options, adapter: fetchAdapter }
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const httpClient = axios.create(options)
|
|
56
|
-
|
|
57
|
-
httpClient.interceptors.request.use(config => {
|
|
58
|
-
// 记录请求的时间戳
|
|
59
|
-
config.metadata = { startTime: Date.now() }
|
|
60
|
-
|
|
61
|
-
// headers对象中设置_tips属性,合并到config中并从headers中删除
|
|
62
|
-
let $config = config.headers.$config
|
|
63
|
-
if ($config) {
|
|
64
|
-
config.$config = { ...$config }
|
|
65
|
-
delete config.headers.$config
|
|
66
|
-
}
|
|
67
|
-
bus.$emit('httpStart', config)
|
|
68
|
-
return config
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
httpClient.interceptors.response.use(handleResponseGrayTips)
|
|
72
|
-
|
|
73
|
-
httpClient.interceptors.response.use(res => {
|
|
74
|
-
bus.$emit('httpEnd', res)
|
|
75
|
-
if (String(res.data.code) === '0') {
|
|
76
|
-
return res.data.data
|
|
77
|
-
}
|
|
78
|
-
// options参数中有_tips属性不提示错误
|
|
79
|
-
if (res.config.$config === undefined || res.config.$config._tips === undefined) {
|
|
80
|
-
Toast(res.data.msg || ERRORS.api)
|
|
81
|
-
}
|
|
82
|
-
return Promise.reject(res)
|
|
83
|
-
}, error => {
|
|
84
|
-
try {
|
|
85
|
-
const msg = error.message || error.msg
|
|
86
|
-
const config = error._config || error.config || {}
|
|
87
|
-
|
|
88
|
-
const endTime = Date.now()
|
|
89
|
-
const startTime = error.config?.metadata?.startTime || 0
|
|
90
|
-
|
|
91
|
-
const apiUrl = 'Unknown'
|
|
92
|
-
// 进行错误信息的上报
|
|
93
|
-
|
|
94
|
-
if (msg && (config.$config === undefined || config.$config._tips === undefined)) {
|
|
95
|
-
const ERRORS = getErrors()
|
|
96
|
-
error.message = ERRORS[msg] || msg || ERRORS.api
|
|
97
|
-
if (error instanceof CanceledError) return Promise.reject(error)
|
|
98
|
-
Toast(error.message)
|
|
99
|
-
}
|
|
100
|
-
return Promise.reject(error)
|
|
101
|
-
} catch (error) {
|
|
102
|
-
return Promise.reject(error)
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
*
|
|
110
|
-
* @param {string} method 开放平台的apiCode
|
|
111
|
-
* @param {number | string} appkey 开放平台的appkey
|
|
112
|
-
* @param {object} data
|
|
113
|
-
* @param {object} options 其他配置
|
|
114
|
-
*/
|
|
115
|
-
const http = async (method, appkey, data, options) => {
|
|
116
|
-
|
|
117
|
-
if (options && options.timeout) {
|
|
118
|
-
TIMEOUT = options.timeout
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
let token = getToken()
|
|
122
|
-
let menu = window.ksui.menu
|
|
123
|
-
|
|
124
|
-
// 先从window上获取user,没有再调sdk获取
|
|
125
|
-
let user = window.ksui && window.ksui.user
|
|
126
|
-
if (!(user && user.id)) {
|
|
127
|
-
user = {id: ''}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
let now = Date.now()
|
|
131
|
-
let headers = {
|
|
132
|
-
method,
|
|
133
|
-
appkey,
|
|
134
|
-
token,
|
|
135
|
-
timestamp: now,
|
|
136
|
-
sign: md5Http(token, now, data),
|
|
137
|
-
'X-menu-id': menu.id,
|
|
138
|
-
webTraceId: `${user.id}-${now}-${random(4)}-${menu.id || 'xxxx'}`,
|
|
139
|
-
// 'x-webtrace-id': getXWebTraceId(user.id, menu.id, now)
|
|
140
|
-
}
|
|
141
|
-
if (options && options.headers) {
|
|
142
|
-
headers = {...headers, ...options.headers}
|
|
143
|
-
}
|
|
144
|
-
let config = {
|
|
145
|
-
url: `?${method}`,
|
|
146
|
-
method: 'POST',
|
|
147
|
-
data,
|
|
148
|
-
...options,
|
|
149
|
-
headers,
|
|
150
|
-
}
|
|
151
|
-
return httpClient(config)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// 换token
|
|
155
|
-
const token = data => {
|
|
156
|
-
let headers = {
|
|
157
|
-
method: 'cas.oauth.ticketValidate',
|
|
158
|
-
appkey: 10184,
|
|
159
|
-
}
|
|
160
|
-
return httpClient({ method: 'POST', data, headers })
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export { http, token }
|
package/src/common/http/token.js
DELETED
|
Binary file
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// 主题色
|
|
4
|
-
// @C1-brand-01: #FCDDD4;
|
|
5
|
-
// @C1-brand-00: #FEF2EE;
|
|
6
|
-
// @C1-brand-02: #FAB9A9;
|
|
7
|
-
// @C1-brand-03: #F79380;
|
|
8
|
-
// @C1-brand-04: #F56B57;
|
|
9
|
-
// @C1-brand-05: #F2412F;
|
|
10
|
-
// @C1-brand-06: #CE2C22;
|
|
11
|
-
// @C1-brand-07: #AB1B17;
|
|
12
|
-
// @C1-brand-08: #870E0F;
|
|
13
|
-
// @C1-brand-09: #63070B;
|
|
14
|
-
|
|
15
|
-
@C9-gray-00: #F7F8FA;
|
|
16
|
-
@C9-gray-01: #F2F3F5;
|
|
17
|
-
@C9-gray-02: #E5E4E4;
|
|
18
|
-
@C9-gray-03: #C2C0C0;
|
|
19
|
-
@C9-gray-04: #9E9C9C;
|
|
20
|
-
@C9-gray-05: #7B7878;
|
|
21
|
-
@C9-gray-06: #575555;
|
|
22
|
-
@C9-gray-07: #3A3536;
|
|
23
|
-
@C9-gray-08: #2C2727;
|
|
24
|
-
@C9-gray-09: #1D1919;
|
|
25
|
-
@C9-gray-10: #FFFFFF;
|
|
26
|
-
@C9-gray-11: rgba(255, 255, 255, 0.4);
|
|
27
|
-
@C9-gray-12: #F1F1F1;
|
|
28
|
-
@C9-gray-13: #DEDEDE;
|
|
29
|
-
@C1-brand-00: #FEF2EE;
|
|
30
|
-
@C1-brand-01: #FCDDD4;
|
|
31
|
-
@C1-brand-02: #FAB9A9;
|
|
32
|
-
@C1-brand-03: #F79380;
|
|
33
|
-
@C1-brand-04: #F56B57;
|
|
34
|
-
@C1-brand-05: #F2412F;
|
|
35
|
-
@C1-brand-06: #CE2C22;
|
|
36
|
-
@C1-brand-07: #AB1B17;
|
|
37
|
-
@C1-brand-08: #870E0F;
|
|
38
|
-
@C1-brand-09: #63070B;
|
|
39
|
-
@C1-brand-10: #fff4f3;
|
|
40
|
-
@C10-Light-gray-01: rgba(29, 25, 25, 0.4);
|
|
41
|
-
|
|
42
|
-
// 字体
|
|
43
|
-
@import "./font.less";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./platform";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
平台能力调用
|
|
File without changes
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import isEmpty from 'lodash/isEmpty'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @description ks callFunc
|
|
6
|
-
* @param {string} method
|
|
7
|
-
* @param {object} params
|
|
8
|
-
* @returns {unknown}
|
|
9
|
-
*/
|
|
10
|
-
export function callFunc(method, params) {
|
|
11
|
-
console.info(`🦕 Call Function`, { method, params })
|
|
12
|
-
|
|
13
|
-
return window.ks.callFunc({ method, params })
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @description ks JsStock callFunc
|
|
18
|
-
* @param {string} method
|
|
19
|
-
* @param {array} params
|
|
20
|
-
*/
|
|
21
|
-
export function jsStockCallFunc(method, params = []) {
|
|
22
|
-
if (isEmpty(method)) return false
|
|
23
|
-
window.jsStock && window.jsStock[method] && window.jsStock[method](...params)
|
|
24
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { callFunc, jsStockCallFunc } from './core'
|
|
2
|
-
import store from '@/store/index.js'
|
|
3
|
-
/**
|
|
4
|
-
* @description 跳转 0 股票 or 指数 1 详情页 2 K线弹窗
|
|
5
|
-
* @param { 0 | 1} type
|
|
6
|
-
* @param {{
|
|
7
|
-
* tag: string
|
|
8
|
-
* id: string
|
|
9
|
-
* list: string[]
|
|
10
|
-
* h5Params?: string
|
|
11
|
-
* }} params
|
|
12
|
-
*/
|
|
13
|
-
export function stockNavigateTo(type, params) {
|
|
14
|
-
// 标记进入原生页面
|
|
15
|
-
if (`${type}` === '2') {
|
|
16
|
-
// const isSupport = window.compareAppVersion(window.ksAppVersion, '1.0.398')
|
|
17
|
-
// if (!isSupport) type = 0
|
|
18
|
-
type = 0
|
|
19
|
-
}
|
|
20
|
-
return callFunc('stockNavigateTo', { pageType: 'native', type, params })
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @description 设置底部 tabs 是否显示
|
|
25
|
-
* @param {boolean} isShow
|
|
26
|
-
*/
|
|
27
|
-
export const setStockTabVisible = isShow => {
|
|
28
|
-
return callFunc('setStockTabVisible', { isShow })
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 隐藏/显示关闭按钮
|
|
33
|
-
* @param {boolean} isShow
|
|
34
|
-
*/
|
|
35
|
-
export const setCloseButton = isShow => {
|
|
36
|
-
return callFunc('setCloseButton', { isShow })
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @description 打开新的界面加载网页
|
|
41
|
-
* @param {string} url
|
|
42
|
-
*/
|
|
43
|
-
export const openBrowser = url => {
|
|
44
|
-
return callFunc({ method: 'openBrowser', params: { url } })
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @description 股票列表/指数列表传递
|
|
49
|
-
* @param {0 | 1} type 0 股票列表;1 指数列表
|
|
50
|
-
* @param {string} tag 列表数据唯一标识,传递相同会覆盖
|
|
51
|
-
* @param {string[]} list 股票列表/指数列表。如股票列表:["000001.SZ","000002.SZ"]
|
|
52
|
-
*/
|
|
53
|
-
export const stockListTransfer = (type, tag, list) => {
|
|
54
|
-
return callFunc('stockListTransfer', { type, tag, list })
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export async function getStatusBarHeight() {
|
|
58
|
-
try {
|
|
59
|
-
let statusBarHeight = window.__statusBarHeight__
|
|
60
|
-
|
|
61
|
-
statusBarHeight = statusBarHeight || window.getComputedStyle(document.documentElement).getPropertyValue('--status-bar-height').replace(/px$/gi, '')
|
|
62
|
-
statusBarHeight = statusBarHeight || (await callFunc('getKsStatusBarHeight', {})).statusHeight
|
|
63
|
-
|
|
64
|
-
return +statusBarHeight || 0
|
|
65
|
-
} catch {
|
|
66
|
-
return 0
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export async function getKsStatusBarHeight() {
|
|
71
|
-
getStatusBarHeight()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @description 通知页面滚动到顶部或底部事件
|
|
76
|
-
* @param {Boolean} isTop 是否滚动到顶部
|
|
77
|
-
* @param {Boolean} isBottom 是否滚动到底部
|
|
78
|
-
*/
|
|
79
|
-
export const webScrollVertical = (isTop, isBottom) => {
|
|
80
|
-
return jsStockCallFunc('webScrollVertical', [isTop, isBottom])
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* @description 通知页面滚动到顶部或底部事件
|
|
85
|
-
* @param {Boolean} isTop 是否滚动到顶部
|
|
86
|
-
* @param {Boolean} isBottom 是否滚动到底部
|
|
87
|
-
*/
|
|
88
|
-
export const reload = () => {
|
|
89
|
-
return jsStockCallFunc('reload')
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @description 调用原生能力存储本地数据
|
|
94
|
-
* 注意: key的值在轻应用中是全局存储的,需要注意唯一性,命名不要和其他业务线中的key产生冲突
|
|
95
|
-
* 踩坑点: value: 只能存储字符串,不能为数字
|
|
96
|
-
* @param {Object} params 存储对象{key: string, value: string}
|
|
97
|
-
*/
|
|
98
|
-
export const storageSetItem = (params) => {
|
|
99
|
-
if (!params || typeof params.key !== 'string' || typeof params.value !== 'string') {
|
|
100
|
-
return false
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return callFunc('storageSetItem', params)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @description 调用原生能力获取本地数据
|
|
108
|
-
* 注意: key的值在轻应用中是全局存储的,需要注意唯一性,命名不要和其他业务线中的key产生冲突
|
|
109
|
-
* @param {String} key 通过storageSetItem方法设置的唯一key键值
|
|
110
|
-
*/
|
|
111
|
-
export const storageGetItem = async (key) => {
|
|
112
|
-
if (!key || typeof key !== 'string') {
|
|
113
|
-
return false
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return await callFunc('storageGetItem', { key })
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @description 通用弹窗原生能力
|
|
121
|
-
* @param {string} url
|
|
122
|
-
*/
|
|
123
|
-
export const openNativeDialog = (params) => {
|
|
124
|
-
console.log('openNativeDialog', params)
|
|
125
|
-
return callFunc('CommonDialog', {
|
|
126
|
-
...params,
|
|
127
|
-
title: '温馨提示',
|
|
128
|
-
leftText: '取消',
|
|
129
|
-
rightText: '确定',
|
|
130
|
-
rightTextColor: '#f2412f'
|
|
131
|
-
})
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* @description 通用Modal原生能力
|
|
136
|
-
* @param {object} params
|
|
137
|
-
*/
|
|
138
|
-
export const openNativeModal = (params) => {
|
|
139
|
-
return callFunc('WebDialog', {
|
|
140
|
-
...params,
|
|
141
|
-
direction: params.direction,
|
|
142
|
-
url: params.url,
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
export const platform = {
|
|
149
|
-
stockNavigateTo,
|
|
150
|
-
setStockTabVisible,
|
|
151
|
-
callFunc,
|
|
152
|
-
openBrowser,
|
|
153
|
-
stockListTransfer,
|
|
154
|
-
webScrollVertical,
|
|
155
|
-
reload,
|
|
156
|
-
storageSetItem,
|
|
157
|
-
storageGetItem,
|
|
158
|
-
openNativeDialog,
|
|
159
|
-
openNativeModal
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export * from './subscribe'
|
|
163
|
-
export * from './subscribe/helper'
|
|
164
|
-
export * from './subscribe/table-animation'
|
|
File without changes
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import throttle from 'lodash/throttle'
|
|
3
|
-
|
|
4
|
-
const DEFAULT_BUFFER_SIZE = 120
|
|
5
|
-
const DEFAULT_WAIT = 400
|
|
6
|
-
|
|
7
|
-
export function createUpdateBuffer(updateHandle, hashKey = 'code', option = { size: DEFAULT_BUFFER_SIZE, wait: DEFAULT_WAIT }) {
|
|
8
|
-
let pool = {}
|
|
9
|
-
let count = 0
|
|
10
|
-
|
|
11
|
-
const throttleFlush = throttle(
|
|
12
|
-
function () {
|
|
13
|
-
updateHandle(Object.values(pool))
|
|
14
|
-
count = 0
|
|
15
|
-
pool = {}
|
|
16
|
-
},
|
|
17
|
-
option.wait,
|
|
18
|
-
{ trailing: true },
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
const buffer = {
|
|
22
|
-
push(item) {
|
|
23
|
-
pool[item[hashKey]] = item
|
|
24
|
-
count++
|
|
25
|
-
|
|
26
|
-
if (count > option.size && option.size > 0) {
|
|
27
|
-
throttleFlush.flush()
|
|
28
|
-
} else {
|
|
29
|
-
throttleFlush()
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
flush: throttleFlush.flush,
|
|
34
|
-
throttleFlush: throttleFlush,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return buffer
|
|
38
|
-
}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
import { uuid } from '@/utils/tools'
|
|
3
|
-
import { callFunc } from '../core'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @param {{ ids: string[], type: number, isSubscribe: boolean, tag: string }} param
|
|
7
|
-
*/
|
|
8
|
-
export function stockSubscribe(param) {
|
|
9
|
-
return callFunc('stockSubscribe', param)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {{ bizData: string, bizType: string, isSubscribe: boolean, tag: string }} param
|
|
14
|
-
*/
|
|
15
|
-
export function stockCommonSubscribe(param) {
|
|
16
|
-
return callFunc('stockCommonSubscribe', param)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const idToHandle = new Map()
|
|
20
|
-
const handleToId = new WeakMap()
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @param {number|string} typeOrCommand
|
|
24
|
-
* @param {unknown} param
|
|
25
|
-
* @param {(data: unknown) => unknown} handle
|
|
26
|
-
* @param {unknown} offParam
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
// 所有的订阅关系
|
|
30
|
-
const subscribeMap = {
|
|
31
|
-
holding: {},
|
|
32
|
-
entrust: {},
|
|
33
|
-
quotes: {},
|
|
34
|
-
selection: {}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// 保存到订阅关系
|
|
38
|
-
function saveStockSubscribeMap(val) {
|
|
39
|
-
const { module, isSubscribe, tag } = val
|
|
40
|
-
// 没有指定模块不操作
|
|
41
|
-
if (!module || !subscribeMap[module]) return
|
|
42
|
-
if (isSubscribe) {
|
|
43
|
-
// 订阅,追加
|
|
44
|
-
if (!needSubscribe(val)) {
|
|
45
|
-
// 非当前tab,状态置为false
|
|
46
|
-
val.isSubscribe = false
|
|
47
|
-
}
|
|
48
|
-
subscribeMap[module][tag] = val
|
|
49
|
-
} else {
|
|
50
|
-
// 取消订阅,删除
|
|
51
|
-
delete subscribeMap[module][tag]
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 批量处理订阅管理
|
|
56
|
-
function batchChangeStockSubscribe(isSubscribe, moduleKey) {
|
|
57
|
-
Object.keys(subscribeMap[moduleKey]).forEach(k => {
|
|
58
|
-
// 订阅状态无变化,不与原生交互
|
|
59
|
-
if (subscribeMap[moduleKey][k].isSubscribe === isSubscribe) return
|
|
60
|
-
const { isCommand } = subscribeMap[moduleKey][k]
|
|
61
|
-
subscribeMap[moduleKey][k].isSubscribe = isSubscribe
|
|
62
|
-
isCommand ? stockCommonSubscribe(subscribeMap[moduleKey][k]) : stockSubscribe(subscribeMap[moduleKey][k])
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// 统一处理所有的订阅关系,息屏时关闭,亮屏时重新订阅
|
|
67
|
-
function changeStockSubscribeMap(type) {
|
|
68
|
-
Object.keys(subscribeMap).forEach(k => {
|
|
69
|
-
// 息屏全部关闭
|
|
70
|
-
let isSubscribe = type === 'hide' ? false : k === window.PE_ACTIVE_TAB
|
|
71
|
-
batchChangeStockSubscribe(isSubscribe, k)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
// console.error('所有订阅', subscribeMap)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// 是否需要立即订阅
|
|
78
|
-
function needSubscribe(param) {
|
|
79
|
-
const { module } = param
|
|
80
|
-
return !module || module === window.PE_ACTIVE_TAB
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
window.changeStockSubscribeMap = changeStockSubscribeMap
|
|
84
|
-
|
|
85
|
-
function on(typeOrCommand, param, handle, offParam = {}, intervalTaskOptions) {
|
|
86
|
-
|
|
87
|
-
// 定时任务类型
|
|
88
|
-
if (typeOrCommand === 'intervalTask' && intervalTaskOptions) {
|
|
89
|
-
const { intervalTask, interval } = intervalTaskOptions;
|
|
90
|
-
let isTaskRunning = false;
|
|
91
|
-
let timerId = null;
|
|
92
|
-
let isActive = true; // 标记订阅是否仍然活跃
|
|
93
|
-
|
|
94
|
-
const executeTask = async () => {
|
|
95
|
-
if (!isActive || isTaskRunning) return;
|
|
96
|
-
|
|
97
|
-
isTaskRunning = true;
|
|
98
|
-
try {
|
|
99
|
-
const result = await intervalTask(param);
|
|
100
|
-
if (isActive) { // 检查是否仍然活跃
|
|
101
|
-
handle(result);
|
|
102
|
-
}
|
|
103
|
-
} catch (error) {
|
|
104
|
-
console.error('Interval task error:', error);
|
|
105
|
-
} finally {
|
|
106
|
-
isTaskRunning = false;
|
|
107
|
-
if (isActive) { // 检查是否仍然活跃
|
|
108
|
-
timerId = setTimeout(executeTask, interval);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
// 立即执行第一次任务
|
|
114
|
-
executeTask();
|
|
115
|
-
|
|
116
|
-
return () => {
|
|
117
|
-
isActive = false; // 标记为不活跃
|
|
118
|
-
clearTimeout(timerId);
|
|
119
|
-
isTaskRunning = false;
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const tag = uuid()
|
|
124
|
-
|
|
125
|
-
const wrapHandle = data => {
|
|
126
|
-
handle(data)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const parseHandle = data => {
|
|
130
|
-
wrapHandle(JSON.parse(data))
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const isCommand = typeof typeOrCommand === 'string'
|
|
134
|
-
|
|
135
|
-
idToHandle.set(tag, isCommand ? parseHandle : wrapHandle)
|
|
136
|
-
|
|
137
|
-
handleToId.set(handle, tag)
|
|
138
|
-
|
|
139
|
-
let _params = { isSubscribe: true, tag, ...param }
|
|
140
|
-
|
|
141
|
-
saveStockSubscribeMap({ bizType: typeOrCommand, type: typeOrCommand, ..._params, isCommand })
|
|
142
|
-
|
|
143
|
-
if (!needSubscribe(_params)) return
|
|
144
|
-
|
|
145
|
-
isCommand
|
|
146
|
-
? stockCommonSubscribe({ bizType: typeOrCommand, ..._params })
|
|
147
|
-
: stockSubscribe({ type: typeOrCommand, ..._params })
|
|
148
|
-
|
|
149
|
-
return () => {
|
|
150
|
-
return off(typeOrCommand, { ...param, ...offParam }, handle)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
export function conditionOn(typeOrCommand, param, handle, lastTradeDate, currentDate, offParam = {}) {
|
|
155
|
-
if (+currentDate < +lastTradeDate) return null
|
|
156
|
-
|
|
157
|
-
return on(typeOrCommand, param, handle, offParam)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @param {number|string} typeOrCommand
|
|
162
|
-
* @param {unknown} params
|
|
163
|
-
* @param {(data: unknown) => unknown} handle
|
|
164
|
-
*/
|
|
165
|
-
function off(typeOrCommand, params, handle) {
|
|
166
|
-
const tag = handleToId.get(handle)
|
|
167
|
-
const isCommand = typeof typeOrCommand === 'string'
|
|
168
|
-
|
|
169
|
-
if (tag) {
|
|
170
|
-
idToHandle.delete(tag)
|
|
171
|
-
handleToId.delete(handle)
|
|
172
|
-
|
|
173
|
-
let _params = { isSubscribe: false, tag, ...params }
|
|
174
|
-
saveStockSubscribeMap({ bizType: typeOrCommand, type: typeOrCommand, ..._params, isCommand })
|
|
175
|
-
|
|
176
|
-
return isCommand
|
|
177
|
-
? stockCommonSubscribe({ bizType: typeOrCommand, ..._params })
|
|
178
|
-
: stockSubscribe({ type: typeOrCommand, ..._params })
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* @param {{ type: string, tags: string[], data: unknown }} event
|
|
184
|
-
*/
|
|
185
|
-
function callback(event) {
|
|
186
|
-
let { tags, data } = event || {}
|
|
187
|
-
|
|
188
|
-
tags = tags || []
|
|
189
|
-
data = data || {}
|
|
190
|
-
|
|
191
|
-
tags.forEach(tag => {
|
|
192
|
-
const handle = idToHandle.get(tag)
|
|
193
|
-
if (handle) {
|
|
194
|
-
handle(data)
|
|
195
|
-
} else {
|
|
196
|
-
console.warn('no handle for tag:', tag)
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
window.stockCallback = callback
|
|
202
|
-
window.stockCommonCallback = callback
|
|
203
|
-
|
|
204
|
-
export const subscribe = { on, off }
|