@kyfe/ks-query-table 0.0.21 → 0.0.22
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/.bitmap +38 -0
- package/.editorconfig +5 -0
- package/.env.dev +2 -0
- package/.env.gray +2 -0
- package/.env.prod +2 -0
- package/.env.stg +3 -0
- package/.env.uat +2 -0
- package/.eslintignore +1 -0
- package/.eslintrc.js +25 -0
- package/.gitmodules +4 -0
- package/.prettierrc +11 -0
- package/README.md +15 -0
- package/babel.config.js +10 -0
- package/build-apm.sh +9 -0
- package/build.sh +16 -0
- package/config/index.js +20 -0
- package/jsconfig.json +7 -0
- package/kuasheng-sdk/index.js +80 -0
- package/kuasheng-sdk/lib/assets.js +304 -0
- package/kuasheng-sdk/lib/context.js +199 -0
- package/kuasheng-sdk/lib/layout.js +346 -0
- package/kuasheng-sdk/lib/location.js +46 -0
- package/kuasheng-sdk/lib/media.js +342 -0
- package/kuasheng-sdk/lib/navigation.js +30 -0
- package/kuasheng-sdk/lib/request.js +76 -0
- package/kuasheng-sdk/lib/system.js +190 -0
- package/kuasheng-sdk/lib/userinfo.js +98 -0
- package/kuasheng-sdk/util/check.js +102 -0
- package/kuasheng-sdk/util/config.js +47 -0
- package/kuasheng-sdk/util/device.js +25 -0
- package/kuasheng-sdk/util/error.js +19 -0
- package/kuasheng-sdk/util/funtional.js +153 -0
- package/kuasheng-sdk/util/mixin.js +36 -0
- package/kuasheng-sdk/util/requestUtil.js +41 -0
- package/kuasheng-sdk/util/response.js +33 -0
- package/kuasheng-sdk/util/warn.js +35 -0
- package/kuasheng-ui/CHANGELOG.md +9 -0
- package/kuasheng-ui/components/card.vue +57 -0
- package/kuasheng-ui/components/ks-area-select/README.md +43 -0
- package/kuasheng-ui/components/ks-area-select/area-picker.vue +554 -0
- package/kuasheng-ui/components/ks-area-select/area-search.vue +363 -0
- package/kuasheng-ui/components/ks-area-select/areas-pop.vue +56 -0
- package/kuasheng-ui/components/ks-area-select/common.js +183 -0
- package/kuasheng-ui/components/ks-area-select/index.vue +355 -0
- package/kuasheng-ui/components/ks-area-select/mixins.js +216 -0
- package/kuasheng-ui/components/ks-area-single-select/README.md +50 -0
- package/kuasheng-ui/components/ks-area-single-select/hot-city.js +45 -0
- package/kuasheng-ui/components/ks-area-single-select/index.vue +324 -0
- package/kuasheng-ui/components/ks-calendar/index.vue +269 -0
- package/kuasheng-ui/components/ks-call-phone/call-tips.vue +70 -0
- package/kuasheng-ui/components/ks-call-phone/call.vue +178 -0
- package/kuasheng-ui/components/ks-call-phone/index.js +48 -0
- package/kuasheng-ui/components/ks-call-phone/index.vue +131 -0
- 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 +23 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker-bottom.vue +123 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker-dropdown.vue +80 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker-right.vue +87 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker-top.vue +88 -0
- package/kuasheng-ui/components/ks-date-picker/date-picker.js +15 -0
- package/kuasheng-ui/components/ks-date-picker/date-range-select.vue +92 -0
- package/kuasheng-ui/components/ks-date-picker/date-select.vue +65 -0
- package/kuasheng-ui/components/ks-date-picker/date-week-month.vue +131 -0
- package/kuasheng-ui/components/ks-date-picker/index.js +12 -0
- package/kuasheng-ui/components/ks-date-picker/mixin.js +92 -0
- package/kuasheng-ui/components/ks-date-picker/month-range-select.vue +129 -0
- package/kuasheng-ui/components/ks-date-picker/month-select.vue +85 -0
- package/kuasheng-ui/components/ks-date-picker/quarter-select.vue +94 -0
- package/kuasheng-ui/components/ks-date-picker/style.less +121 -0
- package/kuasheng-ui/components/ks-date-picker/utils.js +109 -0
- package/kuasheng-ui/components/ks-date-picker/week-select.vue +99 -0
- package/kuasheng-ui/components/ks-decrypt/index.vue +159 -0
- package/kuasheng-ui/components/ks-employee/README.md +78 -0
- package/kuasheng-ui/components/ks-employee/employee-input.vue +173 -0
- package/kuasheng-ui/components/ks-employee/employee-list.vue +662 -0
- package/kuasheng-ui/components/ks-employee/employee-popup.vue +197 -0
- package/kuasheng-ui/components/ks-employee/employee-search.vue +250 -0
- package/kuasheng-ui/components/ks-employee/employee-selected.vue +173 -0
- package/kuasheng-ui/components/ks-employee/index.js +17 -0
- package/kuasheng-ui/components/ks-employee/package-lock.json +5 -0
- package/kuasheng-ui/components/ks-employee/package.json +15 -0
- package/kuasheng-ui/components/ks-employee/yarn.lock +4 -0
- package/kuasheng-ui/components/ks-field-money/index.js +8 -0
- package/kuasheng-ui/components/ks-field-money/index.vue +212 -0
- package/kuasheng-ui/components/ks-field-money/package.json +11 -0
- package/kuasheng-ui/components/ks-field-money/utils.js +65 -0
- 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 +131 -0
- package/kuasheng-ui/components/ks-history-search/history-list.vue +188 -0
- package/kuasheng-ui/components/ks-history-search/img/delete.png +0 -0
- package/kuasheng-ui/components/ks-history-search/index.js +9 -0
- package/kuasheng-ui/components/ks-history-search/index.vue +125 -0
- package/kuasheng-ui/components/ks-history-search/package-lock.json +5 -0
- package/kuasheng-ui/components/ks-history-search/package.json +15 -0
- package/kuasheng-ui/components/ks-history-search/utils.js +35 -0
- package/kuasheng-ui/components/ks-input-search/index.vue +106 -0
- package/kuasheng-ui/components/ks-list/index.vue +75 -0
- package/kuasheng-ui/components/ks-loading/index.js +16 -0
- package/kuasheng-ui/components/ks-month/index.vue +47 -0
- package/kuasheng-ui/components/ks-month/package.json +3 -0
- package/kuasheng-ui/components/ks-month/range.vue +172 -0
- package/kuasheng-ui/components/ks-month/single.vue +136 -0
- package/kuasheng-ui/components/ks-month/style.less +125 -0
- package/kuasheng-ui/components/ks-month/utils.js +35 -0
- package/kuasheng-ui/components/ks-nav/index.vue +264 -0
- package/kuasheng-ui/components/ks-nav-bar.js +35 -0
- package/kuasheng-ui/components/ks-org/ks-org-tree.vue +247 -0
- package/kuasheng-ui/components/ks-org/ks-popup-tree.vue +154 -0
- package/kuasheng-ui/components/ks-org/ks-tree-input.vue +240 -0
- package/kuasheng-ui/components/ks-org/ks-tree-node.vue +94 -0
- package/kuasheng-ui/components/ks-org/ks-tree.vue +229 -0
- package/kuasheng-ui/components/ks-org/utils.js +54 -0
- package/kuasheng-ui/components/ks-popover/index.vue +457 -0
- package/kuasheng-ui/components/ks-popover/mixin.js +28 -0
- package/kuasheng-ui/components/ks-popover/utils.js +60 -0
- package/kuasheng-ui/components/ks-pull-refresh/index.vue +43 -0
- package/kuasheng-ui/components/ks-quarter/index.vue +256 -0
- package/kuasheng-ui/components/ks-table/README.md +103 -0
- package/kuasheng-ui/components/ks-table/cell.vue +31 -0
- package/kuasheng-ui/components/ks-table/index.js +8 -0
- package/kuasheng-ui/components/ks-table/index.less +486 -0
- package/kuasheng-ui/components/ks-table/index.vue +1088 -0
- package/kuasheng-ui/components/ks-table/package.json +12 -0
- package/kuasheng-ui/components/ks-table/release.md +7 -0
- package/kuasheng-ui/components/ks-toast.js +35 -0
- package/kuasheng-ui/components/ks-upload/index.vue +174 -0
- package/kuasheng-ui/components/ks-user-access.vue +229 -0
- package/kuasheng-ui/components/no-data/README.md +45 -0
- package/kuasheng-ui/components/no-data/image.js +1 -0
- package/kuasheng-ui/components/no-data/index.vue +83 -0
- package/kuasheng-ui/components/notice-bar.vue +16 -0
- package/kuasheng-ui/components/steps.js +11 -0
- package/kuasheng-ui/components/tabs.vue +40 -0
- package/kuasheng-ui/index.js +239 -0
- package/kuasheng-ui/patch/datetime-picker/datetimePicker.md +0 -0
- package/kuasheng-ui/patch/datetime-picker/index.js +46 -0
- package/kuasheng-ui/patch/datetime-picker/utils.js +78 -0
- package/kuasheng-ui/patch/field/field.md +1 -0
- package/kuasheng-ui/patch/field/index.js +122 -0
- package/kuasheng-ui/patch/field/utils.js +36 -0
- package/kuasheng-ui/patch/form/form.md +7 -0
- package/kuasheng-ui/patch/form/index.js +106 -0
- package/kuasheng-ui/patch/index.js +12 -0
- package/kuasheng-ui/patch/pagination/index.js +78 -0
- package/kuasheng-ui/style/animation-ui.less +31 -0
- 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 +1 -0
- package/kuasheng-ui/style/images/success.svg +1 -0
- package/kuasheng-ui/style/index.less +6 -0
- package/kuasheng-ui/style/kuasheng-ui.less +207 -0
- package/kuasheng-ui/style/reset-vant.less +307 -0
- package/kuasheng-ui/style/vant-var.less +138 -0
- package/kuasheng-ui/utils/apis.js +17 -0
- package/kuasheng-ui/utils/axios-adapter.js +47 -0
- package/kuasheng-ui/utils/bem.js +39 -0
- package/kuasheng-ui/utils/bus.js +97 -0
- package/kuasheng-ui/utils/common.js +88 -0
- package/kuasheng-ui/utils/decrypt/config.js +12 -0
- package/kuasheng-ui/utils/decrypt/decrypt-api.js +139 -0
- package/kuasheng-ui/utils/decrypt/index.js +6 -0
- package/kuasheng-ui/utils/decrypt/mask.js +36 -0
- package/kuasheng-ui/utils/decrypt/virtual.js +44 -0
- package/kuasheng-ui/utils/directive.js +57 -0
- package/kuasheng-ui/utils/directive.md +23 -0
- package/kuasheng-ui/utils/drcheck-plugin.js +219 -0
- package/kuasheng-ui/utils/error-plugin.js +88 -0
- package/kuasheng-ui/utils/filter.js +149 -0
- package/kuasheng-ui/utils/http-interceptors.js +18 -0
- package/kuasheng-ui/utils/http.js +140 -0
- package/kuasheng-ui/utils/index.js +5 -0
- package/kuasheng-ui/utils/init-event.js +20 -0
- package/kuasheng-ui/utils/log.js +309 -0
- package/kuasheng-ui/utils/token.js +9 -0
- package/kuasheng-ui/utils/type.js +45 -0
- package/kuasheng-ui/utils/validate.js +20 -0
- package/kuasheng-ui/utils/watermark.js +67 -0
- package/kuasheng-ui/version.js +1 -0
- package/ky-apm/client.js +37 -0
- package/ky-apm/customHttp.js +38 -0
- package/ky-apm/index.js +68 -0
- package/ky-apm/plugins/performance.js +84 -0
- package/ky-apm/plugins/self-error.js +26 -0
- package/ky-apm/warn-log.js +3 -0
- package/package.json +81 -10
- package/plugin/ks-chii-webpack-html/index.js +53 -0
- package/plugin/ks-chii-webpack-html/package.json +16 -0
- package/postcss.config.js +15 -0
- package/public/capsule-positon.js +50 -0
- package/public/fonts/DingTalkJinBuTi.ttf +0 -0
- package/public/framework/axios@0.19.0.min.js +9 -0
- package/public/framework/fastclick@1.0.6.min.js +1 -0
- package/public/framework/iconfont/iconfont.css +91 -0
- package/public/framework/iconfont/iconfont.js +1 -0
- package/public/framework/iconfont/iconfont.json +142 -0
- 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 +7 -0
- package/public/framework/vue-router@3.1.3.min.js +6 -0
- package/public/framework/vue@2.6.10.runtime.min.js +6 -0
- package/public/framework/vuex@3.1.1.min.js +6 -0
- package/public/index.html +260 -0
- package/public/ks@3.0.8.umd.min.js +1 -0
- package/public/ksui@4.0.27.umd.min.js +10 -0
- package/public/status-bar-preset.js +39 -0
- package/{index.js → qt-npm/index.js} +3 -3
- package/qt-npm/package.json +13 -0
- package/src/App.vue +204 -0
- package/src/README.md +15 -0
- package/src/common/README.md +94 -0
- package/src/common/http/axios-adapter.js +47 -0
- package/src/common/http/common.js +88 -0
- package/src/common/http/http-interceptors.js +18 -0
- package/src/common/http/http-lock.js +45 -0
- package/src/common/http/index.js +163 -0
- package/src/common/http/token.js +9 -0
- package/src/common/styles/font/AlibabaSans102Ver2-Md.ttf +0 -0
- package/src/common/styles/font.less +12 -0
- package/src/common/styles/variables.less +43 -0
- package/src/common/utils/index.js +1 -0
- package/src/common/utils/platform/README.md +1 -0
- package/src/common/utils/platform/android/.gitkeep +0 -0
- package/src/common/utils/platform/core/index.js +24 -0
- package/src/common/utils/platform/index.js +164 -0
- package/src/common/utils/platform/ios/.gitkeep +0 -0
- package/src/common/utils/platform/subscribe/helper.js +38 -0
- package/src/common/utils/platform/subscribe/index.js +204 -0
- package/src/common/utils/platform/subscribe/table-animation.js +75 -0
- package/src/config/index.js +31 -0
- package/src/config.js +1 -0
- package/src/main.js +73 -0
- package/src/router.js +52 -0
- package/src/view/home/config.js +101 -0
- package/src/view/home/demo1.vue +223 -0
- package/src/view/home/demo2.vue +124 -0
- package/src/view/home/demo3.vue +51 -0
- package/src/view/home/demo4.vue +140 -0
- package/src/view/home/index.vue +97 -0
- package/src/view/home/query-table/README.md +45 -0
- package/src/view/home/query-table/api/index.js +12 -0
- package/src/view/home/query-table/assets/horizontal-back.svg +1 -0
- package/src/view/home/query-table/components/pe-table/cell.js +181 -0
- package/src/view/home/query-table/components/pe-table/collapse.js +334 -0
- package/src/view/home/query-table/components/pe-table/empty.vue +48 -0
- package/src/view/home/query-table/components/pe-table/header.js +328 -0
- 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 +1 -0
- package/src/view/home/query-table/components/pe-table/images/sort.svg +1 -0
- package/src/view/home/query-table/components/pe-table/images/sorting.svg +1 -0
- package/src/view/home/query-table/components/pe-table/images/unfold.svg +1 -0
- package/src/view/home/query-table/components/pe-table/index.vue +847 -0
- package/src/view/home/query-table/components/pe-table/load-more.js +46 -0
- package/src/view/home/query-table/components/pe-table/props/index.js +193 -0
- package/src/view/home/query-table/components/pe-table/row.vue +118 -0
- package/src/view/home/query-table/components/pe-table/scrollbar.js +424 -0
- package/src/view/home/query-table/components/pe-table/stretch-damping.js +112 -0
- package/src/view/home/query-table/components/pe-table/style/cell.less +89 -0
- package/src/view/home/query-table/components/pe-table/style/empty.less +48 -0
- package/src/view/home/query-table/components/pe-table/style/header.less +141 -0
- package/src/view/home/query-table/components/pe-table/style/index.less +88 -0
- package/src/view/home/query-table/components/pe-table/style/load-more.less +61 -0
- package/src/view/home/query-table/components/pe-table/style/row.less +6 -0
- package/src/view/home/query-table/components/pe-table/table-loading.vue +120 -0
- package/src/view/home/query-table/components/pe-table/table-total.vue +57 -0
- package/src/view/home/query-table/components/pe-table/utils/animate.js +80 -0
- package/src/view/home/query-table/components/pe-table/utils/columns.js +290 -0
- package/src/view/home/query-table/components/pe-table/utils/data.js +12 -0
- package/src/view/home/query-table/components/pe-table/utils/fixed.js +69 -0
- package/src/view/home/query-table/components/pe-table/utils/formatter.js +327 -0
- package/src/view/home/query-table/components/pe-table/utils/render-cells.js +424 -0
- package/src/view/home/query-table/components/pe-table/utils/slot.js +28 -0
- package/src/view/home/query-table/components/pe-table/utils/tools.js +84 -0
- package/src/view/home/query-table/components/pe-table/utils/touch-scroll.js +417 -0
- package/src/view/home/query-table/components/query-table/index.vue +497 -0
- package/src/view/home/query-table/components/query-table/mixins/column-mixin.js +102 -0
- package/src/view/home/query-table/components/query-table/mixins/column-setting.js +143 -0
- package/src/view/home/query-table/components/query-table/mixins/data-mixin.js +519 -0
- package/src/view/home/query-table/components/query-table/mixins/pagination-mixin.js +26 -0
- package/src/view/home/query-table/components/query-table/mixins/table-fixed.js +130 -0
- package/src/view/home/query-table/components/query-table/mixins/table-horizontal.js +119 -0
- package/src/view/home/query-table/components/table-horizontal.vue +99 -0
- package/src/view/home/query-table/components/table-pagination.vue +32 -0
- package/src/view/home/query-table/components/table-settings/assets/arrpw-up.svg +1 -0
- package/src/view/home/query-table/components/table-settings/assets/disabled-down.svg +1 -0
- package/src/view/home/query-table/components/table-settings/assets/disabled-up.svg +1 -0
- package/src/view/home/query-table/components/table-settings/assets/down.svg +1 -0
- package/src/view/home/query-table/components/table-settings/assets/up.svg +1 -0
- package/src/view/home/query-table/components/table-settings/index.less +294 -0
- package/src/view/home/query-table/components/table-settings/index.vue +260 -0
- package/src/view/home/query-table/components/table-settings/settings.vue +479 -0
- package/src/view/home/query-table/components/table-settings/test.js +626 -0
- 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 +124 -0
- package/src/view/home/query-table/hooks/use-cache-promise.js +27 -0
- package/src/view/home/query-table/hooks/use-column-config.js +190 -0
- package/src/view/home/query-table/hooks/use-encryption.js +0 -0
- package/src/view/home/query-table/hooks/use-generic-search.js +95 -0
- package/src/view/home/query-table/index.js +7 -0
- package/src/view/home/query-table/store/column-store.js +0 -0
- package/src/view/home/query-table/styles/table.less +24 -0
- package/src/view/home/query-table/utils/column.js +36 -0
- package/src/view/home/query-table/utils/config.js +12 -0
- package/src/view/home/query-table/utils/encryption.js +32 -0
- package/src/view/home/query-table/utils/http.js +1 -0
- package/src/view/home/query-table/utils/localStorage.js +35 -0
- package/src/view/home//351/246/226/351/241/265.md +0 -0
- package/src/web.js +99 -0
- package/vue.config.js +131 -0
package/src/App.vue
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="ksui-app" v-if="$root.init">
|
|
3
|
+
<keep-alive>
|
|
4
|
+
<router-view ref="keepRef" v-if="$route.meta.keepAlive"></router-view>
|
|
5
|
+
</keep-alive>
|
|
6
|
+
<router-view ref="noKeepRef" v-if="!$route.meta.keepAlive"></router-view>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
export default {
|
|
12
|
+
name: 'app',
|
|
13
|
+
data() {
|
|
14
|
+
return {
|
|
15
|
+
screenChange: 0
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
mounted() {
|
|
19
|
+
window.onStockScreenChange = status => {
|
|
20
|
+
// int 0竖屏(默认)、1横屏
|
|
21
|
+
this.$bus.$emit('jumpcallback', status)
|
|
22
|
+
if (this.screenChange !== status) {
|
|
23
|
+
this.screenChange = status
|
|
24
|
+
this.$bus.$emit('screenChange', status)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
created() {
|
|
31
|
+
// 默认占满状态栏
|
|
32
|
+
window.ks && window.ks.callFunc({ method: 'setStatusBar', params: { statusBarType: 1 } })
|
|
33
|
+
window.ks.callFunc({
|
|
34
|
+
method: "setCloseStyle",
|
|
35
|
+
params: {
|
|
36
|
+
style: '3', // '1': 默认 '2': 透明色 '3': 白色
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<style lang="less">
|
|
44
|
+
html, body {
|
|
45
|
+
overflow: hidden; /* 禁止滚动 */
|
|
46
|
+
touch-action: none; /* 禁用触摸滚动 */
|
|
47
|
+
position: fixed; /* 防止 iOS 弹性滚动 */
|
|
48
|
+
height: 100%; /* 确保全屏 */
|
|
49
|
+
width: 100%;
|
|
50
|
+
}
|
|
51
|
+
.ks-date-picker-right-popup {
|
|
52
|
+
max-width: 420px;
|
|
53
|
+
padding-top: var(--status-bar-height);
|
|
54
|
+
.van-popup__close-icon {
|
|
55
|
+
padding-top: var(--status-bar-height);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
#ksui-app {
|
|
59
|
+
-webkit-overflow-scrolling: auto; /* 禁用 iOS 弹性滚动 */
|
|
60
|
+
font-size: 16px;
|
|
61
|
+
.van-tabbar-item__icon {
|
|
62
|
+
img {
|
|
63
|
+
height: 44px;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ksui-body {
|
|
69
|
+
.white-mask {
|
|
70
|
+
position: absolute;
|
|
71
|
+
height: 100%;
|
|
72
|
+
width: 100%;
|
|
73
|
+
top: 0;
|
|
74
|
+
left: 0;
|
|
75
|
+
background-color: #fff;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.ksui-container {
|
|
80
|
+
height: 100%;
|
|
81
|
+
background-color: #f8f8f8;
|
|
82
|
+
position: relative;
|
|
83
|
+
overflow-x: hidden;
|
|
84
|
+
}
|
|
85
|
+
.van-tabbar--fixed {
|
|
86
|
+
z-index: 1000;
|
|
87
|
+
}
|
|
88
|
+
.ksui-nav {
|
|
89
|
+
.van-nav-bar .van-nav-bar__arrow {
|
|
90
|
+
font-size: 20px;
|
|
91
|
+
margin-top: -3px;
|
|
92
|
+
}
|
|
93
|
+
.van-nav-bar__title {
|
|
94
|
+
text-align: left;
|
|
95
|
+
margin-left: 40px;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
[data-stock='up'] {
|
|
100
|
+
&::after {
|
|
101
|
+
transition: all 0.3s;
|
|
102
|
+
animation: ascend-animation 1s ease-in-out;
|
|
103
|
+
position: absolute;
|
|
104
|
+
z-index: -1;
|
|
105
|
+
content: '';
|
|
106
|
+
/*prettier-ignore*/
|
|
107
|
+
left: 1PX;
|
|
108
|
+
/*prettier-ignore*/
|
|
109
|
+
right: 1PX;
|
|
110
|
+
/*prettier-ignore*/
|
|
111
|
+
top: 2PX;
|
|
112
|
+
/*prettier-ignore*/
|
|
113
|
+
bottom: 2PX;
|
|
114
|
+
/*prettier-ignore*/
|
|
115
|
+
border-radius: 2PX;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
[data-stock='down'] {
|
|
120
|
+
&::after {
|
|
121
|
+
transition: all 0.3s;
|
|
122
|
+
animation: descend-animation 1s ease-in-out;
|
|
123
|
+
z-index: -1;
|
|
124
|
+
position: absolute;
|
|
125
|
+
content: '';
|
|
126
|
+
/*prettier-ignore*/
|
|
127
|
+
left: 1PX;
|
|
128
|
+
/*prettier-ignore*/
|
|
129
|
+
right: 1PX;
|
|
130
|
+
/*prettier-ignore*/
|
|
131
|
+
top: 2PX;
|
|
132
|
+
/*prettier-ignore*/
|
|
133
|
+
bottom: 2PX;
|
|
134
|
+
/*prettier-ignore*/
|
|
135
|
+
border-radius: 2PX;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@keyframes descend-animation {
|
|
140
|
+
0% {
|
|
141
|
+
background-color: transparent;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
50% {
|
|
145
|
+
background: #CDF0DA;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
100% {
|
|
149
|
+
background-color: transparent;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@keyframes ascend-animation {
|
|
154
|
+
0% {
|
|
155
|
+
background-color: transparent;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
50% {
|
|
159
|
+
background: #FFDCDC;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
100% {
|
|
163
|
+
background-color: transparent;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.van-popup.pe-common-popup-container {
|
|
168
|
+
box-sizing: border-box;
|
|
169
|
+
padding-top: var(--status-bar-height);
|
|
170
|
+
// 横屏表格
|
|
171
|
+
&.horizontal-popup {
|
|
172
|
+
.screen-hide {
|
|
173
|
+
display: none;
|
|
174
|
+
}
|
|
175
|
+
.table-head-options {
|
|
176
|
+
display: flex;
|
|
177
|
+
.table-head-options-right {
|
|
178
|
+
flex: 1;
|
|
179
|
+
display: flex;
|
|
180
|
+
align-items: center;
|
|
181
|
+
justify-content: flex-end;
|
|
182
|
+
.styled-title-menus {
|
|
183
|
+
margin-left: 36px;
|
|
184
|
+
padding-right: 24px;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.pe-table-cell.holding-total-row {
|
|
192
|
+
will-change: unset !important;
|
|
193
|
+
background-color: #fffaf3;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.android .van-popup.horizontal-popup.pe-common-popup-container {
|
|
197
|
+
box-sizing: border-box;
|
|
198
|
+
padding-top: calc(var(--status-bar-height) - 17px);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.van-overlay {
|
|
202
|
+
animation: none !important;
|
|
203
|
+
}
|
|
204
|
+
</style>
|
package/src/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# ks-query-table
|
|
2
|
+
|
|
3
|
+
## 当前仓库为PE迁移
|
|
4
|
+
### 发布npm流程
|
|
5
|
+
#### 组件代码路径 ks-query-table\src\view\home\query-table
|
|
6
|
+
- 根目录 - package.json文件version 手动更改为新版本号
|
|
7
|
+
- 执行 npm run buildqt 进行对应包打包操作
|
|
8
|
+
- 打完包后进入 一级目录 dist 拷贝 ks-query-table.umd.min.js 文件至 qt-npm,并将改文件重命名为 index.js
|
|
9
|
+
- qt-npm/package.json文件version 手动更改为新版本号
|
|
10
|
+
- 终端进入到 qt-npm 目录
|
|
11
|
+
- 需切换回 npm 官方镜像源!!
|
|
12
|
+
- 登录 npm `npm login`
|
|
13
|
+
- 执行发布命令 `npm publish --access public`
|
|
14
|
+
|
|
15
|
+
## 主分支master
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# pe-common-h5
|
|
2
|
+
移动端公共业务组件库,存放通用工具类
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
|
14
|
+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin http://gitlab.baoguozs.com/ycfm-pe/front/finance/pe-common-h5.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
- [ ] [Set up project integrations](http://gitlab.baoguozs.com/ycfm-pe/front/finance/pe-common-h5/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
|
30
|
+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
+
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
|
40
|
+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
|
41
|
+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
|
42
|
+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
|
43
|
+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
|
94
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
export default function xhrAdapter(config) {
|
|
4
|
+
const isProd = navigator.userAgent.includes('ks_prod')
|
|
5
|
+
if (config._debug !== false && !isProd) {
|
|
6
|
+
console.log(`[request] ${config.headers.method}`, config)
|
|
7
|
+
}
|
|
8
|
+
return new Promise(function dispatchXhrRequest(resolve, reject) {
|
|
9
|
+
// 超时定时器
|
|
10
|
+
let timer = setTimeout(() => {
|
|
11
|
+
const error = {message: `timeout of ${config.timeout}ms exceeded`}
|
|
12
|
+
error._config = config
|
|
13
|
+
reject(error)
|
|
14
|
+
}, config.timeout)
|
|
15
|
+
|
|
16
|
+
config.headers['appkey'] = config.headers.appkey && String(config.headers.appkey)
|
|
17
|
+
ks.request(config.headers.method,JSON.parse(config.data), config.headers).then(function(res){
|
|
18
|
+
|
|
19
|
+
// 请求成功清除定时器
|
|
20
|
+
clearTimeout(timer)
|
|
21
|
+
|
|
22
|
+
if (config._debug !== false && !isProd) {
|
|
23
|
+
console.log(`[response] ${config.headers.method}`, res)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let responseData = res
|
|
27
|
+
let response = {
|
|
28
|
+
data: responseData,
|
|
29
|
+
status: 200,
|
|
30
|
+
statusText: 'OK',
|
|
31
|
+
headers: config.headers,
|
|
32
|
+
config: config,
|
|
33
|
+
request: config
|
|
34
|
+
}
|
|
35
|
+
resolve(response)
|
|
36
|
+
}).catch(function(error){
|
|
37
|
+
|
|
38
|
+
clearTimeout(timer)
|
|
39
|
+
|
|
40
|
+
if (config._debug !== false && !isProd) {
|
|
41
|
+
console.log(`[failed] ${config.headers.method}`, error)
|
|
42
|
+
}
|
|
43
|
+
error._config = config
|
|
44
|
+
reject(error)
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import md5 from "js-md5"
|
|
2
|
+
|
|
3
|
+
const ENV_TYPES = {
|
|
4
|
+
prd: 'ks_prod',
|
|
5
|
+
uat: 'ks_uat',
|
|
6
|
+
stg: 'ks_stg',
|
|
7
|
+
dev: 'ks_dev'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const KS_URL_CONFIG = {
|
|
11
|
+
[ENV_TYPES.prd]: 'https://ys-h5.ycfm-erp.com',
|
|
12
|
+
[ENV_TYPES.uat]: 'http://api-uat.baoguozs.com',
|
|
13
|
+
[ENV_TYPES.stg]: 'https://ys-gray-h5.ycfm-erp.com', //
|
|
14
|
+
[ENV_TYPES.dev]: 'http://api-dev.baoguozs.com'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const random = (count) => {
|
|
18
|
+
let num = Date.now() + Math.floor(1000 * Math.random() + 1000)
|
|
19
|
+
if (count) {
|
|
20
|
+
return num.toString().substr(-count)
|
|
21
|
+
}
|
|
22
|
+
return num.toString()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const md5Http = (token, timestamp, body) => {
|
|
26
|
+
return md5(md5(token).toUpperCase() + timestamp + JSON.stringify(body || {})).toUpperCase()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const getXWebTraceId = (userId, menuId, now) => {
|
|
30
|
+
let log = window.ksui && window.ksui.log
|
|
31
|
+
let startTime = log && log.initTime || now
|
|
32
|
+
return `${userId}-${menuId || 'xxxx'}-${startTime}-${log && log.lastActionId || ''}-${random(4)}`
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 判断是否在环境
|
|
36
|
+
export const isKSClient = () => {
|
|
37
|
+
return navigator.userAgent.toLowerCase().indexOf('kuasheng-2.0') >= 0
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 获取当前环境
|
|
41
|
+
export const getKsEnv = () => {
|
|
42
|
+
return Object.keys(ENV_TYPES).find(type =>
|
|
43
|
+
navigator.userAgent.includes(ENV_TYPES[type])
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 获取当前环境对应的请求域名
|
|
48
|
+
export const getKsEnvUrl = () => {
|
|
49
|
+
const envType = getKsEnv()
|
|
50
|
+
const url = envType ? KS_URL_CONFIG[ENV_TYPES[envType]] : null
|
|
51
|
+
console.info(`当前轻应用走的是 XHR 请求,代理地址为${url}`)
|
|
52
|
+
return url
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const getValue = (key, obj, getSourceOfKey) => {
|
|
56
|
+
if (!key) {
|
|
57
|
+
return ''
|
|
58
|
+
}
|
|
59
|
+
let source = null
|
|
60
|
+
// 解析键的属性和数组索引
|
|
61
|
+
const parseKey = (k) => {
|
|
62
|
+
const index = k.indexOf('[')
|
|
63
|
+
return {
|
|
64
|
+
prop: index > 0 ? k.substr(0, index) : k,
|
|
65
|
+
arrayIndex: index > 0 ? +k.substring(index + 1, k.length - 1) : undefined,
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 处理每个键的情况
|
|
70
|
+
const handleKey = (s, k, isLast) => {
|
|
71
|
+
const { prop, arrayIndex } = parseKey(k)
|
|
72
|
+
const value = s[prop]
|
|
73
|
+
source = s
|
|
74
|
+
if (isLast) {
|
|
75
|
+
return arrayIndex !== undefined ? (value || [])[arrayIndex] : value
|
|
76
|
+
}
|
|
77
|
+
return arrayIndex !== undefined ? (value || [])[arrayIndex] || {} : value || {}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (key.includes('.')) {
|
|
81
|
+
const keys = key.split('.')
|
|
82
|
+
const value = keys.reduce((s, k, i) => handleKey(s, k, i === keys.length - 1), obj)
|
|
83
|
+
return getSourceOfKey ? { source, value } : value
|
|
84
|
+
} else {
|
|
85
|
+
const value = handleKey(obj, key, true)
|
|
86
|
+
return getSourceOfKey ? { source, value } : value
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* 作用:频繁调用接口时,保证取到的返回结果是最后一次请求的结果
|
|
4
|
+
* 可用于频繁切换tab造成数据错位的问题等
|
|
5
|
+
* 给每次请求生成一个reqId,结果响应时对比reqId
|
|
6
|
+
* 如果响应id与请求时生成id一致,证明没有发生新的请求
|
|
7
|
+
* 否则,该请求已经是旧的,可以被丢弃(什么都不做)
|
|
8
|
+
* 利用永远不改变promise状态,达到丢弃的目的
|
|
9
|
+
* @param {*} name
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
function createHttpLock(name = '') {
|
|
13
|
+
var globalId
|
|
14
|
+
return function lock(promise) {
|
|
15
|
+
// 每次发送请求,生成新的id
|
|
16
|
+
globalId = Math.random();
|
|
17
|
+
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
// 利用闭包,将id存到本次请求上下文中
|
|
20
|
+
var reqId = globalId
|
|
21
|
+
promise.then((res) => {
|
|
22
|
+
// 对比reqId和globalId,如果不一致,表示已经有了新的请求
|
|
23
|
+
if (reqId === globalId) {
|
|
24
|
+
resolve(res);
|
|
25
|
+
} else {
|
|
26
|
+
console.log(name + ' httpLock: Promise object is outdated');
|
|
27
|
+
}
|
|
28
|
+
}).catch((err) => {
|
|
29
|
+
if (reqId === globalId) {
|
|
30
|
+
reject(err);
|
|
31
|
+
} else {
|
|
32
|
+
console.error(err);
|
|
33
|
+
console.log(name + ' httpLock: Promise object is outdated');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
export default createHttpLock
|
|
42
|
+
|
|
43
|
+
// 使用示例
|
|
44
|
+
// const searchLock = createHttpLock('search')
|
|
45
|
+
// search(http('pe.stock.app.resource.first.search.v1', appKey, params))
|
|
@@ -0,0 +1,163 @@
|
|
|
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 }
|