diff --git a/.gitignore b/.gitignore index 91734d4..a1a9a24 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,14 @@ dist *.local .history +# 由 @uni-helper/vite-plugin-uni-pages 从 pages.config.ts + definePage 生成,勿手改、勿提交 +src/pages.json + +# 生成物:插件在 dev/build 时自动生成 +src/types/auto-imports.d.ts +src/types/components.d.ts +src/types/uni-pages.d.ts + # Editor directories and files .idea *.suo diff --git a/README.md b/README.md index d72b466..987be15 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ pnpm install ``` +> **提示**:`src/pages.json` 是构建产物(由 `pages.config.json` 与各页面的 `definePage` 宏生成),不随仓库提交。克隆项目后如需使用 HBuilderX 等依赖该文件的工具,请先运行一次任意构建或启动命令(如 `pnpm run dev:h5`)生成。请勿手工编辑该文件:页面路由请修改对应页面的 `definePage`,全局配置(tabBar、globalStyle 等)请修改根目录 `pages.config.json`。 + ### H5 启动 ```bash diff --git a/components.d.ts b/components.d.ts deleted file mode 100644 index 59ed0a0..0000000 --- a/components.d.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* eslint-disable */ -/* prettier-ignore */ -// @ts-nocheck -// Generated by vite-plugin-uni-components -// Read more: https://github.com/vuejs/core/pull/3399 -export {} - -declare module 'vue' { - export interface GlobalComponents { - CuDateQuery: typeof import('./src/components/cu-date-query/index.vue')['default'] - CustomNavbar: typeof import('./src/components/custom-navbar/index.vue')['default'] - CustomTree: typeof import('./src/components/custom-tree/index.vue')['default'] - Loading1: typeof import('./src/components/qiun-loading/loading1.vue')['default'] - Loading2: typeof import('./src/components/qiun-loading/loading2.vue')['default'] - Loading3: typeof import('./src/components/qiun-loading/loading3.vue')['default'] - Loading4: typeof import('./src/components/qiun-loading/loading4.vue')['default'] - Loading5: typeof import('./src/components/qiun-loading/loading5.vue')['default'] - QiunDataCharts: typeof import('./src/components/qiun-data-charts/qiun-data-charts.vue')['default'] - QiunError: typeof import('./src/components/qiun-error/qiun-error.vue')['default'] - QiunLoading: typeof import('./src/components/qiun-loading/qiun-loading.vue')['default'] - WdActionSheet: typeof import('@wot-ui/ui/components/wd-action-sheet/wd-action-sheet.vue')['default'] - WdBadge: typeof import('@wot-ui/ui/components/wd-badge/wd-badge.vue')['default'] - WdButton: typeof import('@wot-ui/ui/components/wd-button/wd-button.vue')['default'] - WdCalendar: typeof import('@wot-ui/ui/components/wd-calendar/wd-calendar.vue')['default'] - WdCard: typeof import('@wot-ui/ui/components/wd-card/wd-card.vue')['default'] - WdCascader: typeof import('@wot-ui/ui/components/wd-cascader/wd-cascader.vue')['default'] - WdCell: typeof import('@wot-ui/ui/components/wd-cell/wd-cell.vue')['default'] - WdCellGroup: typeof import('@wot-ui/ui/components/wd-cell-group/wd-cell-group.vue')['default'] - WdCheckbox: typeof import('@wot-ui/ui/components/wd-checkbox/wd-checkbox.vue')['default'] - WdCollapse: typeof import('@wot-ui/ui/components/wd-collapse/wd-collapse.vue')['default'] - WdCollapseItem: typeof import('@wot-ui/ui/components/wd-collapse-item/wd-collapse-item.vue')['default'] - WdConfigProvider: typeof import('@wot-ui/ui/components/wd-config-provider/wd-config-provider.vue')['default'] - WdDialog: typeof import('@wot-ui/ui/components/wd-dialog/wd-dialog.vue')['default'] - WdDivider: typeof import('@wot-ui/ui/components/wd-divider/wd-divider.vue')['default'] - WdDropMenu: typeof import('@wot-ui/ui/components/wd-drop-menu/wd-drop-menu.vue')['default'] - WdDropMenuItem: typeof import('@wot-ui/ui/components/wd-drop-menu-item/wd-drop-menu-item.vue')['default'] - WdEmpty: typeof import('@wot-ui/ui/components/wd-empty/wd-empty.vue')['default'] - WdFab: typeof import('@wot-ui/ui/components/wd-fab/wd-fab.vue')['default'] - WdForm: typeof import('@wot-ui/ui/components/wd-form/wd-form.vue')['default'] - WdFormItem: typeof import('@wot-ui/ui/components/wd-form-item/wd-form-item.vue')['default'] - WdGrid: typeof import('@wot-ui/ui/components/wd-grid/wd-grid.vue')['default'] - WdGridItem: typeof import('@wot-ui/ui/components/wd-grid-item/wd-grid-item.vue')['default'] - WdIcon: typeof import('@wot-ui/ui/components/wd-icon/wd-icon.vue')['default'] - WdImgCropper: typeof import('@wot-ui/ui/components/wd-img-cropper/wd-img-cropper.vue')['default'] - WdInput: typeof import('@wot-ui/ui/components/wd-input/wd-input.vue')['default'] - WdInputNumber: typeof import('@wot-ui/ui/components/wd-input-number/wd-input-number.vue')['default'] - WdLoading: typeof import('@wot-ui/ui/components/wd-loading/wd-loading.vue')['default'] - WdLoadmore: typeof import('@wot-ui/ui/components/wd-loadmore/wd-loadmore.vue')['default'] - WdNotify: typeof import('@wot-ui/ui/components/wd-notify/wd-notify.vue')['default'] - WdPopup: typeof import('@wot-ui/ui/components/wd-popup/wd-popup.vue')['default'] - WdRadio: typeof import('@wot-ui/ui/components/wd-radio/wd-radio.vue')['default'] - WdRadioGroup: typeof import('@wot-ui/ui/components/wd-radio-group/wd-radio-group.vue')['default'] - WdSearch: typeof import('@wot-ui/ui/components/wd-search/wd-search.vue')['default'] - WdSelectPicker: typeof import('@wot-ui/ui/components/wd-select-picker/wd-select-picker.vue')['default'] - WdSwiper: typeof import('@wot-ui/ui/components/wd-swiper/wd-swiper.vue')['default'] - WdSwitch: typeof import('@wot-ui/ui/components/wd-switch/wd-switch.vue')['default'] - WdTabbar: typeof import('@wot-ui/ui/components/wd-tabbar/wd-tabbar.vue')['default'] - WdTabbarItem: typeof import('@wot-ui/ui/components/wd-tabbar-item/wd-tabbar-item.vue')['default'] - WdTag: typeof import('@wot-ui/ui/components/wd-tag/wd-tag.vue')['default'] - WdTextarea: typeof import('@wot-ui/ui/components/wd-textarea/wd-textarea.vue')['default'] - WdToast: typeof import('@wot-ui/ui/components/wd-toast/wd-toast.vue')['default'] - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs index 76db3fa..6b2d005 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -29,6 +29,7 @@ export default [ "**/qiun-**/**", "**/auto-imports.d.ts", "src/types/auto-imports.d.ts", + "src/types/components.d.ts", ], }, // 检查文件的配置 diff --git a/package.json b/package.json index d2df9c5..3133525 100644 --- a/package.json +++ b/package.json @@ -95,22 +95,21 @@ "@dcloudio/uni-mp-xhs": "3.0.0-4020420240722002", "@dcloudio/uni-quickapp-webview": "3.0.0-4020420240722002", "@uni-helper/uni-use": "^0.19.15", - "@vueuse/core": "9.13.0", "@wot-ui/ui": "^2.2.0", "dayjs": "^1.11.13", "pinia": "^2.3.1", - "vue": "^3.5.22", - "vue-i18n": "^9.14.4" + "vue": "^3.5.22" }, "devDependencies": { "@commitlint/cli": "^19.8.1", "@commitlint/config-conventional": "^19.8.1", "@dcloudio/types": "^3.4.24", - "@dcloudio/uni-automator": "3.0.0-4020420240722002", "@dcloudio/uni-cli-shared": "3.0.0-4020420240722002", "@dcloudio/uni-stacktracey": "3.0.0-4020420240722002", "@dcloudio/vite-plugin-uni": "3.0.0-4020420240722002", "@eslint/js": "^9.37.0", + "@typescript-eslint/eslint-plugin": "^8.46.0", + "@typescript-eslint/parser": "^8.46.0", "@uni-helper/uni-types": "1.0.0-alpha.6", "@uni-helper/vite-plugin-uni-components": "^0.2.3", "@uni-helper/vite-plugin-uni-layouts": "^0.1.11", @@ -130,7 +129,6 @@ "postcss-scss": "^4.0.9", "prettier": "^3.6.2", "sass": "1.78.0", - "sass-loader": "^16.0.5", "stylelint": "^16.25.0", "stylelint-config-html": "^1.1.0", "stylelint-config-recess-order": "^5.1.1", diff --git a/pages.config.ts b/pages.config.ts index b0d8eb8..59e789e 100644 --- a/pages.config.ts +++ b/pages.config.ts @@ -1,4 +1,4 @@ -// pages.config.ts +// pages.config.ts import { defineUniPages } from "@uni-helper/vite-plugin-uni-pages"; export default defineUniPages({ @@ -14,14 +14,10 @@ export default defineUniPages({ backgroundColorBottom: "@bgColorBottom", enablePullDownRefresh: false, onReachBottomDistance: 50, - animationType: "pop-in", - animationDuration: 300, }, tabBar: { custom: true, - customize: true, - overlay: true, height: "0", color: "@tabColor", selectedColor: "@tabSelectedColor", diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml deleted file mode 100644 index 1d59544..0000000 --- a/pnpm-workspace.yaml +++ /dev/null @@ -1,4 +0,0 @@ -allowBuilds: - core-js: false - esbuild: false - vue-demi: false diff --git a/shims-uni.d.ts b/shims-uni.d.ts deleted file mode 100644 index 80efd65..0000000 --- a/shims-uni.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/// -import "vue"; - -declare module "@vue/runtime-core" { - type Hooks = App.AppInstance & Page.PageInstance; - - interface ComponentCustomOptions extends Hooks {} -} diff --git a/src/App.vue b/src/App.vue index afc612e..82f53b0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,13 +1,11 @@ diff --git a/src/components/u-charts/readme.md b/src/components/u-charts/readme.md deleted file mode 100644 index b390690..0000000 --- a/src/components/u-charts/readme.md +++ /dev/null @@ -1,6 +0,0 @@ -# uCharts JSSDK说明 - -1、如不使用uCharts组件,可直接引用u-charts.js,打包编译后会`自动压缩`,压缩后体积约为`120kb`。 -2、如果120kb的体积仍需压缩,请手到uCharts官网通过在线定制选择您需要的图表。 -3、config-ucharts.js为uCharts组件的用户配置文件,升级前请`自行备份config-ucharts.js`文件,以免被强制覆盖。 -4、config-echarts.js为ECharts组件的用户配置文件,升级前请`自行备份config-echarts.js`文件,以免被强制覆盖。 diff --git a/src/components/u-charts/u-charts.min.js b/src/components/u-charts/u-charts.min.js deleted file mode 100644 index 0902ecd..0000000 --- a/src/components/u-charts/u-charts.min.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * uCharts (R) - * 高性能跨平台图表库,支持H5、APP、小程序(微信/支付宝/百度/头条/QQ/360/快手)、Vue、Taro等支持canvas的框架平台 - * Copyright (C) 2021 QIUN (R) 秋云 https://www.ucharts.cn All rights reserved. - * Licensed ( http://www.apache.org/licenses/LICENSE-2.0 ) - * 复制使用请保留本段注释,感谢支持开源! - * - * uCharts (R) 官方网站 - * https://www.uCharts.cn - * - * 开源地址: - * https://gitee.com/uCharts/uCharts - * - * uni-app插件市场地址: - * http://ext.dcloud.net.cn/plugin?id=271 - * - */ -"use strict";var config={version:"v2.5.0-20230101",yAxisWidth:15,xAxisHeight:22,padding:[10,10,10,10],rotate:false,fontSize:13,fontColor:"#666666",dataPointShape:["circle","circle","circle","circle"],color:["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272","#FC8452","#9A60B4","#ea7ccc"],linearColor:["#0EE2F8","#2BDCA8","#FA7D8D","#EB88E2","#2AE3A0","#0EE2F8","#EB88E2","#6773E3","#F78A85"],pieChartLinePadding:15,pieChartTextPadding:5,titleFontSize:20,subtitleFontSize:15,radarLabelTextMargin:13};var assign=function(e,...t){if(e==null){throw new TypeError("[uCharts] Cannot convert undefined or null to object")}if(!t||t.length<=0){return e}function i(e,a){for(let t in a){e[t]=e[t]&&e[t].toString()==="[object Object]"?i(e[t],a[t]):e[t]=a[t]}return e}t.forEach(t=>{e=i(e,t)});return e};var util={toFixed:function t(e,a){a=a||2;if(this.isFloat(e)){e=e.toFixed(a)}return e},isFloat:function t(e){return e%1!==0},approximatelyEqual:function t(e,a){return Math.abs(e-a)<1e-10},isSameSign:function t(e,a){return Math.abs(e)===e&&Math.abs(a)===a||Math.abs(e)!==e&&Math.abs(a)!==a},isSameXCoordinateArea:function t(e,a){return this.isSameSign(e.x,a.x)},isCollision:function t(e,a){e.end={};e.end.x=e.start.x+e.width;e.end.y=e.start.y-e.height;a.end={};a.end.x=a.start.x+a.width;a.end.y=a.start.y-a.height;var i=a.start.x>e.end.x||a.end.xe.start.y||a.start.y1){if(r.extra.mount.widthRatio>2)r.extra.mount.widthRatio=2;n+=(r.extra.mount.widthRatio-1)*a.eachSpacing}var l=e;if(e>=0){l=0;t.uevent.trigger("scrollLeft");t.scrollOption.position="left";r.xAxis.scrollPosition="left"}else if(Math.abs(e)>=n-o){l=o-n;t.uevent.trigger("scrollRight");t.scrollOption.position="right";r.xAxis.scrollPosition="right"}else{t.scrollOption.position=e;r.xAxis.scrollPosition=e}return l}function isInAngleRange(t,e,a){function i(t){while(t<0){t+=2*Math.PI}while(t>2*Math.PI){t-=2*Math.PI}return t}t=i(t);e=i(e);a=i(a);if(e>a){a+=2*Math.PI;if(t=e&&t<=a}function createCurveControlPoints(t,e){function a(t,e){if(t[e-1]&&t[e+1]){return t[e].y>=Math.max(t[e-1].y,t[e+1].y)||t[e].y<=Math.min(t[e-1].y,t[e+1].y)}else{return false}}function c(t,e){if(t[e-1]&&t[e+1]){return t[e].x>=Math.max(t[e-1].x,t[e+1].x)||t[e].x<=Math.min(t[e-1].x,t[e+1].x)}else{return false}}var i=.2;var r=.2;var o=null;var n=null;var l=null;var s=null;if(e<1){o=t[0].x+(t[1].x-t[0].x)*i;n=t[0].y+(t[1].y-t[0].y)*i}else{o=t[e].x+(t[e+1].x-t[e-1].x)*i;n=t[e].y+(t[e+1].y-t[e-1].y)*i}if(e>t.length-3){var h=t.length-1;l=t[h].x-(t[h].x-t[h-1].x)*r;s=t[h].y-(t[h].y-t[h-1].y)*r}else{l=t[e+1].x-(t[e+2].x-t[e].x)*r;s=t[e+1].y-(t[e+2].y-t[e].y)*r}if(a(t,e+1)){s=t[e+1].y}if(a(t,e)){n=t[e].y}if(c(t,e+1)){l=t[e+1].x}if(c(t,e)){o=t[e].x}if(n>=Math.max(t[e].y,t[e+1].y)||n<=Math.min(t[e].y,t[e+1].y)){n=t[e].y}if(s>=Math.max(t[e].y,t[e+1].y)||s<=Math.min(t[e].y,t[e+1].y)){s=t[e+1].y}if(o>=Math.max(t[e].x,t[e+1].x)||o<=Math.min(t[e].x,t[e+1].x)){o=t[e].x}if(l>=Math.max(t[e].x,t[e+1].x)||l<=Math.min(t[e].x,t[e+1].x)){l=t[e+1].x}return{ctrA:{x:o,y:n},ctrB:{x:l,y:s}}}function convertCoordinateOrigin(t,e,a){return{x:a.x+t,y:a.y-e}}function avoidCollision(t,e){if(e){while(util.isCollision(t,e)){if(t.start.x>0){t.start.y--}else if(t.start.x<0){t.start.y++}else{if(t.start.y>0){t.start.y++}else{t.start.y--}}}}return t}function fixPieSeries(e,a,t){let i=[];if(e.length>0&&e[0].data.constructor.toString().indexOf("Array")>-1){a._pieSeries_=e;let t=e[0].data;for(var r=0;r=1e4){a=1e3}else if(i>=1e3){a=100}else if(i>=100){a=10}else if(i>=10){a=5}else if(i>=1){a=1}else if(i>=.1){a=.1}else if(i>=.01){a=.01}else if(i>=.001){a=.001}else if(i>=1e-4){a=1e-4}else if(i>=1e-5){a=1e-5}else{a=1e-6}return{minRange:findRange(t,"lower",a),maxRange:findRange(e,"upper",a)}}function measureText(a,t,e){var i=0;a=String(a);e=false;if(e!==false&&e!==undefined&&e.setFontSize&&e.measureText){e.setFontSize(t);return e.measureText(a).width}else{var a=a.split("");for(let e=0;e-1;if(n){let t=filterSeries(e);for(var l=0;l5&&arguments[5]!==undefined?arguments[5]:{};var l=a.chartData.calPoints?a.chartData.calPoints:[];let s={};if(r.length>0){let e=[];for(let t=0;t0){e=o[i]}return{text:n.formatter?n.formatter(t,e,i,a):t.name+": "+t.data,color:t.color,legendShape:a.extra.tooltip.legendShape=="auto"?t.legendShape:a.extra.tooltip.legendShape}});var h={x:Math.round(s.x),y:Math.round(s.y)};return{textList:e,offset:h}}function getMixToolTipData(t,e,a,i){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var o=e.chartData.xAxisPoints[a]+e.chartData.eachSpacing/2;var n=t.map(function(t){return{text:r.formatter?r.formatter(t,i[a],a,e):t.name+": "+t.data,color:t.color,disableLegend:t.disableLegend?true:false,legendShape:e.extra.tooltip.legendShape=="auto"?t.legendShape:e.extra.tooltip.legendShape}});n=n.filter(function(t){if(t.disableLegend!==true){return t}});var l={x:Math.round(o),y:0};return{textList:n,offset:l}}function getCandleToolTipData(o,e,n,l,i,t){var r=arguments.length>6&&arguments[6]!==undefined?arguments[6]:{};var a=n.chartData.calPoints;let s=t.color.upFill;let h=t.color.downFill;let c=[s,s,h,s];var d=[];e.map(function(t){if(l==0){if(t.data[1]-t.data[0]<0){c[1]=h}else{c[1]=s}}else{if(t.data[0]o[l-1][1]){c[2]=s}if(t.data[3]4&&arguments[4]!==undefined?arguments[4]:0;var l={index:-1,group:[]};var i=e.chartData.eachSpacing/2;let r=[];if(n&&n.length>0){if(!e.categories){i=0}else{for(let t=1;tt){l.index=e}})}}}return l}function findBarChartCurrentIndex(a,t,e,i){var r=arguments.length>4&&arguments[4]!==undefined?arguments[4]:0;var o={index:-1,group:[]};var n=e.chartData.eachSpacing/2;let l=e.chartData.yAxisPoints;if(t&&t.length>0){if(isInExactChartArea(a,e,i)){l.forEach(function(t,e){if(a.y+r+n>t){o.index=e}})}}return o}function findLegendIndex(o,t,e){let n=-1;let l=0;if(isInExactLegendArea(o,t.area)){let i=t.points;let r=-1;for(let t=0,e=i.length;tt[0]-l&&o.xt[1]-l&&o.ye.start.x&&t.xe.start.y&&t.y=e.area[3]-10&&t.y>=e.area[0]&&t.y<=e.height-e.area[2]}function findRadarChartCurrentIndex(t,e,a){var r=2*Math.PI/a;var o=-1;if(isInExactPieChartArea(t,e.center,e.radius)){var n=function t(e){if(e<0){e+=2*Math.PI}if(e>2*Math.PI){e-=2*Math.PI}return e};var l=Math.atan2(e.center.y-t.y,t.x-e.center.x);l=-1*l;if(l<0){l+=2*Math.PI}var i=e.angleList.map(function(t){t=n(-1*t);return t});i.forEach(function(t,e){var a=n(t-r/2);var i=n(t+r/2);if(i=a&&l<=i||l+2*Math.PI>=a&&l+2*Math.PI<=i){o=e}})}return o}function findFunnelChartCurrentIndex(t,e){var a=-1;for(var i=0,r=e.series.length;io.funnelArea[0]&&t.xo.funnelArea[1]&&t.yo.area[0]&&t.xo.area[1]&&t.ys.width-s.area[1]-s.area[3]){i.push(n);o.push(r-s.legend.itemGap*s.pix);r=e;n=[t]}else{r+=e;n.push(t)}}if(n.length){i.push(n);o.push(r-s.legend.itemGap*s.pix);c.widthArr=o;let t=Math.max.apply(null,o);switch(s.legend.float){case"left":c.area.start.x=s.area[3];c.area.end.x=s.area[3]+t+2*d;break;case"right":c.area.start.x=s.width-s.area[1]-t-2*d;c.area.end.x=s.width-s.area[1];break;default:c.area.start.x=(s.width-t)/2-d;c.area.end.x=(s.width+t)/2+d}c.area.width=t+2*d;c.area.wholeWidth=t+2*d;c.area.height=i.length*u+2*d;c.area.wholeHeight=i.length*u+2*d+2*x;c.points=i}}else{let t=l.length;let e=s.height-s.area[0]-s.area[2]-2*x-2*d;let a=Math.min(Math.floor(e/u),t);c.area.height=a*u+d*2;c.area.wholeHeight=a*u+d*2;switch(s.legend.float){case"top":c.area.start.y=s.area[0]+x;c.area.end.y=s.area[0]+x+c.area.height;break;case"bottom":c.area.start.y=s.height-s.area[2]-x-c.area.height;c.area.end.y=s.height-s.area[2]-x;break;default:c.area.start.y=(s.height-c.area.height)/2;c.area.end.y=(s.height+c.area.height)/2}let i=t%a===0?t/a:Math.floor(t/a+1);let r=[];for(let e=0;ei){i=t}}c.widthArr.push(i);c.heightArr.push(a.length*u+d*2)}let e=0;for(let t=0;t4&&arguments[4]!==undefined?arguments[4]:-1;var i;if(c=="stack"){i=dataCombineStack(t,e.categories.length)}else{i=dataCombine(t)}var r=[];i=i.filter(function(t){if(typeof t==="object"&&t!==null){if(t.constructor.toString().indexOf("Array")>-1){return t!==null}else{return t.value!==null}}else{return t!==null}});i.map(function(t){if(typeof t==="object"){if(t.constructor.toString().indexOf("Array")>-1){if(e.type=="candle"){t.map(function(t){r.push(t)})}else{r.push(t[0])}}else{r.push(t.value)}}else{r.push(t)}});var o=0;var n=0;if(r.length>0){o=Math.min.apply(this,r);n=Math.max.apply(this,r)}if(a>-1){if(typeof e.xAxis.data[a].min==="number"){o=Math.min(e.xAxis.data[a].min,o)}if(typeof e.xAxis.data[a].max==="number"){n=Math.max(e.xAxis.data[a].max,n)}}else{if(typeof e.xAxis.min==="number"){o=Math.min(e.xAxis.min,o)}if(typeof e.xAxis.max==="number"){n=Math.max(e.xAxis.max,n)}}if(o===n){var d=n||10;n+=d}var l=o;var x=n;var f=[];var p=(x-l)/e.xAxis.splitNumber;for(var s=0;s<=e.xAxis.splitNumber;s++){f.push(l+p*s)}return f}function calXAxisData(t,e,a,i){var r=assign({},{type:""},e.extra.bar);var o={angle:0,xAxisHeight:e.xAxis.lineHeight*e.pix+e.xAxis.marginTop*e.pix};o.ranges=getXAxisTextList(t,e,a,r.type);o.rangesFormat=o.ranges.map(function(t){t=util.toFixed(t,2);return t});var n=o.ranges.map(function(t){t=util.toFixed(t,2);return t});o=Object.assign(o,getXAxisPoints(n,e,a));var l=o.eachSpacing;var s=n.map(function(t){return measureText(t,e.xAxis.fontSize*e.pix,i)});if(e.xAxis.disabled===true){o.xAxisHeight=0}return o}function getRadarDataPoints(r,o,n,a,t){var l=arguments.length>5&&arguments[5]!==undefined?arguments[5]:1;var e=t.extra.radar||{};e.max=e.max||0;var s=Math.max(e.max,Math.max.apply(null,dataCombine(a)));var h=[];for(let e=0;e2&&arguments[2]!==undefined?arguments[2]:1;var o=0;var n=0;for(let e=0;e4&&arguments[4]!==undefined?arguments[4]:1;for(let t=0;t4&&arguments[4]!==undefined?arguments[4]:1;var l=0;var s=0;var h=[];for(let e=0;e2&&arguments[2]!==undefined?arguments[2]:1;if(o==1){o=.999999}for(let a=0;a=2){t._proportion_=t._proportion_%2}}return i}function getGaugeArcbarDataPoints(i,r){var o=arguments.length>2&&arguments[2]!==undefined?arguments[2]:1;if(o==1){o=.999999}for(let a=0;a=2){t._proportion_=t._proportion_%2}}return i}function getGaugeAxisPoints(e,a,t){let i;if(t=2){e[t]._endAngle_=e[t]._endAngle_%2}r=e[t]._endAngle_}return e}function getGaugeDataPoints(i,r,o){let n=arguments.length>3&&arguments[3]!==undefined?arguments[3]:1;for(let a=0;a=o.oldData){e._proportion_=(e._endAngle_-e._oldAngle_)*n+o.oldAngle}else{e._proportion_=e._oldAngle_-(e._oldAngle_-e._endAngle_)*n}if(e._proportion_>=2){e._proportion_=e._proportion_%2}}return i}function getPieTextMaxLength(i,r,o,n){i=getPieDataPoints(i);let l=0;for(let a=0;a0){t.width=Math.min(t.width,+n.extra.mix.column.width*n.pix)}if(n.extra.column&&n.extra.column.width&&+n.extra.column.width>0){t.width=Math.min(t.width,+n.extra.column.width*n.pix)}if(t.width<=0){t.width=1}t.x+=(o+.5-r/2)*(t.width+e);return t})}function fixBarData(t,i,r,o,e,n){return t.map(function(t){if(t===null){return null}var e=0;var a=0;e=n.extra.bar.seriesGap*n.pix||0;a=n.extra.bar.categoryGap*n.pix||0;e=Math.min(e,i/r);a=Math.min(a,i/r);t.width=Math.ceil((i-2*a-e*(r-1))/r);if(n.extra.bar&&n.extra.bar.width&&+n.extra.bar.width>0){t.width=Math.min(t.width,+n.extra.bar.width*n.pix)}if(t.width<=0){t.width=1}t.y+=(o+.5-r/2)*(t.width+e);return t})}function fixColumeMeterData(t,e,a,i,r,o,n){var l=o.extra.column.categoryGap*o.pix||0;return t.map(function(t){if(t===null){return null}t.width=e-2*l;if(o.extra.column&&o.extra.column.width&&+o.extra.column.width>0){t.width=Math.min(t.width,+o.extra.column.width*o.pix)}if(i>0){t.width-=n}return t})}function fixColumeStackData(t,a,e,i,r,o,n){var l=o.extra.column.categoryGap*o.pix||0;return t.map(function(t,e){if(t===null){return null}t.width=Math.ceil(a-2*l);if(o.extra.column&&o.extra.column.width&&+o.extra.column.width>0){t.width=Math.min(t.width,+o.extra.column.width*o.pix)}if(t.width<=0){t.width=1}return t})}function fixBarStackData(t,a,e,i,r,o,n){var l=o.extra.bar.categoryGap*o.pix||0;return t.map(function(t,e){if(t===null){return null}t.width=Math.ceil(a-2*l);if(o.extra.bar&&o.extra.bar.width&&+o.extra.bar.width>0){t.width=Math.min(t.width,+o.extra.bar.width*o.pix)}if(t.width<=0){t.width=1}return t})}function getXAxisPoints(t,e,h){var a=e.width-e.area[1]-e.area[3];var i=e.enableScroll?Math.min(e.xAxis.itemCount,t.length):t.length;if((e.type=="line"||e.type=="area"||e.type=="scatter"||e.type=="bubble"||e.type=="bar")&&i>1&&e.xAxis.boundaryGap=="justify"){i-=1}var r=0;if(e.type=="mount"&&e.extra&&e.extra.mount&&e.extra.mount.widthRatio&&e.extra.mount.widthRatio>1){if(e.extra.mount.widthRatio>2)e.extra.mount.widthRatio=2;r=e.extra.mount.widthRatio-1;i+=r}var o=a/i;var n=[];var l=e.area[3];var s=e.width-e.area[1];t.forEach(function(t,e){n.push(l+r/2*o+e*o)});if(e.xAxis.boundaryGap!=="justify"){if(e.enableScroll===true){n.push(l+r*o+t.length*o)}else{n.push(s)}}return{xAxisPoints:n,startX:l,endX:s,eachSpacing:o}}function getCandleDataPoints(t,l,s,h,c,d,a){var x=arguments.length>7&&arguments[7]!==undefined?arguments[7]:1;var e=[];var f=d.height-d.area[0]-d.area[2];t.forEach(function(t,o){if(t===null){e.push(null)}else{var n=[];t.forEach(function(t,e){var a={};a.x=h[o]+Math.round(c/2);var i=t.value||t;var r=f*(i-l)/(s-l);r*=x;a.y=d.height-Math.round(r)-d.area[2];n.push(a)});e.push(n)}});return e}function getDataPoints(t,a,n,l,s,h,e){var c=arguments.length>7&&arguments[7]!==undefined?arguments[7]:1;var d="center";if(h.type=="line"||h.type=="area"||h.type=="scatter"||h.type=="bubble"){d=h.xAxis.boundaryGap}var x=[];var f=h.height-h.area[0]-h.area[2];var p=h.width-h.area[1]-h.area[3];t.forEach(function(i,t){if(i===null){x.push(null)}else{var r={};r.color=i.color;r.x=l[t];var o=i;if(typeof i==="object"&&i!==null){if(i.constructor.toString().indexOf("Array")>-1){let t,e,a;t=[].concat(h.chartData.xAxisData.ranges);e=t.shift();a=t.pop();o=i[1];r.x=h.area[3]+p*(i[0]-e)/(a-e);if(h.type=="bubble"){r.r=i[2];r.t=i[3]}}else{o=i.value}}if(d=="center"){r.x+=s/2}var e=f*(o-a)/(n-a);e*=c;r.y=h.height-e-h.area[2];x.push(r)}});return x}function getLineDataPoints(t,a,n,l,s,h,e,p,c){var c=arguments.length>8&&arguments[8]!==undefined?arguments[8]:1;var d=h.xAxis.boundaryGap;var x=[];var f=h.height-h.area[0]-h.area[2];var u=h.width-h.area[1]-h.area[3];t.forEach(function(i,t){if(i===null){x.push(null)}else{var r={};r.color=i.color;if(p.animation=="vertical"){r.x=l[t];var o=i;if(typeof i==="object"&&i!==null){if(i.constructor.toString().indexOf("Array")>-1){let t,e,a;t=[].concat(h.chartData.xAxisData.ranges);e=t.shift();a=t.pop();o=i[1];r.x=h.area[3]+u*(i[0]-e)/(a-e)}else{o=i.value}}if(d=="center"){r.x+=s/2}var e=f*(o-a)/(n-a);e*=c;r.y=h.height-e-h.area[2];x.push(r)}else{r.x=l[0]+s*t*c;var o=i;if(d=="center"){r.x+=s/2}var e=f*(o-a)/(n-a);r.y=h.height-e-h.area[2];x.push(r)}}});return x}function getColumnDataPoints(t,a,n,l,s,h,e,i,c){var c=arguments.length>8&&arguments[8]!==undefined?arguments[8]:1;var d=[];var x=h.height-h.area[0]-h.area[2];var f=h.width-h.area[1]-h.area[3];t.forEach(function(i,t){if(i===null){d.push(null)}else{var r={};r.color=i.color;r.x=l[t];var o=i;if(typeof i==="object"&&i!==null){if(i.constructor.toString().indexOf("Array")>-1){let t,e,a;t=[].concat(h.chartData.xAxisData.ranges);e=t.shift();a=t.pop();o=i[1];r.x=h.area[3]+f*(i[0]-e)/(a-e)}else{o=i.value}}r.x+=s/2;var e=x*(o*c-a)/(n-a);r.y=h.height-e-h.area[2];d.push(r)}});return d}function getMountDataPoints(t,o,n,l,s,h,e,a){var c=arguments.length>8&&arguments[8]!==undefined?arguments[8]:1;var d=[];var x=h.height-h.area[0]-h.area[2];var i=h.width-h.area[1]-h.area[3];var f=s*e.widthRatio;t.forEach(function(t,e){if(t===null){d.push(null)}else{var a={};a.color=t.color;a.x=l[e];a.x+=s/2;var i=t.data;var r=x*(i*c-o)/(n-o);a.y=h.height-r-h.area[2];a.value=i;a.width=f;d.push(a)}});return d}function getBarDataPoints(t,o,n,l,e,s,a){var h=arguments.length>7&&arguments[7]!==undefined?arguments[7]:1;var c=[];var i=s.height-s.area[0]-s.area[2];var d=s.width-s.area[1]-s.area[3];t.forEach(function(t,e){if(t===null){c.push(null)}else{var a={};a.color=t.color;a.y=l[e];var i=t;if(typeof t==="object"&&t!==null){i=t.value}var r=d*(i-o)/(n-o);r*=h;a.height=r;a.value=i;a.x=r+s.area[3];c.push(a)}});return c}function getStackDataPoints(t,s,h,c,g,d,e,x,y){var f=arguments.length>9&&arguments[9]!==undefined?arguments[9]:1;var p=[];var u=d.height-d.area[0]-d.area[2];t.forEach(function(t,e){if(t===null){p.push(null)}else{var a={};a.color=t.color;a.x=c[e]+Math.round(g/2);if(x>0){var i=0;for(let t=0;t<=x;t++){i+=y[t].data[e]}var r=i-t;var o=u*(i-s)/(h-s);var n=u*(r-s)/(h-s)}else{var i=t;if(typeof t==="object"&&t!==null){i=t.value}var o=u*(i-s)/(h-s);var n=0}var l=n;o*=f;l*=f;a.y=d.height-Math.round(o)-d.area[2];a.y0=d.height-Math.round(l)-d.area[2];p.push(a)}});return p}function getBarStackDataPoints(t,s,h,c,e,d,a,x,g){var f=arguments.length>9&&arguments[9]!==undefined?arguments[9]:1;var p=[];var u=d.width-d.area[1]-d.area[3];t.forEach(function(t,e){if(t===null){p.push(null)}else{var a={};a.color=t.color;a.y=c[e];if(x>0){var i=0;for(let t=0;t<=x;t++){i+=g[t].data[e]}var r=i-t;var o=u*(i-s)/(h-s);var n=u*(r-s)/(h-s)}else{var i=t;if(typeof t==="object"&&t!==null){i=t.value}var o=u*(i-s)/(h-s);var n=0}var l=n;o*=f;l*=f;a.height=o-l;a.x=d.area[3]+o;a.x0=d.area[3]+l;p.push(a)}});return p}function getYAxisTextList(t,e,h,c,a){var d=arguments.length>5&&arguments[5]!==undefined?arguments[5]:-1;var i;if(c=="stack"){i=dataCombineStack(t,e.categories.length)}else{i=dataCombine(t)}var r=[];i=i.filter(function(t){if(typeof t==="object"&&t!==null){if(t.constructor.toString().indexOf("Array")>-1){return t!==null}else{return t.value!==null}}else{return t!==null}});i.map(function(t){if(typeof t==="object"){if(t.constructor.toString().indexOf("Array")>-1){if(e.type=="candle"){t.map(function(t){r.push(t)})}else{r.push(t[1])}}else{r.push(t.value)}}else{r.push(t)}});var o=a.min||0;var n=a.max||0;if(r.length>0){o=Math.min.apply(this,r);n=Math.max.apply(this,r)}if(o===n){if(n==0){n=10}else{o=0}}var l=getDataRange(o,n);var x=a.min===undefined||a.min===null?l.minRange:a.min;var f=a.max===undefined||a.max===null?l.maxRange:a.max;var p=(f-x)/e.yAxis.splitNumber;var u=[];for(var s=0;s<=e.yAxis.splitNumber;s++){u.push(x+p*s)}return u.reverse()}function calYAxisData(a,o,e,n){var l=assign({},{type:""},o.extra.column);var t=o.yAxis.data.length;var s=new Array(t);if(t>0){for(let e=0;e{return t+(i.unit||"")}}i.categories=i.categories||o.categories;h[r]=i.categories}else{if(!i.formatter){i.formatter=(t,e,a)=>{return util.toFixed(t,i.tofix||0)+(i.unit||"")}}h[r]=getYAxisTextList(s[r],o,e,l.type,i,r)}let a=i.fontSize*o.pix||e.fontSize;d[r]={position:i.position?i.position:"left",width:0};c[r]=h[r].map(function(t,e){t=i.formatter(t,e,o);d[r].width=Math.max(d[r].width,measureText(t,a,n)+5);return t});let t=i.calibration?4*o.pix:0;d[r].width+=t+3*o.pix;if(i.disabled===true){d[r].width=0}}}else{var h=new Array(1);var c=new Array(1);var d=new Array(1);if(o.type==="bar"){h[0]=o.categories;if(!o.yAxis.formatter){o.yAxis.formatter=(t,e,a)=>{return t+(a.yAxis.unit||"")}}}else{if(!o.yAxis.formatter){o.yAxis.formatter=(t,e,a)=>{return t.toFixed(a.yAxis.tofix)+(a.yAxis.unit||"")}}h[0]=getYAxisTextList(a,o,e,l.type,{})}d[0]={position:"left",width:0};var i=o.yAxis.fontSize*o.pix||e.fontSize;c[0]=h[0].map(function(t,e){t=o.yAxis.formatter(t,e,o);d[0].width=Math.max(d[0].width,measureText(t,i,n)+5);return t});d[0].width+=3*o.pix;if(o.yAxis.disabled===true){d[0]={position:"left",width:0};o.yAxis.data[0]={disabled:true}}else{o.yAxis.data[0]={disabled:false,position:"left",max:o.yAxis.max,min:o.yAxis.min,formatter:o.yAxis.formatter};if(o.type==="bar"){o.yAxis.data[0].categories=o.categories;o.yAxis.data[0].type="categories"}}}return{rangesFormat:c,ranges:h,yAxisWidth:d}}function calTooltipYAxisData(r,t,o,e,a){let n=[].concat(o.chartData.yAxisData.ranges);let l=o.height-o.area[0]-o.area[2];let s=o.area[0];let h=[];for(let i=0;i0&&r.tooltip.group.includes(n)==false){return}var l=typeof r.tooltip.index==="number"?r.tooltip.index:r.tooltip.index[r.tooltip.group.indexOf(n)];i.beginPath();if(o.activeType=="hollow"){i.setStrokeStyle(e);i.setFillStyle(r.background);i.setLineWidth(2*r.pix)}else{i.setStrokeStyle("#ffffff");i.setFillStyle(e);i.setLineWidth(1*r.pix)}if(a==="diamond"){t.forEach(function(t,e){if(t!==null&&l==e){i.moveTo(t.x,t.y-4.5);i.lineTo(t.x-4.5,t.y);i.lineTo(t.x,t.y+4.5);i.lineTo(t.x+4.5,t.y);i.lineTo(t.x,t.y-4.5)}})}else if(a==="circle"){t.forEach(function(t,e){if(t!==null&&l==e){i.moveTo(t.x+2.5*r.pix,t.y);i.arc(t.x,t.y,3*r.pix,0,2*Math.PI,false)}})}else if(a==="square"){t.forEach(function(t,e){if(t!==null&&l==e){i.moveTo(t.x-3.5,t.y-3.5);i.rect(t.x-3.5,t.y-3.5,7,7)}})}else if(a==="triangle"){t.forEach(function(t,e){if(t!==null&&l==e){i.moveTo(t.x,t.y-4.5);i.lineTo(t.x-4.5,t.y+4.5);i.lineTo(t.x+4.5,t.y+4.5);i.lineTo(t.x,t.y-4.5)}})}else if(a==="none"){return}i.closePath();i.fill();i.stroke()}function drawRingTitle(t,e,a,i){var r=t.title.fontSize||e.titleFontSize;var o=t.subtitle.fontSize||e.subtitleFontSize;var n=t.title.name||"";var l=t.subtitle.name||"";var c=t.title.color||t.fontColor;var d=t.subtitle.color||t.fontColor;var x=n?r:0;var f=l?o:0;var s=5;if(l){var p=measureText(l,o*t.pix,a);var u=i.x-p/2+(t.subtitle.offsetX||0)*t.pix;var h=i.y+o*t.pix/2+(t.subtitle.offsetY||0)*t.pix;if(n){h+=(x*t.pix+s)/2}a.beginPath();a.setFontSize(o*t.pix);a.setFillStyle(d);a.fillText(l,u,h);a.closePath();a.stroke()}if(n){var g=measureText(n,r*t.pix,a);var y=i.x-g/2+(t.title.offsetX||0);var v=i.y+r*t.pix/2+(t.title.offsetY||0)*t.pix;if(l){v-=(f*t.pix+s)/2}a.beginPath();a.setFontSize(r*t.pix);a.setFillStyle(c);a.fillText(n,y,v);a.closePath();a.stroke()}}function drawPointText(t,o,n,l,s){var h=o.data;var c=o.textOffset?o.textOffset:0;t.forEach(function(t,e){if(t!==null){l.beginPath();var a=o.textSize?o.textSize*s.pix:n.fontSize;l.setFontSize(a);l.setFillStyle(o.textColor||s.fontColor);var i=h[e];if(typeof h[e]==="object"&&h[e]!==null){if(h[e].constructor.toString().indexOf("Array")>-1){i=h[e][1]}else{i=h[e].value}}var r=o.formatter?o.formatter(i,e,o,s):i;l.setTextAlign("center");l.fillText(String(r),t.x,t.y-4+c*s.pix);l.closePath();l.stroke();l.setTextAlign("left")}})}function drawColumePointText(t,n,l,s,h){var c=n.data;var d=n.textOffset?n.textOffset:0;var x=h.extra.column.labelPosition;t.forEach(function(t,e){if(t!==null){s.beginPath();var a=n.textSize?n.textSize*h.pix:l.fontSize;s.setFontSize(a);s.setFillStyle(n.textColor||h.fontColor);var i=c[e];if(typeof c[e]==="object"&&c[e]!==null){if(c[e].constructor.toString().indexOf("Array")>-1){i=c[e][1]}else{i=c[e].value}}var r=n.formatter?n.formatter(i,e,n,h):i;s.setTextAlign("center");var o=t.y-4*h.pix+d*h.pix;if(t.y>n.zeroPoints){o=t.y+d*h.pix+a}if(x=="insideTop"){o=t.y+a+d*h.pix;if(t.y>n.zeroPoints){o=t.y-d*h.pix-4*h.pix}}if(x=="center"){o=t.y+d*h.pix+(h.height-h.area[2]-t.y+a)/2;if(n.zeroPointsn.zeroPoints){o=t.y-d*h.pix-(t.y-n.zeroPoints-a)/2}if(h.extra.column.type=="stack"){o=t.y+d*h.pix+(t.y0-t.y+a)/2}}if(x=="bottom"){o=h.height-h.area[2]+d*h.pix-4*h.pix;if(n.zeroPointsn.zeroPoints){o=n.zeroPoints-d*h.pix+a+2*h.pix}if(h.extra.column.type=="stack"){o=t.y0+d*h.pix-4*h.pix}}s.fillText(String(r),t.x,o);s.closePath();s.stroke();s.setTextAlign("left")}})}function drawMountPointText(t,n,l,s,h,c){var e=n.data;var d=n.textOffset?n.textOffset:0;var a=h.extra.mount.labelPosition;t.forEach(function(t,e){if(t!==null){s.beginPath();var a=n[e].textSize?n[e].textSize*h.pix:l.fontSize;s.setFontSize(a);s.setFillStyle(n[e].textColor||h.fontColor);var i=t.value;var r=n[e].formatter?n[e].formatter(i,e,n,h):i;s.setTextAlign("center");var o=t.y-4*h.pix+d*h.pix;if(t.y>c){o=t.y+d*h.pix+a}s.fillText(String(r),t.x,o);s.closePath();s.stroke();s.setTextAlign("left")}})}function drawBarPointText(t,o,n,l,s){var h=o.data;var e=o.textOffset?o.textOffset:0;t.forEach(function(t,e){if(t!==null){l.beginPath();var a=o.textSize?o.textSize*s.pix:n.fontSize;l.setFontSize(a);l.setFillStyle(o.textColor||s.fontColor);var i=h[e];if(typeof h[e]==="object"&&h[e]!==null){i=h[e].value}var r=o.formatter?o.formatter(i,e,o,s):i;l.setTextAlign("left");l.fillText(String(r),t.x+4*s.pix,t.y+a/2-3);l.closePath();l.stroke()}})}function drawGaugeLabel(e,a,i,r,o,n){a-=e.width/2+e.labelOffset*r.pix;a=a<10?10:a;let t;if(e.endAngle=2){l=l%2}s+=x}}function drawRadarLabel(t,s,h,c,d,x){var f=c.extra.radar||{};t.forEach(function(t,e){if(f.labelPointShow===true&&c.categories[e]!==""){var a={x:s*Math.cos(t),y:s*Math.sin(t)};var i=convertCoordinateOrigin(a.x,a.y,h);x.setFillStyle(f.labelPointColor);x.beginPath();x.arc(i.x,i.y,f.labelPointRadius*c.pix,0,2*Math.PI,false);x.closePath();x.fill()}if(f.labelShow===true){var r={x:(s+d.radarLabelTextMargin*c.pix)*Math.cos(t),y:(s+d.radarLabelTextMargin*c.pix)*Math.sin(t)};var o=convertCoordinateOrigin(r.x,r.y,h);var n=o.x;var l=o.y;if(util.approximatelyEqual(r.x,0)){n-=measureText(c.categories[e]||"",d.fontSize,x)/2}else if(r.x<0){n-=measureText(c.categories[e]||"",d.fontSize,x)}x.beginPath();x.setFontSize(d.fontSize);x.setFillStyle(f.labelColor||c.fontColor);x.fillText(c.categories[e]||"",n,l+d.fontSize/2);x.closePath();x.stroke()}})}function drawPieText(n,d,x,f,t,l){var p=x.pieChartLinePadding;var u=[];var g=null;var y=n.map(function(t,e){var a=t.formatter?t.formatter(t,e,n,d):util.toFixed(t._proportion_.toFixed(4)*100)+"%";a=t.labelText?t.labelText:a;var i=2*Math.PI-(t._start_+2*Math.PI*t._proportion_/2);if(t._rose_proportion_){i=2*Math.PI-(t._start_+2*Math.PI*t._rose_proportion_/2)}var r=t.color;var o=t._radius_;return{arc:i,text:a,color:r,radius:o,textColor:t.textColor,textSize:t.textSize,labelShow:t.labelShow}});for(let c=0;c=0?e+x.pieChartTextPadding:e-x.pieChartTextPadding;let n=a;let l=measureText(t.text,t.textSize*d.pix||x.fontSize,f);let s=n;if(g&&util.isSameXCoordinateArea(g.start,{x:o})){if(o>0){s=Math.min(n,g.start.y)}else if(e<0){s=Math.max(n,g.start.y)}else{if(n>0){s=Math.max(n,g.start.y)}else{s=Math.min(n,g.start.y)}}}if(o<0){o-=l}let h={lineStart:{x:i,y:r},lineEnd:{x:e,y:a},start:{x:o,y:s},width:l,height:x.fontSize,text:t.text,color:t.color,textColor:t.textColor,textSize:t.textSize};g=avoidCollision(h,g);u.push(g)}for(let n=0;nr?r:o.activeWidth;var n=e.area[0];var l=e.height-e.area[2];i.beginPath();i.setFillStyle(hexToRgb(o.activeBgColor,o.activeBgOpacity));i.rect(t-o.activeWidth/2,n,o.activeWidth,l-n);i.closePath();i.fill();i.setFillStyle("#FFFFFF")}function drawBarToolTipSplitArea(t,e,a,i,r){var o=assign({},{activeBgColor:"#000000",activeBgOpacity:.08},e.extra.bar);var n=e.area[3];var l=e.width-e.area[1];i.beginPath();i.setFillStyle(hexToRgb(o.activeBgColor,o.activeBgOpacity));i.rect(n,t-r/2,l-n,r);i.closePath();i.fill();i.setFillStyle("#FFFFFF")}function drawToolTip(e,r,o,a,n,i,f){var l=assign({},{showBox:true,showArrow:true,showCategory:false,bgColor:"#000000",bgOpacity:.7,borderColor:"#000000",borderWidth:0,borderRadius:0,borderOpacity:.7,boxPadding:3,fontColor:"#FFFFFF",fontSize:13,lineHeight:20,legendShow:true,legendShape:"auto",splitLine:true},o.extra.tooltip);if(l.showCategory==true&&o.categories){e.unshift({text:o.categories[o.tooltip.index],color:null})}var s=l.fontSize*o.pix;var p=l.lineHeight*o.pix;var h=l.boxPadding*o.pix;var c=s;var u=5*o.pix;if(l.legendShow==false){c=0;u=0}var d=l.showArrow?8*o.pix:0;var g=false;if(o.type=="line"||o.type=="mount"||o.type=="area"||o.type=="candle"||o.type=="mix"){if(l.splitLine==true){drawToolTipSplitLine(o.tooltip.offset.x,o,a,n)}}r=assign({x:0,y:0},r);r.y-=8*o.pix;var y=e.map(function(t){return measureText(t.text,s,n)});var x=c+u+4*h+Math.max.apply(null,y);var v=2*h+e.length*p;if(l.showBox==false){return}if(r.x-Math.abs(o._scrollDistance_||0)+d+x>o.width){g=true}if(v+r.y>o.height){r.y=o.height-v}n.beginPath();n.setFillStyle(hexToRgb(l.bgColor,l.bgOpacity));n.setLineWidth(l.borderWidth*o.pix);n.setStrokeStyle(hexToRgb(l.borderColor,l.borderOpacity));var t=l.borderRadius;if(g){if(x+d>o.width){r.x=o.width+Math.abs(o._scrollDistance_||0)+d+(x-o.width)}if(x>r.x){r.x=o.width+Math.abs(o._scrollDistance_||0)+d+(x-o.width)}if(l.showArrow){n.moveTo(r.x,r.y+10*o.pix);n.lineTo(r.x-d,r.y+10*o.pix+5*o.pix)}n.arc(r.x-d-t,r.y+v-t,t,0,Math.PI/2,false);n.arc(r.x-d-Math.round(x)+t,r.y+v-t,t,Math.PI/2,Math.PI,false);n.arc(r.x-d-Math.round(x)+t,r.y+t,t,-Math.PI,-Math.PI/2,false);n.arc(r.x-d-t,r.y+t,t,-Math.PI/2,0,false);if(l.showArrow){n.lineTo(r.x-d,r.y+10*o.pix-5*o.pix);n.lineTo(r.x,r.y+10*o.pix)}}else{if(l.showArrow){n.moveTo(r.x,r.y+10*o.pix);n.lineTo(r.x+d,r.y+10*o.pix-5*o.pix)}n.arc(r.x+d+t,r.y+t,t,-Math.PI,-Math.PI/2,false);n.arc(r.x+d+Math.round(x)-t,r.y+t,t,-Math.PI/2,0,false);n.arc(r.x+d+Math.round(x)-t,r.y+v-t,t,0,Math.PI/2,false);n.arc(r.x+d+t,r.y+v-t,t,Math.PI/2,Math.PI,false);if(l.showArrow){n.lineTo(r.x+d,r.y+10*o.pix+5*o.pix);n.lineTo(r.x,r.y+10*o.pix)}}n.closePath();n.fill();if(l.borderWidth>0){n.stroke()}if(l.legendShow){e.forEach(function(t,e){if(t.color!==null){n.beginPath();n.setFillStyle(t.color);var a=r.x+d+2*h;var i=r.y+(p-s)/2+p*e+h+1;if(g){a=r.x-x-d+2*h}switch(t.legendShape){case"line":n.moveTo(a,i+.5*c-2*o.pix);n.fillRect(a,i+.5*c-2*o.pix,c,4*o.pix);break;case"triangle":n.moveTo(a+7.5*o.pix,i+.5*c-5*o.pix);n.lineTo(a+2.5*o.pix,i+.5*c+5*o.pix);n.lineTo(a+12.5*o.pix,i+.5*c+5*o.pix);n.lineTo(a+7.5*o.pix,i+.5*c-5*o.pix);break;case"diamond":n.moveTo(a+7.5*o.pix,i+.5*c-5*o.pix);n.lineTo(a+2.5*o.pix,i+.5*c);n.lineTo(a+7.5*o.pix,i+.5*c+5*o.pix);n.lineTo(a+12.5*o.pix,i+.5*c);n.lineTo(a+7.5*o.pix,i+.5*c-5*o.pix);break;case"circle":n.moveTo(a+7.5*o.pix,i+.5*c);n.arc(a+7.5*o.pix,i+.5*c,5*o.pix,0,2*Math.PI);break;case"rect":n.moveTo(a,i+.5*c-5*o.pix);n.fillRect(a,i+.5*c-5*o.pix,15*o.pix,10*o.pix);break;case"square":n.moveTo(a+2*o.pix,i+.5*c-5*o.pix);n.fillRect(a+2*o.pix,i+.5*c-5*o.pix,10*o.pix,10*o.pix);break;default:n.moveTo(a,i+.5*c-5*o.pix);n.fillRect(a,i+.5*c-5*o.pix,15*o.pix,10*o.pix)}n.closePath();n.fill()}})}e.forEach(function(t,e){var a=r.x+d+2*h+c+u;if(g){a=r.x-x-d+2*h+c+u}var i=r.y+p*e+(p-s)/2-1+h+s;n.beginPath();n.setFontSize(s);n.setTextBaseline("normal");n.setFillStyle(l.fontColor);n.fillText(t.text,a,i);n.closePath();n.stroke()})}function drawColumnDataPoints(T,b,S,w){let A=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;let t=b.chartData.xAxisData,P=t.xAxisPoints,C=t.eachSpacing;let D=assign({},{type:"group",width:C/2,meterBorder:4,meterFillColor:"#FFFFFF",barBorderCircle:false,barBorderRadius:[],seriesGap:2,linearType:"none",linearOpacity:1,customColor:[],colorStop:0,labelPosition:"outside"},b.extra.column);let M=[];w.save();let L=-2;let F=P.length+2;if(b._scrollDistance_&&b._scrollDistance_!==0&&b.enableScroll===true){w.translate(b._scrollDistance_,0);L=Math.floor(-b._scrollDistance_/C)-2;F=L+b.xAxis.itemCount+4}if(b.tooltip&&b.tooltip.textList&&b.tooltip.textList.length&&A===1){drawToolTipSplitArea(b.tooltip.offset.x,b,S,w,C)}D.customColor=fillCustomColor(D.linearType,D.customColor,T,S);T.forEach(function(a,i){let e,t,o;e=[].concat(b.chartData.yAxisData.ranges[a.index]);t=e.pop();o=e.shift();let x=b.height-b.area[0]-b.area[2];let f=x*(0-t)/(o-t);let n=b.height-Math.round(f)-b.area[2];a.zeroPoints=n;var p=a.data;switch(D.type){case"group":var r=getColumnDataPoints(p,t,o,P,C,b,S,n,A);var u=getStackDataPoints(p,t,o,P,C,b,S,i,T,A);M.push(u);r=fixColumeData(r,C,T.length,i,S,b);for(let t=0;tL&&tn?n:o.y;const d=o.width;const s=Math.abs(n-o.y);if(D.barBorderCircle){D.barBorderRadius=[d/2,d/2,0,0]}if(o.y>n){D.barBorderRadius=[0,0,d/2,d/2]}let[t,e,a,i]=D.barBorderRadius;let r=Math.min(d/2,s/2);t=t>r?r:t;e=e>r?r:e;a=a>r?r:a;i=i>r?r:i;t=t<0?0:t;e=e<0?0:e;a=a<0?0:a;i=i<0?0:i;w.arc(h+t,c+t,t,-Math.PI,-Math.PI/2);w.arc(h+d-e,c+e,e,-Math.PI/2,0);w.arc(h+d-a,c+s-a,a,0,Math.PI/2);w.arc(h+i,c+s-i,i,Math.PI/2,Math.PI)}else{w.moveTo(l,o.y);w.lineTo(l+o.width,o.y);w.lineTo(l+o.width,n);w.lineTo(l,n);w.lineTo(l,o.y);w.setLineWidth(1);w.setStrokeStyle(y)}w.setFillStyle(g);w.closePath();w.fill()}};break;case"stack":var r=getStackDataPoints(p,t,o,P,C,b,S,i,T,A);M.push(r);r=fixColumeStackData(r,C,T.length,i,S,b,T);for(let e=0;eL&&e0){s-=m}w.setFillStyle(g);w.moveTo(l,t.y);w.fillRect(l,t.y,t.width,s);w.closePath();w.fill()}};break;case"meter":var r=getDataPoints(p,t,o,P,C,b,S,A);M.push(r);r=fixColumeMeterData(r,C,T.length,i,S,b,D.meterBorder);for(let t=0;tL&&t0){w.setStrokeStyle(a.color);w.setLineWidth(D.meterBorder*b.pix)}if(i==0){w.setFillStyle(D.meterFillColor)}else{w.setFillStyle(o.color||a.color)}var l=o.x-o.width/2;var s=b.height-o.y-b.area[2];if(D.barBorderRadius&&D.barBorderRadius.length===4||D.barBorderCircle===true){const h=l;const c=o.y;const d=o.width;const s=n-o.y;if(D.barBorderCircle){D.barBorderRadius=[d/2,d/2,0,0]}let[t,e,a,i]=D.barBorderRadius;let r=Math.min(d/2,s/2);t=t>r?r:t;e=e>r?r:e;a=a>r?r:a;i=i>r?r:i;t=t<0?0:t;e=e<0?0:e;a=a<0?0:a;i=i<0?0:i;w.arc(h+t,c+t,t,-Math.PI,-Math.PI/2);w.arc(h+d-e,c+e,e,-Math.PI/2,0);w.arc(h+d-a,c+s-a,a,0,Math.PI/2);w.arc(h+i,c+s-i,i,Math.PI/2,Math.PI);w.fill()}else{w.moveTo(l,o.y);w.lineTo(l+o.width,o.y);w.lineTo(l+o.width,n);w.lineTo(l,n);w.lineTo(l,o.y);w.fill()}if(i==0&&D.meterBorder>0){w.closePath();w.stroke()}}}break}});if(b.dataLabel!==false&&A===1){T.forEach(function(t,e){let a,i,r;a=[].concat(b.chartData.yAxisData.ranges[t.index]);i=a.pop();r=a.shift();var o=t.data;switch(D.type){case"group":var n=getColumnDataPoints(o,i,r,P,C,b,S,A);n=fixColumeData(n,C,T.length,e,S,b);drawColumePointText(n,t,S,w,b);break;case"stack":var n=getStackDataPoints(o,i,r,P,C,b,S,e,T,A);drawColumePointText(n,t,S,w,b);break;case"meter":var n=getDataPoints(o,i,r,P,C,b,S,A);drawColumePointText(n,t,S,w,b);break}})}w.restore();return{xAxisPoints:P,calPoints:M,eachSpacing:C}}function drawMountDataPoints(i,r,o,n){let f=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;let t=r.chartData.xAxisData,p=t.xAxisPoints,l=t.eachSpacing;let s=assign({},{type:"mount",widthRatio:1,borderWidth:1,barBorderCircle:false,barBorderRadius:[],linearType:"none",linearOpacity:1,customColor:[],colorStop:0},r.extra.mount);s.widthRatio=s.widthRatio<=0?0:s.widthRatio;s.widthRatio=s.widthRatio>=2?2:s.widthRatio;let e=[];n.save();let u=-2;let g=p.length+2;if(r._scrollDistance_&&r._scrollDistance_!==0&&r.enableScroll===true){n.translate(r._scrollDistance_,0);u=Math.floor(-r._scrollDistance_/l)-2;g=u+r.xAxis.itemCount+4}s.customColor=fillCustomColor(s.linearType,s.customColor,i,o);let y,v,m;y=[].concat(r.chartData.yAxisData.ranges[0]);v=y.pop();m=y.shift();let T=r.height-r.area[0]-r.area[2];let b=T*(0-v)/(m-v);let h=r.height-Math.round(b)-r.area[2];var c=getMountDataPoints(i,v,m,p,l,r,s,h,f);switch(s.type){case"bar":for(let t=0;tu&&th?h:o.y;const C=o.width;const S=Math.abs(h-o.y);if(s.barBorderCircle){s.barBorderRadius=[C/2,C/2,0,0]}if(o.y>h){s.barBorderRadius=[0,0,C/2,C/2]}let[t,e,a,i]=s.barBorderRadius;let r=Math.min(C/2,S/2);t=t>r?r:t;e=e>r?r:e;a=a>r?r:a;i=i>r?r:i;t=t<0?0:t;e=e<0?0:e;a=a<0?0:a;i=i<0?0:i;n.arc(A+t,P+t,t,-Math.PI,-Math.PI/2);n.arc(A+C-e,P+e,e,-Math.PI/2,0);n.arc(A+C-a,P+S-a,a,0,Math.PI/2);n.arc(A+i,P+S-i,i,Math.PI/2,Math.PI)}else{n.moveTo(d,o.y);n.lineTo(d+o.width,o.y);n.lineTo(d+o.width,h);n.lineTo(d,h);n.lineTo(d,o.y)}n.setStrokeStyle(w);n.setFillStyle(a);if(s.borderWidth>0){n.setLineWidth(s.borderWidth*r.pix);n.closePath();n.stroke()}n.fill()}};break;case"triangle":for(let e=0;eu&&e0){n.setLineWidth(s.borderWidth*r.pix);n.stroke()}n.fill()}};break;case"mount":for(let e=0;eu&&e0){n.setLineWidth(s.borderWidth*r.pix);n.stroke()}n.fill()}};break;case"sharp":for(let e=0;eu&&e0){n.setLineWidth(s.borderWidth*r.pix);n.stroke()}n.fill()}};break}if(r.dataLabel!==false&&f===1){let t,e,a;t=[].concat(r.chartData.yAxisData.ranges[0]);e=t.pop();a=t.shift();var c=getMountDataPoints(i,e,a,p,l,r,s,h,f);drawMountPointText(c,i,o,n,r,h)}n.restore();return{xAxisPoints:p,calPoints:c,eachSpacing:l}}function drawBarDataPoints(y,v,m,T){let b=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;let S=[];let w=(v.height-v.area[0]-v.area[2])/v.categories.length;for(let t=0;tC&&tr?r:t;e=e>r?r:e;a=a>r?r:a;i=i>r?r:i;t=t<0?0:t;e=e<0?0:e;a=a<0?0:a;i=i<0?0:i;T.arc(g+i,c+i,i,-Math.PI,-Math.PI/2);T.arc(o.x-t,c+t,t,-Math.PI/2,0);T.arc(o.x-e,c+h-e,e,0,Math.PI/2);T.arc(g+a,c+h-a,a,Math.PI/2,Math.PI)}else{T.moveTo(n,r);T.lineTo(o.x,r);T.lineTo(o.x,r+o.width);T.lineTo(n,r+o.width);T.lineTo(n,r);T.setLineWidth(1);T.setStrokeStyle(u)}T.setFillStyle(l);T.closePath();T.fill()}};break;case"stack":var i=getBarStackDataPoints(x,e,d,S,w,v,m,t,y,b);P.push(i);i=fixBarStackData(i,w,y.length,t,m,v,y);for(let e=0;eC&&e5&&arguments[5]!==undefined?arguments[5]:1;var s=assign({},{color:{},average:{}},h.extra.candle);s.color=assign({},{upLine:"#f04864",upFill:"#f04864",downLine:"#2fc25b",downFill:"#2fc25b"},s.color);s.average=assign({},{show:false,name:[],day:[],color:c.color},s.average);h.extra.candle=s;let a=h.chartData.xAxisData,x=a.xAxisPoints,f=a.eachSpacing;let y=[];d.save();let p=-2;let v=x.length+2;let u=0;let m=h.width+f;if(h._scrollDistance_&&h._scrollDistance_!==0&&h.enableScroll===true){d.translate(h._scrollDistance_,0);p=Math.floor(-h._scrollDistance_/f)-2;v=p+h.xAxis.itemCount+4;u=-h._scrollDistance_-f*2+h.area[3];m=u+(h.xAxis.itemCount+4)*f}if(s.average.show||t){t.forEach(function(e,t){let a,i,r;a=[].concat(h.chartData.yAxisData.ranges[e.index]);i=a.pop();r=a.shift();var o=e.data;var n=getDataPoints(o,i,r,x,f,h,c,g);var l=splitPoints(n,e);for(let t=0;tu){d.moveTo(t.x,t.y);a=1}if(e>0&&t.x>u&&t.xp&&e0){d.setStrokeStyle(s.color.upLine);d.setFillStyle(s.color.upFill);d.setLineWidth(1*h.pix);d.moveTo(t[3].x,t[3].y);d.lineTo(t[1].x,t[1].y);d.lineTo(t[1].x-f/4,t[1].y);d.lineTo(t[0].x-f/4,t[0].y);d.lineTo(t[0].x,t[0].y);d.lineTo(t[2].x,t[2].y);d.lineTo(t[0].x,t[0].y);d.lineTo(t[0].x+f/4,t[0].y);d.lineTo(t[1].x+f/4,t[1].y);d.lineTo(t[1].x,t[1].y);d.moveTo(t[3].x,t[3].y)}else{d.setStrokeStyle(s.color.downLine);d.setFillStyle(s.color.downFill);d.setLineWidth(1*h.pix);d.moveTo(t[3].x,t[3].y);d.lineTo(t[0].x,t[0].y);d.lineTo(t[0].x-f/4,t[0].y);d.lineTo(t[1].x-f/4,t[1].y);d.lineTo(t[1].x,t[1].y);d.lineTo(t[2].x,t[2].y);d.lineTo(t[1].x,t[1].y);d.lineTo(t[1].x+f/4,t[1].y);d.lineTo(t[0].x+f/4,t[0].y);d.lineTo(t[0].x,t[0].y);d.moveTo(t[3].x,t[3].y)}d.closePath();d.fill();d.stroke()}}});d.restore();return{xAxisPoints:x,calPoints:y,eachSpacing:f}}function drawAreaDataPoints(t,s,h,c){var d=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;var x=assign({},{type:"straight",opacity:.2,addLine:false,width:2,gradient:false,activeType:"none"},s.extra.area);let e=s.chartData.xAxisData,f=e.xAxisPoints,p=e.eachSpacing;let y=s.height-s.area[2];let v=[];c.save();let u=0;let g=s.width+p;if(s._scrollDistance_&&s._scrollDistance_!==0&&s.enableScroll===true){c.translate(s._scrollDistance_,0);u=-s._scrollDistance_-p*2+s.area[3];g=u+(s.xAxis.itemCount+4)*p}t.forEach(function(e,t){let a,i,r;a=[].concat(s.chartData.yAxisData.ranges[e.index]);i=a.pop();r=a.shift();let o=e.data;let n=getDataPoints(o,i,r,f,p,s,h,d);v.push(n);let l=splitPoints(n,e);for(let t=0;t1){let t=r[0];let e=r[r.length-1];c.moveTo(t.x,t.y);let i=0;if(x.type==="curve"){for(let a=0;au){c.moveTo(e.x,e.y);i=1}if(a>0&&e.x>u&&e.xu){c.moveTo(t.x,t.y);i=1}if(e>0&&t.x>u&&t.xu){c.moveTo(t.x,t.y);i=1}if(e>0&&t.x>u&&t.xu){c.moveTo(e.x,e.y);i=1}if(a>0&&e.x>u&&e.xu){c.moveTo(t.x,t.y);i=1}if(e>0&&t.x>u&&t.xu){c.moveTo(t.x,t.y);i=1}if(e>0&&t.x>u&&t.x4&&arguments[4]!==undefined?arguments[4]:1;var i=assign({},{type:"circle"},s.extra.scatter);let e=s.chartData.xAxisData,x=e.xAxisPoints,f=e.eachSpacing;var r=[];c.save();let a=0;let o=s.width+f;if(s._scrollDistance_&&s._scrollDistance_!==0&&s.enableScroll===true){c.translate(s._scrollDistance_,0);a=-s._scrollDistance_-f*2+s.area[3];o=a+(s.xAxis.itemCount+4)*f}t.forEach(function(t,e){let a,i,r;a=[].concat(s.chartData.yAxisData.ranges[t.index]);i=a.pop();r=a.shift();var o=t.data;var n=getDataPoints(o,i,r,x,f,s,h,d);c.beginPath();c.setStrokeStyle(t.color);c.setFillStyle(t.color);c.setLineWidth(1*s.pix);var l=t.pointShape;if(l==="diamond"){n.forEach(function(t,e){if(t!==null){c.moveTo(t.x,t.y-4.5);c.lineTo(t.x-4.5,t.y);c.lineTo(t.x,t.y+4.5);c.lineTo(t.x+4.5,t.y);c.lineTo(t.x,t.y-4.5)}})}else if(l==="circle"){n.forEach(function(t,e){if(t!==null){c.moveTo(t.x+2.5*s.pix,t.y);c.arc(t.x,t.y,3*s.pix,0,2*Math.PI,false)}})}else if(l==="square"){n.forEach(function(t,e){if(t!==null){c.moveTo(t.x-3.5,t.y-3.5);c.rect(t.x-3.5,t.y-3.5,7,7)}})}else if(l==="triangle"){n.forEach(function(t,e){if(t!==null){c.moveTo(t.x,t.y-4.5);c.lineTo(t.x-4.5,t.y+4.5);c.lineTo(t.x+4.5,t.y+4.5);c.lineTo(t.x,t.y-4.5)}})}else if(l==="triangle"){return}c.closePath();c.fill();c.stroke()});if(s.dataLabel!==false&&d===1){t.forEach(function(t,e){let a,i,r;a=[].concat(s.chartData.yAxisData.ranges[t.index]);i=a.pop();r=a.shift();var o=t.data;var n=getDataPoints(o,i,r,x,f,s,h,d);drawPointText(n,t,h,c,s)})}c.restore();return{xAxisPoints:x,calPoints:r,eachSpacing:f}}function drawBubbleDataPoints(a,l,s,h){var c=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;var d=assign({},{opacity:1,border:2},l.extra.bubble);let t=l.chartData.xAxisData,x=t.xAxisPoints,f=t.eachSpacing;var i=[];h.save();let e=0;let r=l.width+f;if(l._scrollDistance_&&l._scrollDistance_!==0&&l.enableScroll===true){h.translate(l._scrollDistance_,0);e=-l._scrollDistance_-f*2+l.area[3];r=e+(l.xAxis.itemCount+4)*f}a.forEach(function(i,t){let e,a,r;e=[].concat(l.chartData.yAxisData.ranges[i.index]);a=e.pop();r=e.shift();var o=i.data;var n=getDataPoints(o,a,r,x,f,l,s,c);h.beginPath();h.setStrokeStyle(i.color);h.setLineWidth(d.border*l.pix);h.setFillStyle(hexToRgb(i.color,d.opacity));n.forEach(function(t,e){h.moveTo(t.x+t.r,t.y);h.arc(t.x,t.y,t.r*l.pix,0,2*Math.PI,false)});h.closePath();h.fill();h.stroke();if(l.dataLabel!==false&&c===1){n.forEach(function(t,e){h.beginPath();var a=i.textSize*l.pix||s.fontSize;h.setFontSize(a);h.setFillStyle(i.textColor||"#FFFFFF");h.setTextAlign("center");h.fillText(String(t.t),t.x,t.y+a/2);h.closePath();h.stroke();h.setTextAlign("left")})}});h.restore();return{xAxisPoints:x,calPoints:i,eachSpacing:f}}function drawLineDataPoints(t,d,x,f){var p=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;var u=assign({},{type:"straight",width:2,activeType:"none",linearType:"none",onShadow:false,animation:"vertical"},d.extra.line);u.width*=d.pix;let e=d.chartData.xAxisData,g=e.xAxisPoints,y=e.eachSpacing;var T=[];f.save();let v=0;let m=d.width+y;if(d._scrollDistance_&&d._scrollDistance_!==0&&d.enableScroll===true){f.translate(d._scrollDistance_,0);v=-d._scrollDistance_-y*2+d.area[3];m=v+(d.xAxis.itemCount+4)*y}t.forEach(function(e,c){f.beginPath();f.setStrokeStyle(e.color);f.moveTo(-1e4,-1e4);f.lineTo(-10001,-10001);f.stroke();let t,a,i;t=[].concat(d.chartData.yAxisData.ranges[e.index]);a=t.pop();i=t.shift();var r=e.data;var o=getLineDataPoints(r,a,i,g,y,d,x,u,p);T.push(o);var n=splitPoints(o,e);if(e.lineType=="dash"){let t=e.dashLength?e.dashLength:8;t*=d.pix;f.setLineDash([t,t])}f.beginPath();var l=e.color;if(u.linearType!=="none"&&e.linearColor&&e.linearColor.length>0){var s=f.createLinearGradient(d.chartData.xAxisData.startX,d.height/2,d.chartData.xAxisData.endX,d.height/2);for(var h=0;h0){f.setShadow(e.setShadow[0],e.setShadow[1],e.setShadow[2],e.setShadow[3])}else{f.setShadow(0,0,0,"rgba(0,0,0,0)")}f.setLineWidth(u.width);n.forEach(function(i,t){if(i.length===1){f.moveTo(i[0].x,i[0].y)}else{f.moveTo(i[0].x,i[0].y);let a=0;if(u.type==="curve"){for(let e=0;ev){f.moveTo(t.x,t.y);a=1}if(e>0&&t.x>v&&t.xv){f.moveTo(t.x,t.y);a=1}if(e>0&&t.x>v&&t.xv){f.moveTo(t.x,t.y);a=1}if(e>0&&t.x>v&&t.x4&&arguments[4]!==undefined?arguments[4]:1;let e=v.chartData.xAxisData,b=e.xAxisPoints,S=e.eachSpacing;let w=assign({},{width:S/2,barBorderCircle:false,barBorderRadius:[],seriesGap:2,linearType:"none",linearOpacity:1,customColor:[],colorStop:0},v.extra.mix.column);let A=assign({},{opacity:.2,gradient:false},v.extra.mix.area);let M=assign({},{width:2},v.extra.mix.line);let L=v.height-v.area[2];let F=[];var _=0;var k=0;t.forEach(function(t,e){if(t.type=="column"){k+=1}});T.save();let R=-2;let I=b.length+2;let P=0;let C=v.width+S;if(v._scrollDistance_&&v._scrollDistance_!==0&&v.enableScroll===true){T.translate(v._scrollDistance_,0);R=Math.floor(-v._scrollDistance_/S)-2;I=R+v.xAxis.itemCount+4;P=-v._scrollDistance_-S*2+v.area[3];C=P+(v.xAxis.itemCount+4)*S}w.customColor=fillCustomColor(w.linearType,w.customColor,t,m);t.forEach(function(n,t){let o,x,f;o=[].concat(v.chartData.yAxisData.ranges[n.index]);x=o.pop();f=o.shift();var p=n.data;var a=getDataPoints(p,x,f,b,S,v,m,D);F.push(a);if(n.type=="column"){a=fixColumeData(a,S,k,_,m,v);for(let t=0;tR&&tr?r:t;e=e>r?r:e;a=a>r?r:a;i=i>r?r:i;t=t<0?0:t;e=e<0?0:e;a=a<0?0:a;i=i<0?0:i;T.arc(h+t,c+t,t,-Math.PI,-Math.PI/2);T.arc(h+d-e,c+e,e,-Math.PI/2,0);T.arc(h+d-a,c+s-a,a,0,Math.PI/2);T.arc(h+i,c+s-i,i,Math.PI/2,Math.PI)}else{T.moveTo(l,o.y);T.lineTo(l+o.width,o.y);T.lineTo(l+o.width,v.height-v.area[2]);T.lineTo(l,v.height-v.area[2]);T.lineTo(l,o.y);T.setLineWidth(1);T.setStrokeStyle(u)}T.setFillStyle(e);T.closePath();T.fill()}}_+=1}if(n.type=="area"){let e=splitPoints(a,n);for(let t=0;t1){var r=i[0];let t=i[i.length-1];T.moveTo(r.x,r.y);let a=0;if(n.style==="curve"){for(let e=0;eP){T.moveTo(t.x,t.y);a=1}if(e>0&&t.x>P&&t.xP){T.moveTo(t.x,t.y);a=1}if(e>0&&t.x>P&&t.xP){T.moveTo(t.x,t.y);a=1}if(e>0&&t.x>P&&t.xP){T.moveTo(t.x,t.y);a=1}if(e>0&&t.x>P&&t.x1){if(h.extra.mount.widthRatio>2)h.extra.mount.widthRatio=2;l+=(h.extra.mount.widthRatio-1)*f}var s=n*n/l;var y=0;if(h._scrollDistance_){y=-h._scrollDistance_*n/l}d.beginPath();d.setLineCap("round");d.setLineWidth(6*h.pix);d.setStrokeStyle(h.xAxis.scrollBackgroundColor||"#EFEBEF");d.moveTo(t,o);d.lineTo(a,o);d.stroke();d.closePath();d.beginPath();d.setLineCap("round");d.setLineWidth(6*h.pix);d.setStrokeStyle(h.xAxis.scrollColor||"#A6A6A6");d.moveTo(t+y,o);d.lineTo(t+y+s,o);d.stroke();d.closePath();d.setLineCap("butt")}d.save();if(h._scrollDistance_&&h._scrollDistance_!==0){d.translate(h._scrollDistance_,0)}if(h.xAxis.calibration===true){d.setStrokeStyle(h.xAxis.gridColor||"#cccccc");d.setLineCap("butt");d.setLineWidth(1*h.pix);x.forEach(function(t,e){if(e>0){d.beginPath();d.moveTo(t-f/2,u);d.lineTo(t-f/2,u+3*h.pix);d.closePath();d.stroke()}})}if(h.xAxis.disableGrid!==true){d.setStrokeStyle(h.xAxis.gridColor||"#cccccc");d.setLineCap("butt");d.setLineWidth(1*h.pix);if(h.xAxis.gridType=="dash"){d.setLineDash([h.xAxis.dashLength*h.pix,h.xAxis.dashLength*h.pix])}h.xAxis.gridEval=h.xAxis.gridEval||1;x.forEach(function(t,e){if(e%h.xAxis.gridEval==0){d.beginPath();d.moveTo(t,u);d.lineTo(t,i);d.stroke()}});d.setLineDash([])}if(h.xAxis.disabled!==true){let t=r.length;if(h.xAxis.labelCount){if(h.xAxis.itemCount){t=Math.ceil(r.length/h.xAxis.itemCount*h.xAxis.labelCount)}else{t=h.xAxis.labelCount}t-=1}let e=Math.ceil(r.length/t);let a=[];let i=r.length;for(let t=0;t=h.area[3]-1&&n-Math.abs(o)<=h.width-h.area[1]+1){d.beginPath();d.setFontSize(g);d.setFillStyle(h.xAxis.fontColor||h.fontColor);d.fillText(String(a),x[e]+i,u+h.xAxis.marginTop*h.pix+(h.xAxis.lineHeight-h.xAxis.fontSize)*h.pix/2+h.xAxis.fontSize*h.pix);d.closePath();d.stroke()}})}else{a.forEach(function(t,e){var a=h.xAxis.formatter?h.xAxis.formatter(t):t;var i=h._scrollDistance_||0;var r=p=="center"?x[e]+f/2:x[e];if(r-Math.abs(i)>=h.area[3]-1&&r-Math.abs(i)<=h.width-h.area[1]+1){d.save();d.beginPath();d.setFontSize(g);d.setFillStyle(h.xAxis.fontColor||h.fontColor);var o=measureText(String(a),g,d);var n=x[e];if(p=="center"){n=x[e]+f/2}var l=0;if(h.xAxis.scrollShow){l=6*h.pix}var s=u+h.xAxis.marginTop*h.pix+g-g*Math.abs(Math.sin(c._xAxisTextAngle_));if(h.xAxis.rotateAngle<0){n-=g/2;o=0}else{n+=g/2;o=-o}d.translate(n,s);d.rotate(-1*c._xAxisTextAngle_);d.fillText(String(a),o,0);d.closePath();d.stroke();d.restore()}})}}d.restore();if(h.xAxis.title){d.beginPath();d.setFontSize(h.xAxis.titleFontSize*h.pix);d.setFillStyle(h.xAxis.titleFontColor);d.fillText(String(h.xAxis.title),h.width-h.area[1]+h.xAxis.titleOffsetX*h.pix,h.height-h.area[2]+h.xAxis.marginTop*h.pix+(h.xAxis.lineHeight-h.xAxis.titleFontSize)*h.pix/2+(h.xAxis.titleFontSize+h.xAxis.titleOffsetY)*h.pix);d.closePath();d.stroke()}if(h.xAxis.axisLine){d.beginPath();d.setStrokeStyle(h.xAxis.axisLineColor);d.setLineWidth(1*h.pix);d.moveTo(t,h.height-h.area[2]);d.lineTo(a,h.height-h.area[2]);d.stroke()}}function drawYAxisGrid(c,e,d,a){if(e.yAxis.disableGrid===true){return}let t=e.height-e.area[0]-e.area[2];let i=t/e.yAxis.splitNumber;let r=e.area[3];let o=e.chartData.xAxisData.xAxisPoints,n=e.chartData.xAxisData.eachSpacing;let l=n*(o.length-1);if(e.type=="mount"&&e.extra&&e.extra.mount&&e.extra.mount.widthRatio&&e.extra.mount.widthRatio>1){if(e.extra.mount.widthRatio>2)e.extra.mount.widthRatio=2;l+=(e.extra.mount.widthRatio-1)*n}let x=r+l;let s=[];let h=1;if(e.xAxis.axisLine===false){h=0}for(let t=h;t4&&arguments[4]!==undefined?arguments[4]:1;var n=assign({},{activeOpacity:.5,activeRadius:10,offsetAngle:0,labelWidth:15,ringWidth:30,customRadius:0,border:false,borderWidth:2,borderColor:"#FFFFFF",centerColor:"#FFFFFF",linearType:"none",customColor:[]},r.type=="pie"?r.extra.pie:r.extra.ring);var l={x:r.area[3]+(r.width-r.area[1]-r.area[3])/2,y:r.area[0]+(r.height-r.area[0]-r.area[2])/2};if(e.pieChartLinePadding==0){e.pieChartLinePadding=n.activeRadius*r.pix}var i=Math.min((r.width-r.area[1]-r.area[3])/2-e.pieChartLinePadding-e.pieChartTextPadding-e._pieTextMaxLength_,(r.height-r.area[0]-r.area[2])/2-e.pieChartLinePadding-e.pieChartTextPadding);i=i<10?10:i;if(n.customRadius>0){i=n.customRadius*r.pix}t=getPieDataPoints(t,i,a);var h=n.activeRadius*r.pix;n.customColor=fillCustomColor(n.linearType,n.customColor,t,e);t=t.map(function(t){t._start_+=n.offsetAngle*Math.PI/180;return t});t.forEach(function(t,e){if(r.tooltip){if(r.tooltip.index==e){o.beginPath();o.setFillStyle(hexToRgb(t.color,n.activeOpacity||.5));o.moveTo(l.x,l.y);o.arc(l.x,l.y,t._radius_+h,t._start_,t._start_+2*t._proportion_*Math.PI);o.closePath();o.fill()}}o.beginPath();o.setLineWidth(n.borderWidth*r.pix);o.lineJoin="round";o.setStrokeStyle(n.borderColor);var a=t.color;if(n.linearType=="custom"){var i;if(o.createCircularGradient){i=o.createCircularGradient(l.x,l.y,t._radius_)}else{i=o.createRadialGradient(l.x,l.y,0,l.x,l.y,t._radius_)}i.addColorStop(0,hexToRgb(n.customColor[t.linearIndex],1));i.addColorStop(1,hexToRgb(t.color,1));a=i}o.setFillStyle(a);o.moveTo(l.x,l.y);o.arc(l.x,l.y,t._radius_,t._start_,t._start_+2*t._proportion_*Math.PI);o.closePath();o.fill();if(n.border==true){o.stroke()}});if(r.type==="ring"){var s=i*.6;if(typeof n.ringWidth==="number"&&n.ringWidth>0){s=Math.max(0,i-n.ringWidth*r.pix)}o.beginPath();o.setFillStyle(n.centerColor);o.moveTo(l.x,l.y);o.arc(l.x,l.y,s,0,2*Math.PI);o.closePath();o.fill()}if(r.dataLabel!==false&&a===1){drawPieText(t,r,e,o,i,l)}if(a===1&&r.type==="ring"){drawRingTitle(r,e,o,l)}return{center:l,radius:i,series:t}}function drawRoseDataPoints(t,r,e,o){var a=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;var n=assign({},{type:"area",activeOpacity:.5,activeRadius:10,offsetAngle:0,labelWidth:15,border:false,borderWidth:2,borderColor:"#FFFFFF",linearType:"none",customColor:[]},r.extra.rose);if(e.pieChartLinePadding==0){e.pieChartLinePadding=n.activeRadius*r.pix}var l={x:r.area[3]+(r.width-r.area[1]-r.area[3])/2,y:r.area[0]+(r.height-r.area[0]-r.area[2])/2};var i=Math.min((r.width-r.area[1]-r.area[3])/2-e.pieChartLinePadding-e.pieChartTextPadding-e._pieTextMaxLength_,(r.height-r.area[0]-r.area[2])/2-e.pieChartLinePadding-e.pieChartTextPadding);i=i<10?10:i;var s=n.minRadius||i*.5;if(i4&&arguments[4]!==undefined?arguments[4]:1;var o=assign({},{startAngle:.75,endAngle:.25,type:"default",direction:"cw",lineCap:"round",width:12,gap:2,linearType:"none",customColor:[]},i.extra.arcbar);a=getArcbarDataPoints(a,o,e);var n;if(o.centerX||o.centerY){n={x:o.centerX?o.centerX:i.width/2,y:o.centerY?o.centerY:i.height/2}}else{n={x:i.width/2,y:i.height/2}}var l;if(o.radius){l=o.radius}else{l=Math.min(n.x,n.y);l-=5*i.pix;l-=o.width/2}l=l<10?10:l;o.customColor=fillCustomColor(o.linearType,o.customColor,a,t);for(let e=0;e5&&arguments[5]!==undefined?arguments[5]:1;var f=assign({},{type:"default",startAngle:.75,endAngle:.25,width:15,labelOffset:13,splitLine:{fixRadius:0,splitNumber:10,width:15,color:"#FFFFFF",childNumber:5,childWidth:5},pointer:{width:15,color:"auto"}},c.extra.gauge);if(f.oldAngle==undefined){f.oldAngle=f.startAngle}if(f.oldData==undefined){f.oldData=0}n=getGaugeAxisPoints(n,f.startAngle,f.endAngle);var p={x:c.width/2,y:c.height/2};var u=Math.min(p.x,p.y);u-=5*c.pix;u-=f.width/2;u=u<10?10:u;var g=u-f.width;var y=0;if(f.type=="progress"){var v=u-f.width*3;d.beginPath();let t=d.createLinearGradient(p.x,p.y-v,p.x,p.y+v);t.addColorStop("0",hexToRgb(h[0].color,.3));t.addColorStop("1.0",hexToRgb("#FFFFFF",.1));d.setFillStyle(t);d.arc(p.x,p.y,v,0,2*Math.PI,false);d.fill();d.setLineWidth(f.width);d.setStrokeStyle(hexToRgb(h[0].color,.3));d.setLineCap("round");d.beginPath();d.arc(p.x,p.y,g,f.startAngle*Math.PI,f.endAngle*Math.PI,false);d.stroke();if(f.endAnglet/o){d.setStrokeStyle(hexToRgb(h[0].color,1))}else{d.setStrokeStyle(hexToRgb(h[0].color,.3))}d.setLineWidth(3*c.pix);d.moveTo(i,0);d.lineTo(r,0);d.stroke();d.rotate(a*Math.PI)}d.restore();h=getGaugeArcbarDataPoints(h,f,x);d.setLineWidth(f.width);d.setStrokeStyle(h[0].color);d.setLineCap("round");d.beginPath();d.arc(p.x,p.y,g,f.startAngle*Math.PI,h[0]._proportion_*Math.PI,false);d.stroke();let l=u-f.width*2.5;d.save();d.translate(p.x,p.y);d.rotate((h[0]._proportion_-1)*Math.PI);d.beginPath();d.setLineWidth(f.width/3);let s=d.createLinearGradient(0,-l*.6,0,l*.6);s.addColorStop("0",hexToRgb("#FFFFFF",0));s.addColorStop("0.5",hexToRgb(h[0].color,1));s.addColorStop("1.0",hexToRgb("#FFFFFF",0));d.setStrokeStyle(s);d.arc(0,0,l,.85*Math.PI,1.15*Math.PI,false);d.stroke();d.beginPath();d.setLineWidth(1);d.setStrokeStyle(h[0].color);d.setFillStyle(h[0].color);d.moveTo(-l-f.width/3/2,-4);d.lineTo(-l-f.width/3/2-4,0);d.lineTo(-l-f.width/3/2,4);d.lineTo(-l-f.width/3/2,-4);d.stroke();d.fill();d.restore()}else{d.setLineWidth(f.width);d.setLineCap("butt");for(let e=0;e4&&arguments[4]!==undefined?arguments[4]:1;var s=assign({},{gridColor:"#cccccc",gridType:"radar",gridEval:1,axisLabel:false,axisLabelTofix:0,labelShow:true,labelColor:"#666666",labelPointShow:false,labelPointRadius:3,labelPointColor:"#cccccc",opacity:.2,gridCount:3,border:false,borderWidth:2,linearType:"none",customColor:[]},n.extra.radar);var a=getRadarCoordinateSeries(n.categories.length);var h={x:n.area[3]+(n.width-n.area[1]-n.area[3])/2,y:n.area[0]+(n.height-n.area[0]-n.area[2])/2};var r=(n.width-n.area[1]-n.area[3])/2;var d=(n.height-n.area[0]-n.area[2])/2;var c=Math.min(r-(getMaxTextListLength(n.categories,i.fontSize,l)+i.radarLabelTextMargin),d-i.radarLabelTextMargin);c-=i.radarLabelTextMargin*n.pix;c=c<10?10:c;c=s.radius?s.radius:c;l.beginPath();l.setLineWidth(1*n.pix);l.setStrokeStyle(s.gridColor);a.forEach(function(t,e){var a=convertCoordinateOrigin(c*Math.cos(t),c*Math.sin(t),h);l.moveTo(h.x,h.y);if(e%s.gridEval==0){l.lineTo(a.x,a.y)}});l.stroke();l.closePath();var x=function t(i){var r={};l.beginPath();l.setLineWidth(1*n.pix);l.setStrokeStyle(s.gridColor);if(s.gridType=="radar"){a.forEach(function(t,e){var a=convertCoordinateOrigin(c/s.gridCount*i*Math.cos(t),c/s.gridCount*i*Math.sin(t),h);if(e===0){r=a;l.moveTo(a.x,a.y)}else{l.lineTo(a.x,a.y)}});l.lineTo(r.x,r.y)}else{var e=convertCoordinateOrigin(c/s.gridCount*i*Math.cos(1.5),c/s.gridCount*i*Math.sin(1.5),h);l.arc(h.x,h.y,h.y-e.y,0,2*Math.PI,false)}l.stroke();l.closePath()};for(var e=1;e<=s.gridCount;e++){x(e)}s.customColor=fillCustomColor(s.linearType,s.customColor,o,i);var f=getRadarDataPoints(a,h,c,o,n,t);f.forEach(function(t,e){l.beginPath();l.setLineWidth(s.borderWidth*n.pix);l.setStrokeStyle(t.color);var a=hexToRgb(t.color,s.opacity);if(s.linearType=="custom"){var i;if(l.createCircularGradient){i=l.createCircularGradient(h.x,h.y,c)}else{i=l.createRadialGradient(h.x,h.y,0,h.x,h.y,c)}i.addColorStop(0,hexToRgb(s.customColor[o[e].linearIndex],s.opacity));i.addColorStop(1,hexToRgb(t.color,s.opacity));a=i}l.setFillStyle(a);t.data.forEach(function(t,e){if(e===0){l.moveTo(t.position.x,t.position.y)}else{l.lineTo(t.position.x,t.position.y)}});l.closePath();l.fill();if(s.border===true){l.stroke()}l.closePath();if(n.dataPointShape!==false){var r=t.data.map(function(t){return t.position});drawPointShape(r,t.color,t.pointShape,l,n)}});if(s.axisLabel===true){const p=Math.max(s.max,Math.max.apply(null,dataCombine(o)));const u=c/s.gridCount;const g=n.fontSize*n.pix;l.setFontSize(g);l.setFillStyle(n.fontColor);l.setTextAlign("left");for(var e=0;eh.x?e.xMax:h.x;e.yMin=e.yMinh.y?e.yMax:h.y}}}return e}function coordinateToPoint(t,e,a,i,r,o){return{x:(e-a.xMin)*i+r,y:(a.yMax-t)*i+o}}function pointToCoordinate(t,e,a,i,r,o){return{x:(e-r)/i+a.xMin,y:a.yMax-(t-o)/i}}function isRayIntersectsSegment(t,e,a){if(e[1]==a[1]){return false}if(e[1]>t[1]&&a[1]>t[1]){return false}if(e[1]t[1]){return false}if(a[1]==t[1]&&e[1]>t[1]){return false}if(e[0]a[t].area[2]||e[1]>a[t].area[3]||e[2]i||e[3]>r){o=true;break}else{o=false}}else{o=true;break}}}return o}function getWordCloudPoint(c,t,d){let x=c.series;switch(t){case"normal":for(let l=0;l.7){return true}else{return false}};for(let h=0;h4&&arguments[4]!==undefined?arguments[4]:1;let a=assign({},{type:"normal",autoColors:true},r.extra.word);if(!r.chartData.wordCloudData){r.chartData.wordCloudData=getWordCloudPoint(r,a.type,o)}o.beginPath();o.setFillStyle(r.background);o.rect(0,0,r.width,r.height);o.fill();o.save();let l=r.chartData.wordCloudData;o.translate(r.width/2,r.height/2);for(let i=0;i0){if(r.tooltip){if(r.tooltip.index==i){o.strokeText(t,(l[i].areav[0]+5-r.width/2)*n-a*(1-n)/2,(l[i].areav[1]+5+e-r.height/2)*n)}else{o.fillText(t,(l[i].areav[0]+5-r.width/2)*n-a*(1-n)/2,(l[i].areav[1]+5+e-r.height/2)*n)}}else{o.fillText(t,(l[i].areav[0]+5-r.width/2)*n-a*(1-n)/2,(l[i].areav[1]+5+e-r.height/2)*n)}}}else{if(l[i].area[0]>0){if(r.tooltip){if(r.tooltip.index==i){o.strokeText(t,(l[i].area[0]+5-r.width/2)*n-a*(1-n)/2,(l[i].area[1]+5+e-r.height/2)*n)}else{o.fillText(t,(l[i].area[0]+5-r.width/2)*n-a*(1-n)/2,(l[i].area[1]+5+e-r.height/2)*n)}}else{o.fillText(t,(l[i].area[0]+5-r.width/2)*n-a*(1-n)/2,(l[i].area[1]+5+e-r.height/2)*n)}}}o.stroke();o.restore()}o.restore()}function drawFunnelDataPoints(t,e,c,a){let d=arguments.length>4&&arguments[4]!==undefined?arguments[4]:1;let i=assign({},{type:"funnel",activeWidth:10,activeOpacity:.3,border:false,borderWidth:2,borderColor:"#FFFFFF",fillOpacity:1,minSize:0,labelAlign:"right",linearType:"none",customColor:[]},e.extra.funnel);let r=(e.height-e.area[0]-e.area[2])/t.length;let o={x:e.area[3]+(e.width-e.area[1]-e.area[3])/2,y:e.height-e.area[2]};let n=i.activeWidth*e.pix;let x=Math.min((e.width-e.area[1]-e.area[3])/2-n,(e.height-e.area[0]-e.area[2])/2-n);let l=getFunnelDataPoints(t,x,i,r,d);a.save();a.translate(o.x,o.y);i.customColor=fillCustomColor(i.linearType,i.customColor,t,c);if(i.type=="pyramid"){for(let t=0;t0){l.area[3]+=i[t].width+l.yAxis.padding*l.pix}else{l.area[3]+=i[t].width}a+=1}else if(i[t].position=="right"){if(e>0){l.area[1]+=i[t].width+l.yAxis.padding*l.pix}else{l.area[1]+=i[t].width}e+=1}}}else{n.yAxisWidth=i}l.chartData.yAxisData=f;if(l.categories&&l.categories.length&&l.type!=="radar"&&l.type!=="gauge"&&l.type!=="bar"){l.chartData.xAxisData=getXAxisPoints(l.categories,l,n);let t=calCategoriesData(l.categories,l,n,l.chartData.xAxisData.eachSpacing,s),e=t.xAxisHeight,a=t.angle;n.xAxisHeight=e;n._xAxisTextAngle_=a;l.area[2]+=e;l.chartData.categoriesData=t}else{if(l.type==="line"||l.type==="area"||l.type==="scatter"||l.type==="bubble"||l.type==="bar"){l.chartData.xAxisData=calXAxisData(c,l,n,s);d=l.chartData.xAxisData.rangesFormat;let t=calCategoriesData(d,l,n,l.chartData.xAxisData.eachSpacing,s),e=t.xAxisHeight,a=t.angle;n.xAxisHeight=e;n._xAxisTextAngle_=a;l.area[2]+=e;l.chartData.categoriesData=t}else{l.chartData.xAxisData={xAxisPoints:[]}}}if(l.enableScroll&&l.xAxis.scrollAlign=="right"&&l._scrollDistance_===undefined){let t=0,e=l.chartData.xAxisData.xAxisPoints,a=l.chartData.xAxisData.startX,i=l.chartData.xAxisData.endX,r=l.chartData.xAxisData.eachSpacing;let o=r*(e.length-1);let n=i-a;t=n-o;h.scrollOption.currentOffset=t;h.scrollOption.startTouchX=t;h.scrollOption.distance=0;h.scrollOption.lastMoveTime=0;l._scrollDistance_=t}if(t==="pie"||t==="ring"||t==="rose"){n._pieTextMaxLength_=l.dataLabel===false?0:getPieTextMaxLength(x,n,s,l)}switch(t){case"word":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function(t){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawWordCloudDataPoints(c,l,n,s,t);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"map":s.clearRect(0,0,l.width,l.height);drawMapDataPoints(c,l,n,s);setTimeout(()=>{this.uevent.trigger("renderComplete")},50);break;case"funnel":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function(t){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}l.chartData.funnelData=drawFunnelDataPoints(c,l,n,s,t);drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,t);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"line":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawYAxisGrid(d,l,n,s);drawXAxis(d,l,n,s);var a=drawLineDataPoints(c,l,n,s,e),i=a.xAxisPoints,r=a.calPoints,o=a.eachSpacing;l.chartData.xAxisPoints=i;l.chartData.calPoints=r;l.chartData.eachSpacing=o;drawYAxis(c,l,n,s);if(l.enableMarkLine!==false&&e===1){drawMarkLine(l,n,s)}drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e,o,i);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"scatter":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawYAxisGrid(d,l,n,s);drawXAxis(d,l,n,s);var a=drawScatterDataPoints(c,l,n,s,e),i=a.xAxisPoints,r=a.calPoints,o=a.eachSpacing;l.chartData.xAxisPoints=i;l.chartData.calPoints=r;l.chartData.eachSpacing=o;drawYAxis(c,l,n,s);if(l.enableMarkLine!==false&&e===1){drawMarkLine(l,n,s)}drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e,o,i);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"bubble":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawYAxisGrid(d,l,n,s);drawXAxis(d,l,n,s);var a=drawBubbleDataPoints(c,l,n,s,e),i=a.xAxisPoints,r=a.calPoints,o=a.eachSpacing;l.chartData.xAxisPoints=i;l.chartData.calPoints=r;l.chartData.eachSpacing=o;drawYAxis(c,l,n,s);if(l.enableMarkLine!==false&&e===1){drawMarkLine(l,n,s)}drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e,o,i);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"mix":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawYAxisGrid(d,l,n,s);drawXAxis(d,l,n,s);var a=drawMixDataPoints(c,l,n,s,e),i=a.xAxisPoints,r=a.calPoints,o=a.eachSpacing;l.chartData.xAxisPoints=i;l.chartData.calPoints=r;l.chartData.eachSpacing=o;drawYAxis(c,l,n,s);if(l.enableMarkLine!==false&&e===1){drawMarkLine(l,n,s)}drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e,o,i);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"column":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawYAxisGrid(d,l,n,s);drawXAxis(d,l,n,s);var a=drawColumnDataPoints(c,l,n,s,e),i=a.xAxisPoints,r=a.calPoints,o=a.eachSpacing;l.chartData.xAxisPoints=i;l.chartData.calPoints=r;l.chartData.eachSpacing=o;drawYAxis(c,l,n,s);if(l.enableMarkLine!==false&&e===1){drawMarkLine(l,n,s)}drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e,o,i);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"mount":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawYAxisGrid(d,l,n,s);drawXAxis(d,l,n,s);var a=drawMountDataPoints(c,l,n,s,e),i=a.xAxisPoints,r=a.calPoints,o=a.eachSpacing;l.chartData.xAxisPoints=i;l.chartData.calPoints=r;l.chartData.eachSpacing=o;drawYAxis(c,l,n,s);if(l.enableMarkLine!==false&&e===1){drawMarkLine(l,n,s)}drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e,o,i);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"bar":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawXAxis(d,l,n,s);var a=drawBarDataPoints(c,l,n,s,e),i=a.yAxisPoints,r=a.calPoints,o=a.eachSpacing;l.chartData.yAxisPoints=i;l.chartData.xAxisPoints=l.chartData.xAxisData.xAxisPoints;l.chartData.calPoints=r;l.chartData.eachSpacing=o;drawYAxis(c,l,n,s);if(l.enableMarkLine!==false&&e===1){drawMarkLine(l,n,s)}drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e,o,i);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"area":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawYAxisGrid(d,l,n,s);drawXAxis(d,l,n,s);var a=drawAreaDataPoints(c,l,n,s,e),i=a.xAxisPoints,r=a.calPoints,o=a.eachSpacing;l.chartData.xAxisPoints=i;l.chartData.calPoints=r;l.chartData.eachSpacing=o;drawYAxis(c,l,n,s);if(l.enableMarkLine!==false&&e===1){drawMarkLine(l,n,s)}drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e,o,i);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"ring":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}l.chartData.pieData=drawPieDataPoints(c,l,n,s,e);drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"pie":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}l.chartData.pieData=drawPieDataPoints(c,l,n,s,e);drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"rose":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}l.chartData.pieData=drawRoseDataPoints(c,l,n,s,e);drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"radar":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}l.chartData.radarData=drawRadarDataPoints(c,l,n,s,e);drawLegend(l.series,l,n,s,l.chartData);drawToolTipBridge(l,n,s,e);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"arcbar":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}l.chartData.arcbarData=drawArcbarDataPoints(c,l,n,s,e);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"gauge":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}l.chartData.gaugeData=drawGaugeDataPoints(d,c,l,n,s,e);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break;case"candle":this.animationInstance=new Animation({timing:l.timing,duration:e,onProcess:function t(e){s.clearRect(0,0,l.width,l.height);if(l.rotate){contextRotate(s,l)}drawYAxisGrid(d,l,n,s);drawXAxis(d,l,n,s);var a=drawCandleDataPoints(c,x,l,n,s,e),i=a.xAxisPoints,r=a.calPoints,o=a.eachSpacing;l.chartData.xAxisPoints=i;l.chartData.calPoints=r;l.chartData.eachSpacing=o;drawYAxis(c,l,n,s);if(l.enableMarkLine!==false&&e===1){drawMarkLine(l,n,s)}if(x){drawLegend(x,l,n,s,l.chartData)}else{drawLegend(l.series,l,n,s,l.chartData)}drawToolTipBridge(l,n,s,e,o,i);drawCanvas(l,s)},onAnimationFinish:function t(){h.uevent.trigger("renderComplete")}});break}}function uChartsEvent(){this.events={}}uChartsEvent.prototype.addEventListener=function(t,e){this.events[t]=this.events[t]||[];this.events[t].push(e)};uChartsEvent.prototype.delEventListener=function(t){this.events[t]=[]};uChartsEvent.prototype.trigger=function(){for(var t=arguments.length,e=Array(t),a=0;a0&&arguments[0]!==undefined?arguments[0]:{};this.opts=assign({},this.opts,t);this.opts.updateData=true;let c=t.scrollPosition||"current";switch(c){case"current":this.opts._scrollDistance_=this.scrollOption.currentOffset;break;case"left":this.opts._scrollDistance_=0;this.scrollOption={currentOffset:0,startTouchX:0,distance:0,lastMoveTime:0};break;case"right":let t=calYAxisData(this.opts.series,this.opts,this.config,this.context),e=t.yAxisWidth;this.config.yAxisWidth=e;let a=0;let i=getXAxisPoints(this.opts.categories,this.opts,this.config),r=i.xAxisPoints,o=i.startX,n=i.endX,l=i.eachSpacing;let s=l*(r.length-1);let h=n-o;a=h-s;this.scrollOption={currentOffset:a,startTouchX:a,distance:0,lastMoveTime:0};this.opts._scrollDistance_=a;break}drawCharts.call(this,this.opts.type,this.opts,this.config,this.context)};uCharts.prototype.zoom=function(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:this.opts.xAxis.itemCount;if(this.opts.enableScroll!==true){console.log("[uCharts] 请启用滚动条后使用");return}let e=Math.round(Math.abs(this.scrollOption.currentOffset)/this.opts.chartData.eachSpacing)+Math.round(this.opts.xAxis.itemCount/2);this.opts.animation=false;this.opts.xAxis.itemCount=t.itemCount;let a=calYAxisData(this.opts.series,this.opts,this.config,this.context),i=a.yAxisWidth;this.config.yAxisWidth=i;let r=0;let o=getXAxisPoints(this.opts.categories,this.opts,this.config),h=o.xAxisPoints,c=o.startX,d=o.endX,n=o.eachSpacing;let x=n*e;let l=d-c;let s=l-n*(h.length-1);r=l/2-x;if(r>0){r=0}if(r=this.opts.categories.length?this.opts.categories.length:r;this.opts.animation=false;this.opts.xAxis.itemCount=r;let o=0;let n=getXAxisPoints(this.opts.categories,this.opts,this.config),x=n.xAxisPoints,f=n.startX,p=n.endX,l=n.eachSpacing;let u=l*this.scrollOption.moveCurrent1;let g=p-f;let y=g-l*(x.length-1);o=-u+Math.min(i[0].x,i[1].x)-this.opts.area[3]-l;if(o>0){o=0}if(o1&&arguments[1]!==undefined?arguments[1]:{};var a=null;if(t.changedTouches){a=t.changedTouches[0]}else{a=t.mp.changedTouches[0]}if(a){var i=getTouches(a,this.opts,t);var r=this.getLegendDataIndex(t);if(r>=0){if(this.opts.type=="candle"){this.opts.seriesMA[r].show=!this.opts.seriesMA[r].show}else{this.opts.series[r].show=!this.opts.series[r].show}this.opts.animation=e.animation?true:false;this.opts._scrollDistance_=this.scrollOption.currentOffset;drawCharts.call(this,this.opts.type,this.opts,this.config,this.context)}}};uCharts.prototype.showToolTip=function(t){var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var c=null;if(t.changedTouches){c=t.changedTouches[0]}else{c=t.mp.changedTouches[0]}if(!c){console.log("[uCharts] 未获取到event坐标信息")}var a=getTouches(c,this.opts,t);var d=this.scrollOption.currentOffset;var i=assign({},this.opts,{_scrollDistance_:d,animation:false});if(this.opts.type==="line"||this.opts.type==="area"||this.opts.type==="column"||this.opts.type==="scatter"||this.opts.type==="bubble"){var r=this.getCurrentDataIndex(t);var o=e.index==undefined?r.index:e.index;if(o>-1||o.length>0){var n=getSeriesDataItem(this.opts.series,o,r.group);if(n.length!==0){var l=getToolTipData(n,this.opts,o,r.group,this.opts.categories,e),s=l.textList,h=l.offset;h.y=a.y;i.tooltip={textList:e.textList!==undefined?e.textList:s,offset:e.offset!==undefined?e.offset:h,option:e,index:o,group:r.group}}}drawCharts.call(this,i.type,i,this.config,this.context)}if(this.opts.type==="mount"){var o=e.index==undefined?this.getCurrentDataIndex(t).index:e.index;if(o>-1){var i=assign({},this.opts,{animation:false});var n=assign({},i._series_[o]);var s=[{text:e.formatter?e.formatter(n,undefined,o,i):n.name+": "+n.data,color:n.color,legendShape:this.opts.extra.tooltip.legendShape=="auto"?n.legendShape:this.opts.extra.tooltip.legendShape}];var h={x:i.chartData.calPoints[o].x,y:a.y};i.tooltip={textList:e.textList?e.textList:s,offset:e.offset!==undefined?e.offset:h,option:e,index:o}}drawCharts.call(this,i.type,i,this.config,this.context)}if(this.opts.type==="bar"){var r=this.getCurrentDataIndex(t);var o=e.index==undefined?r.index:e.index;if(o>-1||o.length>0){var n=getSeriesDataItem(this.opts.series,o,r.group);if(n.length!==0){var l=getToolTipData(n,this.opts,o,r.group,this.opts.categories,e),s=l.textList,h=l.offset;h.x=a.x;i.tooltip={textList:e.textList!==undefined?e.textList:s,offset:e.offset!==undefined?e.offset:h,option:e,index:o}}}drawCharts.call(this,i.type,i,this.config,this.context)}if(this.opts.type==="mix"){var r=this.getCurrentDataIndex(t);var o=e.index==undefined?r.index:e.index;if(o>-1){var d=this.scrollOption.currentOffset;var i=assign({},this.opts,{_scrollDistance_:d,animation:false});var n=getSeriesDataItem(this.opts.series,o);if(n.length!==0){var x=getMixToolTipData(n,this.opts,o,this.opts.categories,e),s=x.textList,h=x.offset;h.y=a.y;i.tooltip={textList:e.textList?e.textList:s,offset:e.offset!==undefined?e.offset:h,option:e,index:o}}}drawCharts.call(this,i.type,i,this.config,this.context)}if(this.opts.type==="candle"){var r=this.getCurrentDataIndex(t);var o=e.index==undefined?r.index:e.index;if(o>-1){var d=this.scrollOption.currentOffset;var i=assign({},this.opts,{_scrollDistance_:d,animation:false});var n=getSeriesDataItem(this.opts.series,o);if(n.length!==0){var l=getCandleToolTipData(this.opts.series[0].data,n,this.opts,o,this.opts.categories,this.opts.extra.candle,e),s=l.textList,h=l.offset;h.y=a.y;i.tooltip={textList:e.textList?e.textList:s,offset:e.offset!==undefined?e.offset:h,option:e,index:o}}}drawCharts.call(this,i.type,i,this.config,this.context)}if(this.opts.type==="pie"||this.opts.type==="ring"||this.opts.type==="rose"||this.opts.type==="funnel"){var o=e.index==undefined?this.getCurrentDataIndex(t):e.index;if(o>-1){var i=assign({},this.opts,{animation:false});var n=assign({},i._series_[o]);var s=[{text:e.formatter?e.formatter(n,undefined,o,i):n.name+": "+n.data,color:n.color,legendShape:this.opts.extra.tooltip.legendShape=="auto"?n.legendShape:this.opts.extra.tooltip.legendShape}];var h={x:a.x,y:a.y};i.tooltip={textList:e.textList?e.textList:s,offset:e.offset!==undefined?e.offset:h,option:e,index:o}}drawCharts.call(this,i.type,i,this.config,this.context)}if(this.opts.type==="map"){var o=e.index==undefined?this.getCurrentDataIndex(t):e.index;if(o>-1){var i=assign({},this.opts,{animation:false});var n=assign({},this.opts.series[o]);n.name=n.properties.name;var s=[{text:e.formatter?e.formatter(n,undefined,o,this.opts):n.name,color:n.color,legendShape:this.opts.extra.tooltip.legendShape=="auto"?n.legendShape:this.opts.extra.tooltip.legendShape}];var h={x:a.x,y:a.y};i.tooltip={textList:e.textList?e.textList:s,offset:e.offset!==undefined?e.offset:h,option:e,index:o}}i.updateData=false;drawCharts.call(this,i.type,i,this.config,this.context)}if(this.opts.type==="word"){var o=e.index==undefined?this.getCurrentDataIndex(t):e.index;if(o>-1){var i=assign({},this.opts,{animation:false});var n=assign({},this.opts.series[o]);var s=[{text:e.formatter?e.formatter(n,undefined,o,this.opts):n.name,color:n.color,legendShape:this.opts.extra.tooltip.legendShape=="auto"?n.legendShape:this.opts.extra.tooltip.legendShape}];var h={x:a.x,y:a.y};i.tooltip={textList:e.textList?e.textList:s,offset:e.offset!==undefined?e.offset:h,option:e,index:o}}i.updateData=false;drawCharts.call(this,i.type,i,this.config,this.context)}if(this.opts.type==="radar"){var o=e.index==undefined?this.getCurrentDataIndex(t):e.index;if(o>-1){var i=assign({},this.opts,{animation:false});var n=getSeriesDataItem(this.opts.series,o);if(n.length!==0){var s=n.map(t=>{return{text:e.formatter?e.formatter(t,this.opts.categories[o],o,this.opts):t.name+": "+t.data,color:t.color,legendShape:this.opts.extra.tooltip.legendShape=="auto"?t.legendShape:this.opts.extra.tooltip.legendShape}});var h={x:a.x,y:a.y};i.tooltip={textList:e.textList?e.textList:s,offset:e.offset!==undefined?e.offset:h,option:e,index:o}}}drawCharts.call(this,i.type,i,this.config,this.context)}};uCharts.prototype.translate=function(t){this.scrollOption={currentOffset:t,startTouchX:t,distance:0,lastMoveTime:0};let e=assign({},this.opts,{_scrollDistance_:t,animation:false});drawCharts.call(this,this.opts.type,e,this.config,this.context)};uCharts.prototype.scrollStart=function(t){var e=null;if(t.changedTouches){e=t.changedTouches[0]}else{e=t.mp.changedTouches[0]}var a=getTouches(e,this.opts,t);if(e&&this.opts.enableScroll===true){this.scrollOption.startTouchX=a.x}};uCharts.prototype.scroll=function(t){if(this.scrollOption.lastMoveTime===0){this.scrollOption.lastMoveTime=Date.now()}let e=this.opts.touchMoveLimit||60;let a=Date.now();let i=a-this.scrollOption.lastMoveTime;if(i void | Promise; +} + +/** + * 列表页「更多操作」菜单(wd-action-sheet)统一逻辑 + * + * 页面只需声明菜单项(含权限判断),选中分发与空菜单提示由这里处理: + * + * const { actionSheetVisible, actionSheetActions, showActions, handleActionSelect, confirmAction } = + * useActionSheet(); + */ +export function useActionSheet() { + const toast = useToast(); + const { confirm } = useDialog(); + + const actionSheetVisible = ref(false); + const actionSheetActions = ref<{ name: string; color?: string }[]>([]); + let handlers: Record void> = {}; + + /** 展示操作菜单,无可用项时提示「暂无操作权限」 */ + function showActions(menus: ActionMenuOption[]) { + if (menus.length === 0) { + toast.warning("暂无操作权限"); + return; + } + actionSheetActions.value = menus.map(({ name, color }) => ({ name, color })); + handlers = Object.fromEntries(menus.map((menu) => [menu.name, menu.handler])); + actionSheetVisible.value = true; + } + + function handleActionSelect({ item }: { item: { name: string } }) { + handlers[item.name]?.(); + } + + /** + * 标准危险操作确认流程:确认弹窗 → 执行 → 成功提示,用户取消静默 + * + * @param options.msg 确认弹窗提示文案 + * @param options.action 确认后执行的操作 + * @param options.title 确认弹窗标题,默认「确认删除」 + * @param options.successText 成功提示文案,默认「删除成功」 + */ + async function confirmAction(options: { + msg: string; + action: () => Promise; + title?: string; + successText?: string; + }) { + const { msg, action, title = "确认删除", successText = "删除成功" } = options; + try { + await confirm({ title, msg, headerImage: "warning" }); + await action(); + toast.success(successText); + } catch { + // 用户取消操作 + } + } + + return { actionSheetVisible, actionSheetActions, showActions, handleActionSelect, confirmAction }; +} diff --git a/src/composables/useLoading.ts b/src/composables/useLoading.ts deleted file mode 100644 index 10670f9..0000000 --- a/src/composables/useLoading.ts +++ /dev/null @@ -1,141 +0,0 @@ -import { type Ref, type ComputedRef } from "vue"; - -/** - * 加载状态管理 - * - * 提供全局或局部的加载状态管理,支持多个加载任务的并发控制。 - * - * @example - * ```ts - * // 基本使用 - * const loading = useLoading() - * loading.start() - * await fetchData() - * loading.stop() - * - * // 带消息 - * loading.start('正在加载数据...') - * - * // 异步包装 - * const result = await loading.wrap(fetchData()) - * - * // 独立实例 - * const localLoading = useLoading({ singleton: false }) - * ``` - */ - -export interface UseLoadingOptions { - /** 是否使用全局单例,默认 true */ - singleton?: boolean; - /** 初始加载状态,默认 false */ - initial?: boolean; - /** 加载提示消息 */ - message?: string; -} - -export interface UseLoadingReturn { - /** 是否处于加载状态 */ - isLoading: ComputedRef; - /** 加载计数(支持并发) */ - loadingCount: Ref; - /** 当前加载消息 */ - message: Ref; - /** 开始加载 */ - start: (msg?: string) => void; - /** 结束加载 */ - stop: () => void; - /** 包装异步函数,自动管理加载状态 */ - wrap: (promise: Promise) => Promise; - /** 设置加载消息 */ - setMessage: (msg: string) => void; -} - -/** - * 创建加载状态实例 - */ -function createLoadingState(options: UseLoadingOptions = {}) { - const { message: initialMessage = "" } = options; - - const loadingCount = ref(0); - const message = ref(initialMessage); - - const isLoading = computed(() => loadingCount.value > 0); - - /** - * 开始加载 - * @param msg 加载提示消息 - */ - const start = (msg?: string): void => { - loadingCount.value++; - if (msg) { - message.value = msg; - } - }; - - /** - * 结束加载 - */ - const stop = (): void => { - if (loadingCount.value > 0) { - loadingCount.value--; - } - if (loadingCount.value === 0) { - message.value = ""; - } - }; - - /** - * 包装异步函数,自动管理加载状态 - * @param promise 异步 Promise - */ - const wrap = async (promise: Promise): Promise => { - try { - start(); - return await promise; - } finally { - stop(); - } - }; - - /** - * 设置加载消息 - * @param msg 消息内容 - */ - const setMessage = (msg: string): void => { - message.value = msg; - }; - - return { - isLoading, - loadingCount, - message, - start, - stop, - wrap, - setMessage, - }; -} - -/** 全局单例实例 */ -let loadingInstance: UseLoadingReturn | null = null; - -/** - * 加载状态管理 Hook - * - * 默认使用全局单例模式,确保整个应用共享同一加载状态。 - * 如需独立状态(如组件内部的局部加载),可传入 `{ singleton: false }`。 - * - * @param options 配置选项 - */ -export function useLoading(options?: UseLoadingOptions): UseLoadingReturn { - const { singleton = true } = options ?? {}; - - if (singleton) { - if (!loadingInstance) { - loadingInstance = createLoadingState(options); - } - return loadingInstance; - } - - return createLoadingState(options); -} diff --git a/src/composables/useNavbar.ts b/src/composables/useNavbar.ts index 5199394..5248a09 100644 --- a/src/composables/useNavbar.ts +++ b/src/composables/useNavbar.ts @@ -154,6 +154,18 @@ export function useNavbar(options: UseNavbarOptions = {}): UseNavbarReturn { }; const setMenuButtonRectWithRetry = (maxRetry = 6, delayMs = 50) => { + // 兜底:合理的默认胶囊按钮尺寸,避免导航栏高度为 0 + const applyDefaultMenuButton = () => { + menuButton.value = { + width: 87, + height: 32, + top: statusBarHeight.value + 6, + right: windowWidth.value - 10, + bottom: statusBarHeight.value + 38, + left: windowWidth.value - 97, + }; + }; + try { const rect = uni.getMenuButtonBoundingClientRect(); @@ -174,28 +186,10 @@ export function useNavbar(options: UseNavbarOptions = {}): UseNavbarReturn { setMenuButtonRectWithRetry(maxRetry - 1, delayMs); }, delayMs); } else { - console.warn("getMenuButtonBoundingClientRect 返回值无效,使用默认值"); - // 兜底:设置合理的默认胶囊按钮尺寸,避免导航栏高度为 0 - menuButton.value = { - width: 87, - height: 32, - top: statusBarHeight.value + 6, - right: windowWidth.value - 10, - bottom: statusBarHeight.value + 38, - left: windowWidth.value - 97, - }; + applyDefaultMenuButton(); } - } catch (e) { - console.warn("获取胶囊按钮位置失败,使用默认值", e); - // 兜底:设置合理的默认胶囊按钮尺寸 - menuButton.value = { - width: 87, - height: 32, - top: statusBarHeight.value + 6, - right: windowWidth.value - 10, - bottom: statusBarHeight.value + 38, - left: windowWidth.value - 97, - }; + } catch { + applyDefaultMenuButton(); } }; // #endif @@ -214,8 +208,8 @@ export function useNavbar(options: UseNavbarOptions = {}): UseNavbarReturn { // 微信小程序:获取胶囊按钮位置 setMenuButtonRectWithRetry(); // #endif - } catch (e) { - console.warn("获取系统信息失败", e); + } catch { + // 各字段已有声明处默认值兜底 } }; diff --git a/src/composables/useNavigation.ts b/src/composables/useNavigation.ts index 568beb4..a2f6046 100644 --- a/src/composables/useNavigation.ts +++ b/src/composables/useNavigation.ts @@ -5,9 +5,10 @@ interface NavItem { } export function useNavigation() { + const toast = useToast(); const handleNavClick = (item: NavItem) => { if (!item.url) { - uni.showToast({ title: "功能开发中", icon: "none" }); + toast.info("功能开发中"); return; } @@ -28,7 +29,7 @@ export function useNavigation() { uni.navigateTo({ url: item.url, fail: () => { - uni.showToast({ title: "页面不存在", icon: "none" }); + toast.info("页面不存在"); }, }); }; diff --git a/src/composables/usePagedList.ts b/src/composables/usePagedList.ts new file mode 100644 index 0000000..7afecd5 --- /dev/null +++ b/src/composables/usePagedList.ts @@ -0,0 +1,68 @@ +import { ref, type Ref } from "vue"; +import { onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app"; + +/** + * 分页列表统一逻辑:触底加载 + 下拉刷新 + * + * fetcher 返回一页数据;pageNum 的推进与回退全部由这里维护,页面只消费 + * pageData / total / loadMoreState 三个状态。 + * + * const { pageData, total, loadMoreState, reload } = usePagedList(UserAPI.getPage, queryParams); + */ +export function usePagedList( + fetcher: (query: Q) => Promise<{ list: T[]; total: number }>, + queryParams: Q +) { + const total = ref(0); + const pageData = ref([]) as Ref; + const loadMoreState = ref<"loading" | "finished" | "error">("loading"); + + /** 拉取当前 pageNum 指向的一页(成功后 pageNum 前进);append 为触底追加,否则整体替换 */ + function fetchPage(append: boolean) { + loadMoreState.value = "loading"; + fetcher(queryParams) + .then((data) => { + pageData.value = append ? [...pageData.value, ...data.list] : data.list; + total.value = data.total; + queryParams.pageNum++; + loadMoreState.value = "finished"; + }) + .catch(() => { + if (!append) pageData.value = []; + loadMoreState.value = "error"; + }); + } + + /** 回到第一页重新拉取(搜索/筛选/增删改后调用) */ + function reload() { + queryParams.pageNum = 1; + fetchPage(false); + } + + // 触底加载下一页 + onReachBottom(() => { + if (loadMoreState.value === "loading") return; + if (queryParams.pageNum * queryParams.pageSize < total.value) { + fetchPage(true); + } else { + loadMoreState.value = "finished"; + } + }); + + // 下拉刷新:回到第一页(失败时保留现有数据,展示重试态) + onPullDownRefresh(async () => { + try { + const data = await fetcher({ ...queryParams, pageNum: 1 }); + pageData.value = data.list; + total.value = data.total; + queryParams.pageNum = 2; + loadMoreState.value = "finished"; + } catch { + loadMoreState.value = "error"; + } finally { + uni.stopPullDownRefresh(); + } + }); + + return { pageData, total, loadMoreState, reload }; +} diff --git a/src/composables/useRequest.ts b/src/composables/useRequest.ts deleted file mode 100644 index d14caf4..0000000 --- a/src/composables/useRequest.ts +++ /dev/null @@ -1,302 +0,0 @@ -import { ref, computed, shallowRef, type Ref, type ComputedRef } from "vue"; - -/** - * 请求状态管理 - * - * 封装异步请求的加载状态、错误处理和数据缓存,提供统一的请求管理方式。 - * - * @example - * ```ts - * const { data, loading, error, execute } = useRequest( - * () => UserAPI.getUserInfo() - * ) - * - * // 立即执行 - * const { data } = useRequest(() => UserAPI.getUserInfo(), { immediate: true }) - * - * // 手动执行 - * await execute() - * - * // 刷新数据 - * await refresh() - * ``` - */ - -export interface UseRequestOptions { - /** 是否立即执行,默认 false */ - immediate?: boolean; - /** 初始数据 */ - initialData?: T | null; - /** 请求前的回调 */ - onBefore?: () => void; - /** 请求成功的回调 */ - onSuccess?: (data: T) => void; - /** 请求失败的回调 */ - onError?: (error: Error) => void; - /** 请求完成的回调(无论成功失败) */ - onFinally?: () => void; - /** 是否重置数据在重新请求时,默认 false */ - resetOnExecute?: boolean; -} - -export interface UseRequestReturn { - /** 响应数据 */ - data: Ref; - /** 是否正在加载 */ - loading: ComputedRef; - /** 错误信息 */ - error: Ref; - /** 是否已请求过(用于区分初始状态和请求后状态) */ - hasExecuted: Ref; - /** 执行请求 */ - execute: () => Promise; - /** 刷新数据(重新执行请求) */ - refresh: () => Promise; - /** 重置状态 */ - reset: () => void; -} - -/** - * 请求状态管理 Hook - * - * @param requestFn 请求函数 - * @param options 配置选项 - */ -export function useRequest( - requestFn: () => Promise, - options: UseRequestOptions = {} -): UseRequestReturn { - const { - immediate = false, - initialData = null, - onBefore, - onSuccess, - onError, - onFinally, - resetOnExecute = false, - } = options; - - // 使用 shallowRef 避免深层响应式,提升性能 - const data = shallowRef(initialData) as Ref; - const error = ref(null); - const loadingCount = ref(0); - const hasExecuted = ref(false); - - const loading = computed(() => loadingCount.value > 0); - - /** - * 执行请求 - */ - const execute = async (): Promise => { - // 重置状态 - if (resetOnExecute) { - data.value = initialData; - error.value = null; - } - - loadingCount.value++; - hasExecuted.value = true; - - try { - onBefore?.(); - const result = await requestFn(); - data.value = result; - error.value = null; - onSuccess?.(result); - return result; - } catch (e) { - const err = e instanceof Error ? e : new Error(String(e)); - error.value = err; - onError?.(err); - return null; - } finally { - loadingCount.value--; - onFinally?.(); - } - }; - - /** - * 刷新数据 - */ - const refresh = async (): Promise => { - return execute(); - }; - - /** - * 重置状态 - */ - const reset = (): void => { - data.value = initialData; - error.value = null; - loadingCount.value = 0; - hasExecuted.value = false; - }; - - // 立即执行 - if (immediate) { - execute(); - } - - return { - data, - loading, - error, - hasExecuted, - execute, - refresh, - reset, - }; -} - -/** - * 分页请求状态管理 - * - * @example - * ```ts - * const { list, loading, loadMore, refresh, hasMore } = usePagination( - * (params) => UserAPI.getUserPage({ ...params, status: 1 }), - * { pageSize: 20 } - * ) - * - * // 加载更多 - * await loadMore() - * - * // 刷新 - * await refresh() - * ``` - */ - -export interface PaginationParams { - pageNum: number; - pageSize: number; -} - -export interface UsePaginationOptions { - /** 每页条数,默认 10 */ - pageSize?: number; - /** 初始数据 */ - initialData?: T[]; - /** 请求成功的回调 */ - onSuccess?: (list: T[], total: number) => void; - /** 请求失败的回调 */ - onError?: (error: Error) => void; -} - -export interface UsePaginationReturn { - /** 数据列表 */ - list: Ref; - /** 是否正在加载 */ - loading: ComputedRef; - /** 错误信息 */ - error: Ref; - /** 是否还有更多数据 */ - hasMore: ComputedRef; - /** 当前页码 */ - pageNum: Ref; - /** 总条数 */ - total: Ref; - /** 是否为空 */ - isEmpty: ComputedRef; - /** 加载更多 */ - loadMore: () => Promise; - /** 刷新(从第一页开始) */ - refresh: () => Promise; - /** 重置 */ - reset: () => void; -} - -/** - * 分页请求 Hook - * - * @param requestFn 分页请求函数 - * @param options 配置选项 - */ -export function usePagination( - requestFn: (params: PaginationParams) => Promise>, - options: UsePaginationOptions = {} -): UsePaginationReturn { - const { pageSize = 10, initialData = [], onSuccess, onError } = options; - - const list = ref(initialData) as Ref; - const loadingCount = ref(0); - const error = ref(null); - const pageNum = ref(1); - const total = ref(0); - - const loading = computed(() => loadingCount.value > 0); - const hasMore = computed(() => list.value.length < total.value); - const isEmpty = computed(() => list.value.length === 0 && !loading.value); - - /** - * 加载更多 - */ - const loadMore = async (): Promise => { - // 如果正在加载或没有更多数据,直接返回 - if (loading.value || !hasMore.value) { - return list.value; - } - - loadingCount.value++; - - try { - const result = await requestFn({ - pageNum: pageNum.value, - pageSize, - }); - - // 如果是第一页,替换数据;否则追加数据 - if (pageNum.value === 1) { - list.value = result.list; - } else { - list.value = [...list.value, ...result.list]; - } - - total.value = result.total; - pageNum.value++; - onSuccess?.(result.list, result.total); - - return result.list; - } catch (e) { - const err = e instanceof Error ? e : new Error(String(e)); - error.value = err; - onError?.(err); - return []; - } finally { - loadingCount.value--; - } - }; - - /** - * 刷新(从第一页开始) - */ - const refresh = async (): Promise => { - pageNum.value = 1; - total.value = 0; - list.value = []; - return loadMore(); - }; - - /** - * 重置 - */ - const reset = (): void => { - list.value = initialData; - loadingCount.value = 0; - error.value = null; - pageNum.value = 1; - total.value = 0; - }; - - return { - list, - loading, - error, - hasMore, - pageNum, - total, - isEmpty, - loadMore, - refresh, - reset, - }; -} diff --git a/src/composables/useScanLogin.ts b/src/composables/useScanLogin.ts index f3d9b84..0e22fd7 100644 --- a/src/composables/useScanLogin.ts +++ b/src/composables/useScanLogin.ts @@ -7,17 +7,18 @@ import { checkLogin } from "@/utils/auth"; * 未登录时跳转登录页,用户取消扫码静默处理。 */ export function useScanLogin() { + const toast = useToast(); const scanLogin = async () => { if (!checkLogin()) return; try { const res = await uni.scanCode({ scanType: ["qrCode"] }); const ticket = (res.result || "").trim(); if (!ticket) { - uni.showToast({ title: "无效的二维码", icon: "none" }); + toast.info("无效的二维码"); return; } uni.navigateTo({ - url: `/pages/mine/scan-confirm/index?ticket=${encodeURIComponent(ticket)}`, + url: `/subPages/mine/scan-confirm/index?ticket=${encodeURIComponent(ticket)}`, }); } catch { // 用户取消扫码,静默处理 diff --git a/src/composables/useSmsCode.ts b/src/composables/useSmsCode.ts new file mode 100644 index 0000000..7e32396 --- /dev/null +++ b/src/composables/useSmsCode.ts @@ -0,0 +1,44 @@ +import { useToast } from "@wot-ui/ui"; +import { useCountdown } from "@/composables/useCountdown"; +import { getErrorMessage } from "@/utils"; +import AuthAPI from "@/api/auth"; + +/** 手机号格式校验 */ +export function isValidMobile(mobile: string): boolean { + return /^1\d{10}$/.test((mobile || "").trim()); +} + +/** + * 短信验证码发送(含 60s 倒计时) + * + * @param options.sentDelay 发送成功后延时毫秒数,默认 0 + * @returns countdown 剩余秒数、send 发送函数、reset 重置倒计时 + */ +export function useSmsCode() { + const toast = useToast(); + const { countdown, start, stop } = useCountdown(60); + + /** 发送验证码,失败提示由这里统一处理 */ + async function send(mobile: string, fallback = "发送失败"): Promise { + if (countdown.value > 0) return false; + if (!isValidMobile(mobile)) { + toast.error("请输入正确的手机号"); + return false; + } + try { + await AuthAPI.sendSmsLoginCode(mobile.trim()); + toast.success("验证码已发送"); + start(); + return true; + } catch (error) { + toast.error(getErrorMessage(error, fallback)); + return false; + } + } + + function reset() { + stop(); + } + + return { countdown, send, reset }; +} diff --git a/src/composables/useSse.ts b/src/composables/useSse.ts deleted file mode 100644 index 899eaf2..0000000 --- a/src/composables/useSse.ts +++ /dev/null @@ -1,216 +0,0 @@ -import { getAccessToken } from "@/utils/auth"; - -export interface UseSseOptions { - url?: string; - debug?: boolean; - connectionTimeout?: number; - reconnectInterval?: number; - maxReconnectInterval?: number; - maxReconnectAttempts?: number; -} - -type EventHandler = (data: unknown) => void; - -export enum SseConnectionState { - DISCONNECTED = "DISCONNECTED", - CONNECTING = "CONNECTING", - CONNECTED = "CONNECTED", -} - -let globalInstance: ReturnType | null = null; - -function createSseConnection(options: UseSseOptions = {}) { - const baseUrl = import.meta.env.VITE_APP_BASE_API; - const defaultUrl = `${baseUrl}/api/v1/sse/connect`; - - const config = { - url: options.url ?? defaultUrl, - debug: options.debug ?? false, - connectionTimeout: options.connectionTimeout ?? 10000, - reconnectInterval: options.reconnectInterval ?? 5000, - maxReconnectInterval: options.maxReconnectInterval ?? 120000, - maxReconnectAttempts: options.maxReconnectAttempts ?? 10, - }; - - const connectionState = ref(SseConnectionState.DISCONNECTED); - const isConnected = computed(() => connectionState.value === SseConnectionState.CONNECTED); - - let eventSource: EventSource | null = null; - let connectionTimeoutTimer: ReturnType | null = null; - let isManualDisconnect = false; - let reconnectTimer: ReturnType | null = null; - let reconnectAttempts = 0; - let currentReconnectInterval = config.reconnectInterval; - - const eventHandlers = new Map>(); - - const log = (...args: unknown[]) => config.debug && console.log("[SSE]", ...args); - const logError = (...args: unknown[]) => console.error("[SSE]", ...args); - - const clearTimer = (timer: typeof connectionTimeoutTimer) => { - if (timer) { - clearTimeout(timer); - return null; - } - return timer; - }; - - const scheduleReconnect = () => { - if (isManualDisconnect) return; - if (config.maxReconnectAttempts > 0 && reconnectAttempts >= config.maxReconnectAttempts) { - log(`已达到最大重试次数 ${config.maxReconnectAttempts},停止重连`); - return; - } - - reconnectAttempts++; - log(`将在 ${currentReconnectInterval}ms 后重试(${reconnectAttempts})`); - - reconnectTimer = setTimeout(() => { - connect(); - currentReconnectInterval = Math.min( - currentReconnectInterval * 2, - config.maxReconnectInterval - ); - }, currentReconnectInterval); - }; - - const connect = () => { - isManualDisconnect = false; - - if (connectionState.value !== SseConnectionState.DISCONNECTED) { - log("SSE 已连接或正在连接中,跳过重复连接"); - return; - } - - const token = getAccessToken(); - if (!token) { - log("未检测到有效令牌,跳过 SSE 连接"); - return; - } - - connectionState.value = SseConnectionState.CONNECTING; - - connectionTimeoutTimer = setTimeout(() => { - if (connectionState.value === SseConnectionState.CONNECTING) { - log("SSE 连接超时"); - disconnect(); - } - }, config.connectionTimeout); - - log("正在建立 SSE 连接..."); - - // SSE 连接地址附带 token 参数(EventSource 不支持自定义 Header) - const separator = config.url.includes("?") ? "&" : "?"; - const fullUrl = `${config.url}${separator}accessToken=${encodeURIComponent(token)}`; - - eventSource = new EventSource(fullUrl); - - eventSource.onopen = () => { - connectionTimeoutTimer = clearTimer(connectionTimeoutTimer); - connectionState.value = SseConnectionState.CONNECTED; - reconnectAttempts = 0; - currentReconnectInterval = config.reconnectInterval; - log("SSE 连接已建立"); - }; - - eventSource.onerror = () => { - logError("SSE 连接错误"); - connectionState.value = SseConnectionState.DISCONNECTED; - cleanupEventSource(); - scheduleReconnect(); - }; - - // 监听所有命名事件 - for (const [eventName] of eventHandlers) { - bindEvent(eventName); - } - - // 默认监听 message 事件 - bindEvent("message"); - }; - - const bindEvent = (eventName: string) => { - if (!eventSource) return; - eventSource.addEventListener(eventName, (event: MessageEvent) => { - const handlers = eventHandlers.get(eventName); - if (handlers) { - try { - const data = JSON.parse(event.data); - handlers.forEach((h) => h(data)); - } catch { - handlers.forEach((h) => h(event.data)); - } - } - log(`收到事件[${eventName}]:`, event.data); - }); - }; - - const on = (eventName: string, handler: EventHandler): (() => void) => { - if (!eventHandlers.has(eventName)) { - eventHandlers.set(eventName, new Set()); - // 如果已连接,动态绑定新事件 - if (eventSource) { - bindEvent(eventName); - } - } - const handlers = eventHandlers.get(eventName); - if (!handlers) return () => {}; - handlers.add(handler); - log(`已订阅事件: ${eventName}`); - - return () => { - const handlers = eventHandlers.get(eventName); - if (handlers) { - handlers.delete(handler); - if (handlers.size === 0) { - eventHandlers.delete(eventName); - } - } - }; - }; - - const cleanupEventSource = () => { - if (eventSource) { - eventSource.close(); - eventSource = null; - } - }; - - const disconnect = () => { - isManualDisconnect = true; - connectionTimeoutTimer = clearTimer(connectionTimeoutTimer); - reconnectTimer = clearTimer(reconnectTimer); - cleanupEventSource(); - connectionState.value = SseConnectionState.DISCONNECTED; - log("SSE 连接已断开"); - }; - - const cleanup = () => { - disconnect(); - eventHandlers.clear(); - log("SSE 资源已清理"); - }; - - return { - connectionState: readonly(connectionState), - isConnected, - connect, - disconnect, - cleanup, - on, - }; -} - -export function useSse(options: UseSseOptions = {}) { - if (!globalInstance) { - globalInstance = createSseConnection(options); - } - return globalInstance; -} - -export function cleanupSse() { - if (globalInstance) { - globalInstance.cleanup(); - globalInstance = null; - } -} diff --git a/src/composables/useTabbar.ts b/src/composables/useTabbar.ts deleted file mode 100644 index 09bf600..0000000 --- a/src/composables/useTabbar.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { ref, computed } from "vue"; - -/** - * TabBar 状态管理 - * - * 提供底部导航栏的状态管理功能,包括激活状态切换、徽标数字设置等。 - * - * @example - * ```ts - * const { tabbarList, setTabbarItemActive, setTabbarItem } = useTabbar() - * - * // 切换到工作台 - * setTabbarItemActive('work') - * - * // 设置徽标数字 - * setTabbarItem('work', 5) - * ``` - */ - -export interface TabbarItem { - /** 唯一标识 */ - name: string; - /** 徽标数字,null 表示不显示 */ - value: number | null; - /** 是否激活 */ - active: boolean; - /** 显示标题 */ - title: string; - /** 图标名称 */ - icon: string; -} - -/** 默认 TabBar 配置 */ -const DEFAULT_TABBAR_ITEMS: Omit[] = [ - { name: "home", value: null, title: "首页", icon: "home" }, - { name: "work", value: null, title: "工作台", icon: "apps" }, - { name: "mine", value: null, title: "我的", icon: "user" }, -]; - -/** - * 创建 TabBar 状态实例 - * - * 使用工厂函数创建独立的状态实例,避免模块级别的状态污染。 - * 每个调用者都可以获得独立的状态管理。 - */ -function createTabbarState() { - const items = ref( - DEFAULT_TABBAR_ITEMS.map((item, index) => ({ - ...item, - active: index === 0, - })) - ); - - /** TabBar 列表 */ - const tabbarList = computed(() => items.value); - - /** 当前激活的 TabBar 项 */ - const activeTabbar = computed(() => { - return items.value.find((item) => item.active) || items.value[0]; - }); - - /** - * 获取指定 TabBar 项的徽标数字 - * @param name TabBar 项名称 - */ - const getTabbarItemValue = (name: string): number | null => { - const item = items.value.find((item) => item.name === name); - return item?.value ?? null; - }; - - /** - * 设置 TabBar 项的徽标数字 - * @param name TabBar 项名称 - * @param value 徽标数字 - */ - const setTabbarItem = (name: string, value: number): void => { - const item = items.value.find((item) => item.name === name); - if (item) { - item.value = value; - } - }; - - /** - * 设置激活的 TabBar 项 - * @param name TabBar 项名称 - */ - const setTabbarItemActive = (name: string): void => { - items.value.forEach((item) => { - item.active = item.name === name; - }); - }; - - /** - * 重置 TabBar 状态 - */ - const resetTabbar = (): void => { - items.value = DEFAULT_TABBAR_ITEMS.map((item, index) => ({ - ...item, - active: index === 0, - })); - }; - - return { - tabbarList, - activeTabbar, - getTabbarItemValue, - setTabbarItem, - setTabbarItemActive, - resetTabbar, - }; -} - -/** 全局单例实例 */ -let tabbarInstance: ReturnType | null = null; - -/** - * TabBar 状态管理 Hook - * - * 默认使用全局单例模式,确保整个应用共享同一状态。 - * 如需独立状态,可传入 `{ singleton: false }` 创建新实例。 - * - * @param options 配置选项 - * @param options.singleton 是否使用单例模式,默认 true - */ -export function useTabbar(options?: { singleton?: boolean }) { - const { singleton = true } = options ?? {}; - - if (singleton) { - if (!tabbarInstance) { - tabbarInstance = createTabbarState(); - } - return tabbarInstance; - } - - return createTabbarState(); -} diff --git a/src/composables/useTheme.ts b/src/composables/useTheme.ts index 1ce775b..abbd7eb 100644 --- a/src/composables/useTheme.ts +++ b/src/composables/useTheme.ts @@ -1,6 +1,9 @@ -import type { ThemeColorOption, ThemeMode } from "@/composables/types/theme"; -import { themeColorOptions } from "@/composables/types/theme"; -import { useThemeStore } from "@/store"; +import { + useThemeStore, + themeColorOptions, + type ThemeColorOption, + type ThemeMode, +} from "@/store/modules/theme"; export function useTheme() { const store = useThemeStore(); @@ -28,9 +31,8 @@ export function useTheme() { store.initTheme(); } - // 注意:全局主题管理已在App.vue中处理 - // 包括:系统主题监听、导航栏颜色同步等 - // 组件中一般不需要再调用initTheme(),除非有特殊需求 + // 全局主题初始化已在 App.vue onLaunch 中完成(导航栏颜色同步), + // 组件中一般无需再调用 initTheme() return { theme: computed(() => store.theme), @@ -46,6 +48,4 @@ export function useTheme() { }; } -// 导出类型和常量供外部使用 export type { ThemeColorOption, ThemeMode }; -export { themeColorOptions }; diff --git a/src/config/menu.ts b/src/config/menu.ts index 1907924..70637ac 100644 --- a/src/config/menu.ts +++ b/src/config/menu.ts @@ -21,49 +21,49 @@ export const menuConfig: WorkMenuGroup[] = [ { icon: "/static/icons/user.svg", title: "用户管理", - url: "/pages/work/user/index", + url: "/subPages/work/user/index", perm: "sys:user:list", }, { icon: "/static/icons/role.svg", title: "角色管理", - url: "/pages/work/role/index", + url: "/subPages/work/role/index", perm: "sys:role:list", }, { icon: "/static/icons/company.svg", title: "部门管理", - url: "/pages/work/dept/index", + url: "/subPages/work/dept/index", perm: "sys:dept:list", }, { icon: "/static/icons/settings.svg", title: "系统配置", - url: "/pages/work/config/index", + url: "/subPages/work/config/index", perm: "sys:config:list", }, { icon: "/static/icons/file.svg", title: "字典管理", - url: "/pages/work/dict/index", + url: "/subPages/work/dict/index", perm: "sys:dict:list", }, { icon: "/static/icons/tree.svg", title: "菜单管理", - url: "/pages/work/menu/index", + url: "/subPages/work/menu/index", perm: "sys:menu:list", }, { icon: "/static/icons/bell.svg", title: "通知公告", - url: "/pages/work/notice/index", + url: "/subPages/work/notice/index", perm: "sys:notice:list", }, { icon: "/static/icons/log.svg", title: "系统日志", - url: "/pages/work/log/index", + url: "/subPages/work/log/index", perm: "sys:log:list", }, ], diff --git a/src/enums/api-code-enum.ts b/src/enums/api-code-enum.ts index 4fb0d9f..04e699d 100644 --- a/src/enums/api-code-enum.ts +++ b/src/enums/api-code-enum.ts @@ -1,49 +1,16 @@ -/** - * API响应码枚举 +/** + * API 响应码枚举 + * + * 与后端 ResultCode 对齐(youlai-boot common/result/ResultCode.java), + * 仅收录前端实际消费的响应码 */ export const enum ApiCode { - /** - * 成功 - */ + /** 成功 */ SUCCESS = "00000", - /** - * 通用错误 - */ - ERROR = "B0001", + /** 访问令牌无效或已过期 */ + ACCESS_TOKEN_INVALID = "A0230", - /** - * 令牌无效或过期 - */ - TOKEN_INVALID = "A0230", - - /** - * 令牌已过期 - */ - TOKEN_EXPIRED = "A0231", - - /** - * 未授权访问 - */ - UNAUTHORIZED = "A0232", - - /** - * 禁止访问 - */ - FORBIDDEN = "A0233", - - /** - * 参数校验失败 - */ - PARAM_INVALID = "A0400", - - /** - * 资源不存在 - */ - NOT_FOUND = "A0404", - - /** - * 服务器内部错误 - */ - INTERNAL_ERROR = "B0500", + /** 刷新令牌无效或已过期 */ + REFRESH_TOKEN_INVALID = "A0231", } diff --git a/src/layouts/blank.vue b/src/layouts/blank.vue new file mode 100644 index 0000000..7a8b9ba --- /dev/null +++ b/src/layouts/blank.vue @@ -0,0 +1,16 @@ + + + diff --git a/src/layouts/default.vue b/src/layouts/default.vue index 4f3f275..eea2e18 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -1,11 +1,3 @@ - - diff --git a/src/layouts/tabbar.vue b/src/layouts/tabbar.vue index 42d9329..e59253a 100644 --- a/src/layouts/tabbar.vue +++ b/src/layouts/tabbar.vue @@ -1,11 +1,6 @@ + + + diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index b033b53..8a2ded1 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -1,27 +1,21 @@ diff --git a/src/pages/mine/components/community-card.vue b/src/pages/mine/components/community-card.vue new file mode 100644 index 0000000..64aae8f --- /dev/null +++ b/src/pages/mine/components/community-card.vue @@ -0,0 +1,127 @@ + + + + + diff --git a/src/pages/mine/components/menu-section.vue b/src/pages/mine/components/menu-section.vue new file mode 100644 index 0000000..01d552a --- /dev/null +++ b/src/pages/mine/components/menu-section.vue @@ -0,0 +1,139 @@ + + + + + diff --git a/src/pages/mine/components/profile-card.vue b/src/pages/mine/components/profile-card.vue new file mode 100644 index 0000000..ffc7e93 --- /dev/null +++ b/src/pages/mine/components/profile-card.vue @@ -0,0 +1,205 @@ + + + + + diff --git a/src/pages/mine/components/quick-cards.vue b/src/pages/mine/components/quick-cards.vue new file mode 100644 index 0000000..44a1375 --- /dev/null +++ b/src/pages/mine/components/quick-cards.vue @@ -0,0 +1,100 @@ + + + + + diff --git a/src/pages/mine/index.vue b/src/pages/mine/index.vue index 1eaeba5..ee8873b 100644 --- a/src/pages/mine/index.vue +++ b/src/pages/mine/index.vue @@ -1,7 +1,6 @@ @@ -205,8 +60,11 @@ import { useUserStore, useThemeStore } from "@/store"; import { useRouter } from "uni-mini-router"; import { useNavbar } from "@/composables/useNavbar"; import { useScanLogin } from "@/composables/useScanLogin"; -import { getAccessToken } from "@/utils/auth"; import { formatBytes } from "@/utils/format"; +import ProfileCard from "./components/profile-card.vue"; +import CommunityCard from "./components/community-card.vue"; +import QuickCards from "./components/quick-cards.vue"; +import MenuSection, { type MenuItem } from "./components/menu-section.vue"; definePage({ name: "mine", @@ -216,33 +74,135 @@ definePage({ const userStore = useUserStore(); const themeStore = useThemeStore(); -const currentThemeColor = computed(() => themeStore.themeVars.colorTheme); +const router = useRouter(); +const navbar = useNavbar({ hasTabbar: true }); +const { scanLogin } = useScanLogin(); +const toast = useToast(); + +const isLogin = computed(() => !!userStore.userInfo); const userInfo = computed(() => userStore.userInfo); const defaultAvatar = "/static/images/default-avatar.png"; -const isLogin = computed(() => !!getAccessToken()); +const avatar = computed(() => + isLogin.value && userInfo.value?.avatar ? userInfo.value.avatar : defaultAvatar +); +const displayName = computed(() => + isLogin.value ? userInfo.value?.nickname || "匿名用户" : "欢迎使用" +); +const username = computed(() => userInfo.value?.username || "未设置账号"); +const deptName = computed(() => (isLogin.value ? userInfo.value?.deptName || "" : "")); const headerBackground = computed(() => { - const color = currentThemeColor.value || "var(--color-primary)"; + const color = themeStore.themeVars.colorTheme || "var(--color-primary)"; const colorWithAlpha = color.length === 7 ? `${color}E6` : color; const colorWithAlpha2 = color.length === 7 ? `${color}CC` : color; return `linear-gradient(135deg, ${colorWithAlpha} 0%, ${colorWithAlpha2} 100%)`; }); -const router = useRouter(); const appVersion = ref("1.0.0"); -const navbar = useNavbar({ hasTabbar: true }); +const isClearing = ref(false); +const cacheSize = ref("计算中..."); + +const toolMenus = computed(() => [ + { key: "network", icon: "tool", tone: "warning", title: "网络检测", desc: "检测接口连通性" }, + { + key: "clear-cache", + icon: "delete", + tone: "danger", + title: "清理缓存", + desc: "显示当前缓存大小", + value: cacheSize.value, + }, +]); + +const helpMenus = computed(() => [ + { + key: "settings", + icon: "settings", + tone: "primary", + title: "系统设置", + desc: "主题、语言、通知等设置", + }, + { + key: "agreement", + icon: "safe", + tone: "success", + title: "用户协议", + desc: "了解产品使用规则", + }, + { + key: "about", + icon: "info-circle", + tone: "info", + title: "关于系统", + desc: "产品介绍与联系方式", + value: `v${appVersion.value}`, + }, +]); + +const menuRoutes: Record = { + network: "/subPages/mine/settings/network/index", + settings: "/subPages/mine/settings/index", + agreement: "/subPages/mine/settings/agreement/index", + about: "/subPages/mine/about/index", +}; + +function handleMenuSelect(key: string) { + if (key === "clear-cache") { + handleClearCache(); + return; + } + const path = menuRoutes[key]; + if (path) { + router.push({ path }); + } +} + +// 登录 +const navigateToLogin = () => { + const pages = getCurrentPages(); + const currentPage = pages[pages.length - 1]; + const currentPagePath = `/${currentPage.route}`; + router.push({ path: "/pages/login/index", query: { redirect: currentPagePath } }); +}; + +const openProfile = () => { + if (!isLogin.value) { + navigateToLogin(); + return; + } + router.push({ path: "/subPages/mine/profile/index" }); +}; + +// 账号和安全 +const openAccount = () => { + if (!isLogin.value) { + navigateToLogin(); + return; + } + router.push({ path: "/subPages/mine/account/index" }); +}; + +const openNotifications = () => { + if (!isLogin.value) { + navigateToLogin(); + return; + } + toast.info("功能开发中"); +}; + +// 有来技术公众号 +const openOfficialAccount = () => { + uni.navigateTo({ + url: "/subPages/mine/official/index", + }); +}; const hasUserProfile = computed(() => { const info = userInfo.value; return !!(info && (info.userId || info.username || info.nickname)); }); -const deptNameText = computed(() => { - if (!isLogin.value) return ""; - return userInfo.value?.deptName || ""; -}); - const fetchUserInfoIfNeeded = async () => { if (!isLogin.value || hasUserProfile.value) return; try { @@ -264,65 +224,6 @@ onShow(async () => { syncMiniProgramVersion(); }); -// 登录 -const navigateToLogin = () => { - const pages = getCurrentPages(); - const currentPage = pages[pages.length - 1]; - const currentPagePath = `/${currentPage.route}`; - router.push({ path: "/pages/login/index", query: { redirect: currentPagePath } }); -}; - -// 个人信息 -const openProfile = () => { - if (!isLogin.value) { - navigateToLogin(); - return; - } - router.push({ path: "/pages/mine/profile/index" }); -}; - -// 账号和安全 -const openAccount = () => { - if (!isLogin.value) { - navigateToLogin(); - return; - } - router.push({ path: "/pages/mine/account/index" }); -}; - -const openNotifications = () => { - if (!isLogin.value) { - navigateToLogin(); - return; - } - uni.showToast({ - title: "功能开发中", - icon: "none", - }); -}; - -// 系统设置 -const openSettings = () => { - router.push({ path: "/pages/mine/settings/index" }); -}; - -// 用户协议 -const openUserAgreement = () => { - router.push({ path: "/pages/mine/settings/agreement/index" }); -}; - -// 网络测试 -const openNetworkTest = () => { - router.push({ path: "/pages/mine/settings/network/index" }); -}; - -const openAbout = () => { - router.push({ path: "/pages/mine/about/index" }); -}; - -const isClearing = ref(false); -const cacheSize = ref("计算中..."); - const fetchCacheSize = async () => { try { // #ifdef MP-WEIXIN @@ -344,19 +245,11 @@ const fetchCacheSize = async () => { const handleClearCache = async () => { if (cacheSize.value === "获取失败") { - uni.showToast({ - title: "获取缓存信息失败,请稍后重试", - icon: "none", - duration: 2000, - }); + toast.info("获取缓存信息失败,请稍后重试"); return; } if (cacheSize.value === "0B") { - uni.showToast({ - title: "暂无缓存需要清理", - icon: "none", - duration: 2000, - }); + toast.info("暂无缓存需要清理"); return; } if (isClearing.value) { @@ -365,36 +258,18 @@ const handleClearCache = async () => { try { isClearing.value = true; - await new Promise((resolve) => setTimeout(resolve, 1500)); await uni.clearStorage(); await fetchCacheSize(); - uni.showToast({ - title: "清理成功", - icon: "success", - }); + toast.success("清理成功"); } catch { - uni.showToast({ - title: "清理失败", - icon: "error", - }); + toast.error("清理失败"); } finally { isClearing.value = false; } }; - -// 扫一扫:扫描 PC 端二维码后跳转确认页(逻辑收敛在 useScanLogin) -const { scanLogin } = useScanLogin(); - -// 有来技术公众号 -const openOfficialAccount = () => { - uni.navigateTo({ - url: "/pages/mine/official/index", - }); -}; diff --git a/src/pages/work/index.vue b/src/pages/work/index.vue index f422765..d76bceb 100644 --- a/src/pages/work/index.vue +++ b/src/pages/work/index.vue @@ -1,29 +1,32 @@ diff --git a/src/pages/work/notice/index.vue b/src/subPages/work/notice/index.vue similarity index 69% rename from src/pages/work/notice/index.vue rename to src/subPages/work/notice/index.vue index 234913f..d83557e 100644 --- a/src/pages/work/notice/index.vue +++ b/src/subPages/work/notice/index.vue @@ -1,5 +1,5 @@ -