@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
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import tippy from 'tippy.js';
|
|
2
|
+
function findParentWithClass(element, className, maxDepth = 10) {
|
|
3
|
+
if (!element || element === document.documentElement || maxDepth <= 0) {
|
|
4
|
+
return null
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
if (element.classList && element.classList.contains(className)) {
|
|
8
|
+
return element
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return findParentWithClass(element.parentElement, className, maxDepth - 1)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const isShow = (val, vm) => {
|
|
15
|
+
const { event, column } = val
|
|
16
|
+
const { width } = column
|
|
17
|
+
// TODO 默认需要?
|
|
18
|
+
if (column.showPopover === false) return { show: false }
|
|
19
|
+
// 找到单元格
|
|
20
|
+
let cellDom = findParentWithClass(event.target, 'pe-table-cell')
|
|
21
|
+
if (!cellDom) {
|
|
22
|
+
return {
|
|
23
|
+
show: false
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let div = document.createElement('div')
|
|
28
|
+
div.innerText = cellDom.textContent
|
|
29
|
+
div.style.top = '-10000px'
|
|
30
|
+
div.style.position = 'absolute'
|
|
31
|
+
event.target.appendChild(div)
|
|
32
|
+
let realW = div.getBoundingClientRect().width
|
|
33
|
+
let columnW = width - 16
|
|
34
|
+
|
|
35
|
+
event.target.removeChild(div)
|
|
36
|
+
let offsets = getOffset(val, vm, cellDom)
|
|
37
|
+
return {
|
|
38
|
+
offsets,
|
|
39
|
+
show: realW >= columnW,
|
|
40
|
+
cellDom,
|
|
41
|
+
textContent: cellDom.textContent
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const getOffset = (val, vm, cellDom) => {
|
|
46
|
+
const { width, fixed } = val.column
|
|
47
|
+
const fixedList = vm.onlineColumns.filter(col => col.fixed === 'left' || col.fixed)
|
|
48
|
+
const fixedWidth = fixedList.reduce((acc, col) => acc + col.width, 0) // 计算左边固定距离
|
|
49
|
+
const translateX = (cellDom && cellDom.style.transform.match(/translateX\(([^)]+)px\)/)?.[1]) || 0
|
|
50
|
+
const sortW = 40
|
|
51
|
+
let X = width + Math.ceil(translateX) - (fixedWidth + sortW)
|
|
52
|
+
if (X < width / 2 && !fixed) {
|
|
53
|
+
return {
|
|
54
|
+
left: fixedWidth + sortW + X / 2,
|
|
55
|
+
maxWidth: window.innerWidth - (fixedWidth + sortW) - X / 2 - 8,
|
|
56
|
+
offset: [0, -4]
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
return {
|
|
60
|
+
maxWidth: window.innerWidth - 20,
|
|
61
|
+
offset: [0, -4]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export const handleShowPopover = (val, vm) => {
|
|
68
|
+
const { show, offsets } = isShow(val, vm)
|
|
69
|
+
const { event } = val
|
|
70
|
+
const element = event.currentTarget;
|
|
71
|
+
if (show) {
|
|
72
|
+
tippy(element, {
|
|
73
|
+
content: element.innerText,
|
|
74
|
+
theme: 'light',
|
|
75
|
+
appendTo: document.body,
|
|
76
|
+
offset: offsets.offset,
|
|
77
|
+
maxWidth: offsets.maxWidth,
|
|
78
|
+
hideOnClick: true, // 点击任何地方都会关闭
|
|
79
|
+
interactive: true, // 允许与弹窗交互
|
|
80
|
+
trigger: 'manual', // 手动触发
|
|
81
|
+
onShow(instance) {
|
|
82
|
+
// 点击外部关闭的处理
|
|
83
|
+
const handleClickOutside = () => {
|
|
84
|
+
|
|
85
|
+
// if (!instance.popper.contains(e.target) && e.target !== element) {
|
|
86
|
+
instance.hide()
|
|
87
|
+
// }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const resizeHide = () => {
|
|
91
|
+
instance.hide()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
document.addEventListener('pointerdown', handleClickOutside)
|
|
95
|
+
window.addEventListener('resize', resizeHide)
|
|
96
|
+
|
|
97
|
+
instance._clickOutsideHandler = handleClickOutside
|
|
98
|
+
instance._resizeHide = resizeHide
|
|
99
|
+
if (offsets.left) {
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
instance.popper.style.transform = instance.popper.style.transform.replace(/\(.*?px/, '(' + offsets.left + 'px')
|
|
102
|
+
instance.popper.querySelector('.tippy-arrow').style.transform = 'translate(4px, 0px)'
|
|
103
|
+
}, 10)
|
|
104
|
+
}
|
|
105
|
+
// 获取箭头元素
|
|
106
|
+
},
|
|
107
|
+
onHide(instance) {
|
|
108
|
+
// 移除事件监听
|
|
109
|
+
document.removeEventListener('pointerdown', instance._clickOutsideHandler)
|
|
110
|
+
window.removeEventListener('resize', instance._resizeHide)
|
|
111
|
+
},
|
|
112
|
+
onClickOutside(instance) {
|
|
113
|
+
instance.hide();
|
|
114
|
+
}
|
|
115
|
+
}).show();
|
|
116
|
+
return {
|
|
117
|
+
show: true,
|
|
118
|
+
rowIndex: val.rowIndex
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
show: false
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
function removeCache(key) {
|
|
3
|
+
const {cache} = this
|
|
4
|
+
if(cache) {
|
|
5
|
+
delete cache[key]
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const useCachePromise = () => {
|
|
10
|
+
const cache = {};
|
|
11
|
+
|
|
12
|
+
// 外部处理好key相同的情况
|
|
13
|
+
const fn = function (key, promiseOrFunction) {
|
|
14
|
+
if (cache[key]) return cache[key]; // 如果有缓存,直接返回
|
|
15
|
+
|
|
16
|
+
const promise = typeof promiseOrFunction === 'function' ? promiseOrFunction() : promiseOrFunction;
|
|
17
|
+
|
|
18
|
+
cache[key] = promise.catch((err) => {
|
|
19
|
+
cache[key] = null; // 失败时清理缓存
|
|
20
|
+
throw err;
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return cache[key];
|
|
24
|
+
};
|
|
25
|
+
fn.removeCache = removeCache.bind({cache})
|
|
26
|
+
return fn
|
|
27
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { commonGetGenericSearchById } from './use-generic-search'
|
|
2
|
+
import { useCachePromise } from './use-cache-promise.js'
|
|
3
|
+
import cloneDeep from 'lodash/cloneDeep'
|
|
4
|
+
import intersection from 'lodash/intersection'
|
|
5
|
+
import { addColumnParams, } from '../utils/column.js'
|
|
6
|
+
import { setLocalStorageItem } from '../utils/localStorage'
|
|
7
|
+
import { getGenericSearch } from '../api/index'
|
|
8
|
+
import { createdId } from '../utils/config'
|
|
9
|
+
|
|
10
|
+
const cacheGeneric = useCachePromise()
|
|
11
|
+
|
|
12
|
+
async function _getColumns(searchCode, needCache) {
|
|
13
|
+
try {
|
|
14
|
+
// sessionStorage里有,无需重新加载
|
|
15
|
+
if (!(searchCode)) return
|
|
16
|
+
// 线上原始配置
|
|
17
|
+
let originArr = []
|
|
18
|
+
let snapshotObj = []
|
|
19
|
+
const userData = await getGeneric(searchCode)
|
|
20
|
+
// console.log('wwwwwwwwwwww',userData);
|
|
21
|
+
if (!userData) return
|
|
22
|
+
let genericId = userData.id
|
|
23
|
+
let userArr = JSON.parse(userData.fieldContent || [])
|
|
24
|
+
// 数组内的项 是 字符串,代表用户保存的数据 typeof userArr[0] === 'string'
|
|
25
|
+
const isUserData = !userArr || !userArr[0] || typeof userArr[0] === 'string' || userArr[0].child
|
|
26
|
+
if (isUserData) {
|
|
27
|
+
// 如果用户保存了自定义查询,需要获取自定义查询公共配置。对比后处理后设置给表格和个性设置
|
|
28
|
+
const promise = () => commonGetGenericSearchById({ id: userData.id })
|
|
29
|
+
let res = await (needCache ? cacheGeneric(genericId, promise) : promise())
|
|
30
|
+
// console.log('wwwwwwwwwwww',res);
|
|
31
|
+
// 线上的原始配置
|
|
32
|
+
originArr = JSON.parse(res.fieldContent)
|
|
33
|
+
// 新增字段,表示是否有上个版本的全字段配置
|
|
34
|
+
snapshotObj = JSON.parse(res.fieldSnapshot || '{}')
|
|
35
|
+
} else {
|
|
36
|
+
// 容错处理:没有返回正确的个性模板,则使用线上初始配置
|
|
37
|
+
// 调试代码,用与生成demo动图
|
|
38
|
+
// userArr.forEach((v, i) => {
|
|
39
|
+
// v.label = '列' + (i + 1)
|
|
40
|
+
// })
|
|
41
|
+
originArr = userArr
|
|
42
|
+
const key = createdId(userData.id)
|
|
43
|
+
// 设置缓存为当前数据
|
|
44
|
+
await setLocalStorageItem(key, JSON.stringify(userData))
|
|
45
|
+
}
|
|
46
|
+
let data = {
|
|
47
|
+
originArr,
|
|
48
|
+
userArr,
|
|
49
|
+
snapshotObj,
|
|
50
|
+
isUserData,
|
|
51
|
+
genericId
|
|
52
|
+
}
|
|
53
|
+
return data
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.log(error, 'getColumns error');
|
|
56
|
+
return false
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class ColUtils {
|
|
61
|
+
constructor({ mergeColumn } = {}) {
|
|
62
|
+
this.mergeColumn = mergeColumn
|
|
63
|
+
}
|
|
64
|
+
async run(searchCode, needCache) {
|
|
65
|
+
const args = await _getColumns(searchCode, needCache)
|
|
66
|
+
if (!args) {
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
const {
|
|
70
|
+
originArr,
|
|
71
|
+
userArr,
|
|
72
|
+
snapshotObj,
|
|
73
|
+
isUserData,
|
|
74
|
+
} = args
|
|
75
|
+
if (isUserData) {
|
|
76
|
+
return this.setColumns(originArr, userArr, snapshotObj)
|
|
77
|
+
} else {
|
|
78
|
+
return this.setColumns(originArr)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
setColumns(originArr, userArr, snapshotObj) {
|
|
82
|
+
if (originArr && originArr.length) {
|
|
83
|
+
// 是否用用户自定义数据
|
|
84
|
+
let isUserSave = !!userArr
|
|
85
|
+
// 用户自定义数据
|
|
86
|
+
let userKeys = []
|
|
87
|
+
let userChildKeys = {}
|
|
88
|
+
// 如果没有交集,则取公共模板
|
|
89
|
+
if (isUserSave) {
|
|
90
|
+
userKeys = userArr.map(item => {
|
|
91
|
+
if (typeof item === 'string') return item
|
|
92
|
+
if (item.child && item.child.length) userChildKeys[item.key] = item.child
|
|
93
|
+
return item.key || ''
|
|
94
|
+
})
|
|
95
|
+
let keys = originArr.map(v => v.key)
|
|
96
|
+
keys = intersection(keys, userKeys)
|
|
97
|
+
// 原始配置包含用户保存的配置
|
|
98
|
+
isUserSave = keys && keys.length > 0
|
|
99
|
+
}
|
|
100
|
+
let userSaveConfigLength = isUserSave ? userArr.length : 0
|
|
101
|
+
originArr.forEach(v => {
|
|
102
|
+
// 深拷贝,为了拿到原数据中一级头和二级头是否显示show的状态
|
|
103
|
+
const originCol = cloneDeep(v)
|
|
104
|
+
// 用户自定义的字段排序在前面
|
|
105
|
+
if (isUserSave) {
|
|
106
|
+
let index = userKeys.indexOf(v.key) + 1
|
|
107
|
+
v.index = index || ++userSaveConfigLength
|
|
108
|
+
v.show = index > 0
|
|
109
|
+
}
|
|
110
|
+
if (v.show && v.children && userChildKeys[v.key]) {
|
|
111
|
+
let childLength = isUserSave ? userChildKeys[v.key].length : 0
|
|
112
|
+
v.children.forEach(child => {
|
|
113
|
+
let childIndex = userChildKeys[v.key].indexOf(child.key) + 1
|
|
114
|
+
child.index = childIndex || ++childLength
|
|
115
|
+
child.show = childIndex > 0
|
|
116
|
+
})
|
|
117
|
+
v.children.sort((a, b) => a.index - b.index)
|
|
118
|
+
}
|
|
119
|
+
// 是否有用户数据,是否有上个版本数据
|
|
120
|
+
if (isUserSave && snapshotObj && Object.keys(snapshotObj).length) {
|
|
121
|
+
this.updateColumnStatus(originCol, v, snapshotObj, originArr)
|
|
122
|
+
}
|
|
123
|
+
// 处理用户传进来的cellRender
|
|
124
|
+
this.mergeColumn && this.mergeColumn(v)
|
|
125
|
+
})
|
|
126
|
+
if (isUserSave) {
|
|
127
|
+
originArr.sort((a, b) => a.index - b.index)
|
|
128
|
+
}
|
|
129
|
+
// 固定列排最前
|
|
130
|
+
originArr.sort((a, b) => {
|
|
131
|
+
let x = a.fixed ? 1 : 0
|
|
132
|
+
let y = b.fixed ? 1 : 0
|
|
133
|
+
return y - x
|
|
134
|
+
})
|
|
135
|
+
return addColumnParams(originArr)
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// 2021-11-19 检查是当前一级头或二级头是否是新同步字段
|
|
139
|
+
updateColumnStatus(originCol, v, snapshotObj, originArr) {
|
|
140
|
+
const index = originArr.findIndex(item => item.key === v.key)
|
|
141
|
+
const isNewKey = !snapshotObj[v.key] && originCol.show
|
|
142
|
+
// 1、上个版本没有一级头字段,则表示该字段是新增字段
|
|
143
|
+
v.show = v.show || isNewKey
|
|
144
|
+
// 2、上个版本一级头字段,且没有二级头标识children,则表示二级头children都是新增字段
|
|
145
|
+
if (v.children && snapshotObj[v.key] && !snapshotObj[v.key].children) {
|
|
146
|
+
v.children.forEach((child) => {
|
|
147
|
+
const findObj = originCol.children.find(item => item.key === child.key)
|
|
148
|
+
child.show = findObj.show
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
// 3、如果新旧版本字段都有二级头,查找二级头children中是否有新增字段
|
|
152
|
+
if (v.show && v.children && snapshotObj[v.key] && snapshotObj[v.key].children) {
|
|
153
|
+
v.children.forEach((child) => {
|
|
154
|
+
const newFlag = !snapshotObj[v.key].children[child.key]
|
|
155
|
+
const findIndex = originCol.children.findIndex(item => item.key === child.key)
|
|
156
|
+
child.show = child.show || (newFlag && originCol.children[findIndex].show)
|
|
157
|
+
child.index = newFlag ? findIndex : child.index
|
|
158
|
+
})
|
|
159
|
+
v.children.sort((a, b) => a.index - b.index)
|
|
160
|
+
}
|
|
161
|
+
// 2022-12-04 4、新增字段按照原有顺序排序
|
|
162
|
+
if (isNewKey) {
|
|
163
|
+
// 字段排序是通过添加索引排序,起始为1
|
|
164
|
+
// sort方法相同大小排序,会导致先排序的字段会排在前面
|
|
165
|
+
v.index = index
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
export const getGeneric = async (searchCode) => {
|
|
172
|
+
let generic = window.KS_QUERY_TABLE_GERENIC_SEARCH_LIST_PROMISE ? await window.KS_QUERY_TABLE_GERENIC_SEARCH_LIST_PROMISE : await getGenericSearch()
|
|
173
|
+
|
|
174
|
+
let userData = generic.find(v => v.searchCode === searchCode)
|
|
175
|
+
|
|
176
|
+
if (!userData) {
|
|
177
|
+
// 如果缓存里没有当前列,需要重新调用
|
|
178
|
+
// let newMenuList = window.PE_NEW_GENERIC_PROMISE || getListByMenuIdAndCache()
|
|
179
|
+
let generic = await getGenericSearch()
|
|
180
|
+
// window.PE_NEW_GENERIC_PROMISE = newMenuList
|
|
181
|
+
// generic = await newMenuList
|
|
182
|
+
userData = generic.find(v => v.searchCode === searchCode)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (!userData) {
|
|
186
|
+
console.error('[自定义列获取失败,请检查是否配置正确]')
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return userData
|
|
190
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { getGenericSearch, getGenericSearchById } from '../api/index'
|
|
2
|
+
import { getLocalStorageItem, setLocalStorageItem } from '../utils/localStorage'
|
|
3
|
+
import { createdId, menuCacheKey } from '../utils/config'
|
|
4
|
+
|
|
5
|
+
// 延迟更新缓存的时间,防止应用初始化时接口过多,阻塞首屏性能
|
|
6
|
+
const lazyTime = 5000
|
|
7
|
+
|
|
8
|
+
// 初始化通用查询所有配置
|
|
9
|
+
export const initGenericSearch = () => {
|
|
10
|
+
window.KS_QUERY_TABLE_GERENIC_SEARCH_LIST_PROMISE = new Promise((resolve, reject) => {
|
|
11
|
+
getGenericSearch().then(res => {
|
|
12
|
+
setLocalStorageItem(menuCacheKey(), JSON.stringify(res))
|
|
13
|
+
resolve(res)
|
|
14
|
+
}).catch(e => {
|
|
15
|
+
reject(e)
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 通过id获取自定列配置
|
|
21
|
+
export const commonGetGenericSearchById = (params) => {
|
|
22
|
+
return new Promise(async resolve => {
|
|
23
|
+
try {
|
|
24
|
+
const { id } = params
|
|
25
|
+
const key = createdId(id)
|
|
26
|
+
// 获取原生缓存
|
|
27
|
+
const value = await getLocalStorageItem(key)
|
|
28
|
+
if (value) {
|
|
29
|
+
// 有缓存
|
|
30
|
+
resolve(JSON.parse(value))
|
|
31
|
+
upDateCatch(params, lazyTime)
|
|
32
|
+
} else {
|
|
33
|
+
// 调接口
|
|
34
|
+
if (!id) {
|
|
35
|
+
resolve(undefined)
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
// 调用接口获取
|
|
39
|
+
let res = await getGenericSearchById(params)
|
|
40
|
+
// 存缓存
|
|
41
|
+
resolve(res)
|
|
42
|
+
await setLocalStorageItem(key, JSON.stringify(res))
|
|
43
|
+
}
|
|
44
|
+
} catch (e) {
|
|
45
|
+
resolve(undefined)
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const upDateCatch = (params, time = 0) => {
|
|
51
|
+
// 覆盖缓存
|
|
52
|
+
const { id } = params
|
|
53
|
+
const key = createdId(id)
|
|
54
|
+
setTimeout(async () => {
|
|
55
|
+
let res = await getGenericSearchById(params)
|
|
56
|
+
await setLocalStorageItem(key, JSON.stringify(res))
|
|
57
|
+
}, time)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
// 个性设置更新本地缓存,不依赖接口
|
|
62
|
+
export const upDateLocalCache = async (params, type = 'update') => {
|
|
63
|
+
// 更新单条快照
|
|
64
|
+
const { genericId } = params
|
|
65
|
+
const key = createdId(genericId)
|
|
66
|
+
const value = await getLocalStorageItem(key)
|
|
67
|
+
const _value = JSON.parse(value)
|
|
68
|
+
if (type === 'update') {
|
|
69
|
+
// 只更新快照
|
|
70
|
+
_value.fieldSnapshot = params.fieldSnapshot
|
|
71
|
+
} else if (type === 'reset') {
|
|
72
|
+
// 清空快照
|
|
73
|
+
_value.fieldSnapshot = ''
|
|
74
|
+
}
|
|
75
|
+
await setLocalStorageItem(key, JSON.stringify(_value))
|
|
76
|
+
// 更新菜单配置下的fieldContent
|
|
77
|
+
const menuKey = menuCacheKey()
|
|
78
|
+
const menuValue = await getLocalStorageItem(menuKey)
|
|
79
|
+
const _menuValue = JSON.parse(menuValue)
|
|
80
|
+
_menuValue.some(v => {
|
|
81
|
+
if (v.id === params.genericId) {
|
|
82
|
+
v.fieldContent = params.fieldContent
|
|
83
|
+
return true
|
|
84
|
+
} else {
|
|
85
|
+
return false
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
// let promise = new Promise(async resolve => {
|
|
90
|
+
// resolve(_menuValue)
|
|
91
|
+
// })
|
|
92
|
+
// store缓存也更新下
|
|
93
|
+
// store.commit('SET_GENERIC_DATA', promise)
|
|
94
|
+
await setLocalStorageItem(menuKey, JSON.stringify(_menuValue))
|
|
95
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.pe-table-wrappper {
|
|
2
|
+
position: relative;
|
|
3
|
+
height: 100%;
|
|
4
|
+
width: 100%;
|
|
5
|
+
.table-box {
|
|
6
|
+
height: 100%;
|
|
7
|
+
overflow-y: auto;
|
|
8
|
+
.top-unfixed {
|
|
9
|
+
// background: green;
|
|
10
|
+
}
|
|
11
|
+
.fixed-box {
|
|
12
|
+
height: 100%;
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
.top-fixed {
|
|
16
|
+
// background: pink;
|
|
17
|
+
}
|
|
18
|
+
.table {
|
|
19
|
+
flex: 1;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
// 拓展增加表头参数
|
|
3
|
+
export const addColumnParams = (columns) => {
|
|
4
|
+
// 创建面板图标标识
|
|
5
|
+
const createCollapseFlag = (item, columns) => {
|
|
6
|
+
if (!item.collapseKeys || !item.collapseKeys.length) return false
|
|
7
|
+
const isSome = item.collapseKeys.some(key => {
|
|
8
|
+
const find = columns.find(find => find.key === key)
|
|
9
|
+
return !!find.show
|
|
10
|
+
})
|
|
11
|
+
return isSome
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// 创建背景颜色
|
|
15
|
+
const colors = ['#FEF2EE', '#EBF7FF', '#FFF7EB', '#ECEFF7']
|
|
16
|
+
let colorIndex = 0
|
|
17
|
+
const createBackgroundColor = (item) => {
|
|
18
|
+
let backgroundColor = ''
|
|
19
|
+
if (item.children && item.children.length > 0) {
|
|
20
|
+
backgroundColor = colors[colorIndex % colors.length]
|
|
21
|
+
colorIndex++
|
|
22
|
+
}
|
|
23
|
+
return backgroundColor
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return columns.map(item => {
|
|
27
|
+
return {
|
|
28
|
+
...item,
|
|
29
|
+
children: addColumnParams(item.children || []),
|
|
30
|
+
// 增加 isShowCollapseIcon 辅助字段,用于动态根据 collapseKeys 判断是否显示折叠图标
|
|
31
|
+
isShowCollapseIcon: createCollapseFlag(item, columns),
|
|
32
|
+
// 如果每项的 children 属性存在,则添加 bg 属性,依次设置为 colors 数组
|
|
33
|
+
bg: createBackgroundColor(item)
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const Vue = window.Vue // 在此项目中,Vue使用的是public下的运行时的vue.reuntime.min.js。所以此时需要保持一致
|
|
2
|
+
import { http } from './http'
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const createUuid = () => {
|
|
6
|
+
return Math.random().toString(36).substr(3)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const tableDecrypt = async (val) => {
|
|
10
|
+
const { column, rowData } = val
|
|
11
|
+
const { key, label } = column
|
|
12
|
+
|
|
13
|
+
if (rowData[key + 'Mask']) {
|
|
14
|
+
await vant.Dialog.confirm({ title: '温馨提示', message: `如非必要请勿查看,此操作会联动风控系统监控!` })
|
|
15
|
+
const { id } = rowData
|
|
16
|
+
|
|
17
|
+
let params = {
|
|
18
|
+
dataId: id || createUuid(),
|
|
19
|
+
moduleCode: 'pe_stock_h5',
|
|
20
|
+
fieldName: label,
|
|
21
|
+
fieldContent: rowData[key + 'Mask'],
|
|
22
|
+
fieldNameStr: '',
|
|
23
|
+
buttonName: label,
|
|
24
|
+
}
|
|
25
|
+
let res = await http('syslog.sensitiveFieldViewLog.save', '10124', params)
|
|
26
|
+
Vue.set(rowData, key, res)
|
|
27
|
+
Vue.delete(rowData, key + 'Mask')
|
|
28
|
+
return false
|
|
29
|
+
} else {
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const http = (ksui.default && ksui.default.http) || ksui.http
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// 设置本地缓存
|
|
2
|
+
export const setLocalStorageItem = (key, value) => {
|
|
3
|
+
if (typeof value !== 'string') {
|
|
4
|
+
/** console.error('ios本地只能存字符串,非字符串类型强行转为字符串类型存储') */
|
|
5
|
+
}
|
|
6
|
+
// ios端只支持存字符串
|
|
7
|
+
value = typeof value === 'string' ? value : String(value)
|
|
8
|
+
return new Promise(async (resolve) => {
|
|
9
|
+
try {
|
|
10
|
+
await window.ks.callFunc({
|
|
11
|
+
method: "storageSetItem",
|
|
12
|
+
params: { key: key, value: value }
|
|
13
|
+
})
|
|
14
|
+
resolve()
|
|
15
|
+
} catch (e) {
|
|
16
|
+
window.localStorage.setItem(key, value)
|
|
17
|
+
resolve()
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const getLocalStorageItem = async (key) => {
|
|
23
|
+
return new Promise(async resolve => {
|
|
24
|
+
try {
|
|
25
|
+
const value = await window.ks.callFunc({
|
|
26
|
+
method: "storageGetItem",
|
|
27
|
+
params: { key: key }
|
|
28
|
+
})
|
|
29
|
+
resolve(value)
|
|
30
|
+
} catch (e) {
|
|
31
|
+
const value = window.localStorage.getItem(key)
|
|
32
|
+
resolve(value)
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
}
|
|
File without changes
|