st-comp 0.0.13 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/auto-imports.d.ts +1 -1
  2. package/components.d.ts +2 -1
  3. package/lib/bundle.js +10145 -9151
  4. package/lib/bundle.umd.cjs +10 -12
  5. package/lib/style.css +1 -1
  6. package/lib/talib.wasm +0 -0
  7. package/package.json +4 -1
  8. package/packages/Kline/components/Contextmenu/index.vue +110 -0
  9. package/packages/Kline/components/Tips/index.vue +18 -86
  10. package/packages/Kline/formatKlineData.ts +67 -40
  11. package/packages/Kline/images/buy.svg +1 -0
  12. package/packages/Kline/images/pen.png +0 -0
  13. package/packages/Kline/images/sell.svg +1 -0
  14. package/packages/Kline/images/t.svg +1 -0
  15. package/packages/Kline/index.vue +439 -119
  16. package/packages/Kline/option.ts +316 -0
  17. package/packages/Kline/type.d.ts +192 -24
  18. package/packages/Kline/utils.ts +576 -171
  19. package/packages/Table/components/Button/index.vue +7 -0
  20. package/packages/Table/index.vue +37 -24
  21. package/packages/index.ts +0 -2
  22. package/public/talib.wasm +0 -0
  23. package/src/pages/ChartLayout/index.vue +22 -22
  24. package/src/pages/Kline/api.ts +57 -0
  25. package/src/pages/Kline/components/MultiCycleSingleVariety.vue +728 -0
  26. package/src/pages/Kline/components/SingleCycleSingleVariety.vue +663 -0
  27. package/src/pages/Kline/index.vue +85 -16
  28. package/src/router/routes.ts +0 -5
  29. package/src/style.css +75 -0
  30. package/vite.config.ts +37 -27
  31. package/vitePlugins/testRelese.ts +67 -0
  32. package/packages/Echarts/index.ts +0 -8
  33. package/packages/Echarts/index.vue +0 -113
  34. package/packages/Kline/kline_theme_dark.json +0 -30
  35. package/packages/Kline/kline_theme_light.json +0 -30
  36. package/src/components/Echarts/index.vue +0 -31
  37. package/src/pages/Echarts/index.vue +0 -12
@@ -1,21 +1,90 @@
1
+ <!-- 业务K线组件Demo页面 -->
2
+ <script setup lang="ts">
3
+ import { ref, computed } from 'vue'
4
+ import SingleCycleSingleVariety from './components/SingleCycleSingleVariety.vue'
5
+ import MultiCycleSingleVariety from './components/MultiCycleSingleVariety.vue'
6
+ // 当前选择的标签页值
7
+ const elTab = ref(1)
8
+ // 当前加载的动态组件
9
+ const componentName = computed(() => {
10
+ const componentMap = new Map([
11
+ [1, SingleCycleSingleVariety],
12
+ [2, MultiCycleSingleVariety],
13
+ ])
14
+ return componentMap.get(elTab.value)
15
+ })
16
+ // 调试按钮
17
+ const deBugValue = ref(1)
18
+
19
+ const elTabChange = () => {
20
+ deBugValue.value = 1
21
+ }
22
+ </script>
23
+
1
24
  <template>
2
- <div id="Kline">
3
- <st-kline
4
- code="ao8888.SHFE"
5
- tradeDate="2023-10-13T16:24:28"
6
- indicator="DKX_EMA"
7
- frequency="1m"
8
- />
25
+ <div id="kline-page">
26
+ <el-tabs v-model="elTab" @tab-change="elTabChange">
27
+ <el-tab-pane
28
+ label="单品种单周期"
29
+ :name="1"
30
+ />
31
+ <el-tab-pane
32
+ label="单品种多周期"
33
+ :name="2"
34
+ />
35
+ </el-tabs>
36
+ <!-- 调试按钮 -->
37
+ <el-radio-group
38
+ class="deBugGroup"
39
+ v-model="deBugValue"
40
+ >
41
+ <el-radio-button :label="1">正常模式</el-radio-button>
42
+ <el-radio-button :label="2">网络请求错误</el-radio-button>
43
+ <el-radio-button :label="3">空数据</el-radio-button>
44
+ </el-radio-group>
45
+ <div class="kline-page-body">
46
+ <Transition
47
+ name="animation"
48
+ mode="out-in"
49
+ >
50
+ <component
51
+ :is="componentName"
52
+ :deBugValue="deBugValue"
53
+ />
54
+ </Transition>
55
+ </div>
9
56
  </div>
10
57
  </template>
11
58
 
12
- <script setup lang="ts">
13
- </script>
14
-
15
- <style scoped>
16
- #Kline{
17
- margin: auto;
18
- width: 1200px;
19
- height: 600px;
20
- }
59
+ <style lang="scss" scoped>
60
+ #kline-page {
61
+ height: 100%;
62
+ display: flex;
63
+ flex-direction: column;
64
+ position: relative;
65
+ .deBugGroup {
66
+ position: absolute;
67
+ right: 0;
68
+ top: 7px;
69
+ }
70
+ .kline-page-body {
71
+ flex: 1;
72
+ overflow: hidden;
73
+ // 进入和离开的两个过程
74
+ .animation-enter-active,
75
+ .animation-leave-active {
76
+ transition: all 0.3s ease-in-out;
77
+ }
78
+ // 进入的动画初始样式
79
+ .animation-enter-from {
80
+ transform: translateY(-500px);
81
+ opacity: 0;
82
+ }
83
+ // 离开的动画初始样式
84
+ .animation-leave-to {
85
+ transform: translateY(500px);
86
+ opacity: 0;
87
+ }
88
+ }
89
+ }
21
90
  </style>
@@ -9,11 +9,6 @@ export default [
9
9
  name: 'Dialog',
10
10
  component: () => import('../pages/Dialog/index.vue'),
11
11
  },
12
- {
13
- path: '/echarts',
14
- name: 'Echarts',
15
- component: () => import('../pages/Echarts/index.vue'),
16
- },
17
12
  {
18
13
  path: '/kline',
19
14
  name: 'Kline',
package/src/style.css CHANGED
@@ -1,4 +1,79 @@
1
1
  html, body {
2
2
  padding: 0;
3
3
  margin: 0;
4
+ }
5
+
6
+ .element-dark {
7
+ color-scheme: dark;
8
+ --el-color-primary: #409eff;
9
+ --el-color-primary-light-3: #3375b9;
10
+ --el-color-primary-light-5: #2a598a;
11
+ --el-color-primary-light-7: #213d5b;
12
+ --el-color-primary-light-8: #1d3043;
13
+ --el-color-primary-light-9: #18222c;
14
+ --el-color-primary-dark-2: #66b1ff;
15
+ --el-color-success: #67c23a;
16
+ --el-color-success-light-3: #4e8e2f;
17
+ --el-color-success-light-5: #3e6b27;
18
+ --el-color-success-light-7: #2d481f;
19
+ --el-color-success-light-8: #25371c;
20
+ --el-color-success-light-9: #1c2518;
21
+ --el-color-success-dark-2: #85ce61;
22
+ --el-color-warning: #e6a23c;
23
+ --el-color-warning-light-3: #a77730;
24
+ --el-color-warning-light-5: #7d5b28;
25
+ --el-color-warning-light-7: #533f20;
26
+ --el-color-warning-light-8: #3e301c;
27
+ --el-color-warning-light-9: #292218;
28
+ --el-color-warning-dark-2: #ebb563;
29
+ --el-color-danger: #f56c6c;
30
+ --el-color-danger-light-3: #b25252;
31
+ --el-color-danger-light-5: #854040;
32
+ --el-color-danger-light-7: #582e2e;
33
+ --el-color-danger-light-8: #412626;
34
+ --el-color-danger-light-9: #2b1d1d;
35
+ --el-color-danger-dark-2: #f78989;
36
+ --el-color-error: #f56c6c;
37
+ --el-color-error-light-3: #b25252;
38
+ --el-color-error-light-5: #854040;
39
+ --el-color-error-light-7: #582e2e;
40
+ --el-color-error-light-8: #412626;
41
+ --el-color-error-light-9: #2b1d1d;
42
+ --el-color-error-dark-2: #f78989;
43
+ --el-color-info: #909399;
44
+ --el-color-info-light-3: #6b6d71;
45
+ --el-color-info-light-5: #525457;
46
+ --el-color-info-light-7: #393a3c;
47
+ --el-color-info-light-8: #2d2d2f;
48
+ --el-color-info-light-9: #202121;
49
+ --el-color-info-dark-2: #a6a9ad;
50
+ --el-box-shadow: 0px 12px 32px 4px rgba(0, 0, 0, 0.36),0px 8px 20px rgba(0, 0, 0, 0.72);
51
+ --el-box-shadow-light: 0px 0px 12px rgba(0, 0, 0, 0.72);
52
+ --el-box-shadow-lighter: 0px 0px 6px rgba(0, 0, 0, 0.72);
53
+ --el-box-shadow-dark: 0px 16px 48px 16px rgba(0, 0, 0, 0.72),0px 12px 32px #000000,0px 8px 16px -8px #000000;
54
+ --el-bg-color-page: #0a0a0a;
55
+ --el-bg-color: #141414;
56
+ --el-bg-color-overlay: #1d1e1f;
57
+ --el-text-color-primary: #E5EAF3;
58
+ --el-text-color-regular: #CFD3DC;
59
+ --el-text-color-secondary: #A3A6AD;
60
+ --el-text-color-placeholder: #8D9095;
61
+ --el-text-color-disabled: #6C6E72;
62
+ --el-border-color-darker: #636466;
63
+ --el-border-color-dark: #58585B;
64
+ --el-border-color: #4C4D4F;
65
+ --el-border-color-light: #414243;
66
+ --el-border-color-lighter: #363637;
67
+ --el-border-color-extra-light: #2B2B2C;
68
+ --el-fill-color-darker: #424243;
69
+ --el-fill-color-dark: #39393A;
70
+ --el-fill-color: #303030;
71
+ --el-fill-color-light: #262727;
72
+ --el-fill-color-lighter: #1D1D1D;
73
+ --el-fill-color-extra-light: #191919;
74
+ --el-fill-color-blank: transparent;
75
+ --el-mask-color: rgba(0, 0, 0, 0.8);
76
+ --el-mask-color-extra-light: rgba(0, 0, 0, 0.3);
77
+ --el-disabled-bg-color: var(--el-fill-color-dark);
78
+ --el-disabled-border-color: var(--el-border-color-dark);
4
79
  }
package/vite.config.ts CHANGED
@@ -4,10 +4,12 @@ import AutoImport from 'unplugin-auto-import/vite' // element-plus自动引用
4
4
  import Components from 'unplugin-vue-components/vite' // element-plus自动引用使用
5
5
  import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' // element-plus自动引用使用
6
6
  import createExportFile from './vitePlugins/createExportFile.ts'
7
+ import testRelease from './vitePlugins/testRelese.js'
7
8
 
8
9
  // https://vitejs.dev/config/
9
- export default defineConfig({
10
- plugins: [
10
+ export default ({ mode }) => {
11
+
12
+ const plugins = [
11
13
  vue(),
12
14
  AutoImport({
13
15
  resolvers: [ElementPlusResolver()],
@@ -16,31 +18,39 @@ export default defineConfig({
16
18
  resolvers: [ElementPlusResolver()],
17
19
  }),
18
20
  createExportFile(),
19
- ],
20
- build: {
21
- outDir: 'lib',
22
- lib: {
23
- entry: './packages/index.ts',
24
- name: 'Bundle',
25
- fileName: 'bundle'
21
+ ]
22
+
23
+ if (mode === 'test') {
24
+ plugins.push(testRelease({ source: 'dist', target_dir: 'stComp' }))
25
+ }
26
+
27
+ return defineConfig({
28
+ base: './',
29
+ plugins,
30
+ build: mode === 'test' ? undefined : {
31
+ outDir: 'lib',
32
+ lib: {
33
+ entry: './packages/index.ts',
34
+ name: 'Bundle',
35
+ fileName: 'bundle'
36
+ },
37
+ rollupOptions: {
38
+ external: ['vue', 'echarts'],
39
+ }
26
40
  },
27
- rollupOptions: {
28
- external: ['vue', 'echarts'],
29
- }
30
- },
31
-
32
- resolve: {
33
- alias: {
34
- '@':'./src'
35
- }
36
- },
37
- server: {
38
- proxy: {
39
- '/proxy': {
40
- target: 'http://192.168.12.49:88/',
41
- changeOrigin: true,
42
- rewrite: (path) => path.replace(/^\/proxy/, ''),
41
+ resolve: {
42
+ alias: {
43
+ '@':'./src'
44
+ }
45
+ },
46
+ server: {
47
+ proxy: {
48
+ '/proxy': {
49
+ target: 'http://192.168.12.49:88/',
50
+ changeOrigin: true,
51
+ rewrite: (path) => path.replace(/^\/proxy/, ''),
52
+ }
43
53
  }
44
54
  }
45
- }
46
- })
55
+ })
56
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * 上传资源并重启nginx插件
3
+ * 需要安装依赖 ssh2-sftp-client ssh2
4
+ * 执行命令 npm install ssh2-sftp-client ssh2 -D
5
+ * 使用方法:
6
+ * 1.将该文件放到项目根目录中
7
+ * 2.vue.config.js中引入该文件到处的类
8
+ * 3.在configureWebpack.plugins中根据想要的环境(目前仅支持发测试环境)加入该插件
9
+ * 4.参数option.source为需要上传的文件夹路径,使用相对路径即可(必填)
10
+ * 参数option.target为需要上传到服务端的路径,当前默认为测试环境的路径(可选)
11
+ * 参数option.target_dir为上传到服务器后的文件夹名称(必填)
12
+ */
13
+ import Client from 'ssh2-sftp-client'
14
+ import Ssh2Client from 'ssh2'
15
+
16
+ const defaultOption = {
17
+ source: '', // 需要上传的文件夹
18
+ target: '/usr/local/nginx/html/', // 服务端存放资源的路径
19
+ target_dir: '', // 目标文件夹名称
20
+ host: '192.168.12.49', // 服务器地址
21
+ port: '22', // 服务器断开
22
+ username: 'root', // 服务器登录用户名
23
+ password: 'hzst2020', // 服务器登录密码
24
+ }
25
+
26
+ // 重启nginx
27
+ const reloadNginx = (serverMsg) => {
28
+ const conn = new Ssh2Client.Client()
29
+ conn.on('ready', () => {
30
+ conn.shell((err, stream) => {
31
+ if (err) throw err
32
+ stream.end('cd /usr/local/nginx/ \n/usr/local/nginx/sbin/nginx -s reload')
33
+ console.log('nginx重启完成')
34
+ conn.end()
35
+ })
36
+ }).connect(serverMsg)
37
+ }
38
+
39
+ // 上传文件
40
+ const upload = async mergeOption => {
41
+ const { source, target, target_dir, host, port, username, password } = mergeOption
42
+ if (!source || !target_dir) {
43
+ console.log('发布插件参数有误,请检查后重试')
44
+ return
45
+ }
46
+ const sftp = new Client()
47
+ try {
48
+ const serverMsg = { host, port, username, password }
49
+ await sftp.connect(serverMsg)
50
+ console.log('服务器连接成功,开始上传资源')
51
+ await sftp.uploadDir(`./${source}`, `${target}${target_dir}`)
52
+ console.log('资源上传完成')
53
+ sftp.end()
54
+ reloadNginx(serverMsg)
55
+ } catch (err) {
56
+ console.log('发布失败', err)
57
+ sftp.end()
58
+ }
59
+ }
60
+
61
+ export default option => ({
62
+ name: 'release',
63
+ closeBundle() {
64
+ const mergeOption = { ...defaultOption, ...option }
65
+ upload(mergeOption)
66
+ }
67
+ })
@@ -1,8 +0,0 @@
1
- import { App } from "vue";
2
- import StEcharts from "./index.vue";
3
-
4
- export default {
5
- install(app: App) {
6
- app.component("st-echarts", StEcharts);
7
- },
8
- }
@@ -1,113 +0,0 @@
1
- <template>
2
- <div
3
- ref="chartRef"
4
- class="st-echarts"
5
- />
6
- </template>
7
-
8
- <script setup lang="ts">
9
- import * as echarts from 'echarts'
10
- import type { EChartsType } from 'echarts'
11
- import { ref, onMounted, watch, onUnmounted } from 'vue'
12
-
13
- const emit = defineEmits(['afterInit', 'highlight', 'contextmenu', 'resize', 'datazoom'])
14
- const props = defineProps({
15
- option: {
16
- type: Object,
17
- required: true,
18
- }, // echarts配置
19
- theme: {
20
- type: String,
21
- default: () => 'light',
22
- }, // 主题
23
- themeConfig: {
24
- type: Object,
25
- default: () => ({
26
- name: 'basic',
27
- light: {},
28
- dark: {},
29
- }),
30
- }, // 样式配置
31
- })
32
-
33
- const chartRef = ref<HTMLElement>()
34
- let chart: EChartsType // echarts实例
35
- let chartDomObserver: any // echarts监视DOM变化
36
-
37
- watch(
38
- () => props.option,
39
- () => {
40
- chart.clear()
41
- chart.setOption(props.option)
42
- emit('afterInit', chart)
43
- },
44
- { deep: true }
45
- )
46
- watch(
47
- () => props.theme,
48
- () => {
49
- chart.dispose()
50
- const theme = registerTheme()
51
- chart = echarts.init(chartRef.value, theme)
52
- chart.setOption(props.option)
53
- emit('afterInit', chart)
54
- }
55
- )
56
-
57
- onMounted(() => {
58
- const theme = registerTheme()
59
- chart = echarts.init(chartRef.value, theme)
60
- chart.setOption(props.option)
61
- emit('afterInit', chart)
62
-
63
- // 监听dom元素样式改变,执行resize方法
64
- chartDomObserver = new ResizeObserver(() => {
65
- chart.resize()
66
- emit('resize', chart)
67
- })
68
- chartDomObserver.observe(chartRef.value)
69
-
70
- addEventListener()
71
- })
72
-
73
- onUnmounted(() => {
74
- chart.dispose()
75
- // 取消dom元素样式改变监听
76
- chartDomObserver.disconnect()
77
- })
78
-
79
- // 注册主题
80
- const registerTheme = () => {
81
- const { name, light, dark } = props.themeConfig
82
- const theme = props.theme === 'dark' ? `${name}_dark` : name
83
- echarts.registerTheme(theme, props.theme === 'dark' ? dark : light)
84
- return theme
85
- }
86
-
87
- // 绑定事件
88
- const addEventListener = () => {
89
- // 高亮事件
90
- chart.on('highlight', (data: any) => {
91
- emit('highlight', data, chart)
92
- })
93
- // 移出图表事件
94
- chart.on('globalout', () => {
95
- emit('highlight', null, chart)
96
- })
97
- // 右键点击事件
98
- chart.on('contextmenu', (params: any) => {
99
- emit('contextmenu', params, chart)
100
- })
101
- // 右键点击事件
102
- chart.on('datazoom', (params: any) => {
103
- emit('datazoom', params, chart)
104
- })
105
- }
106
- </script>
107
-
108
- <style scoped>
109
- .st-echarts {
110
- width: 100%;
111
- height: 100%;
112
- }
113
- </style>
@@ -1,30 +0,0 @@
1
-
2
- {
3
- "candlestick": {
4
- "itemStyle": {
5
- "color": "transparent",
6
- "color0": "#00FFFF",
7
- "borderColor": "#FF0000",
8
- "borderColor0": "#00FFFF",
9
- "borderWidth": 1
10
- }
11
- },
12
- "categoryAxis": {
13
- "splitLine": {
14
- "lineStyle": {
15
- "color": [
16
- "#333"
17
- ]
18
- }
19
- }
20
- },
21
- "valueAxis": {
22
- "splitLine": {
23
- "lineStyle": {
24
- "color": [
25
- "#333"
26
- ]
27
- }
28
- }
29
- }
30
- }
@@ -1,30 +0,0 @@
1
-
2
- {
3
- "candlestick": {
4
- "itemStyle": {
5
- "color": "transparent",
6
- "color0": "#00FFFF",
7
- "borderColor": "#FF0000",
8
- "borderColor0": "#00FFFF",
9
- "borderWidth": 1
10
- }
11
- },
12
- "categoryAxis": {
13
- "splitLine": {
14
- "lineStyle": {
15
- "color": [
16
- "#333"
17
- ]
18
- }
19
- }
20
- },
21
- "valueAxis": {
22
- "splitLine": {
23
- "lineStyle": {
24
- "color": [
25
- "#333"
26
- ]
27
- }
28
- }
29
- }
30
- }
@@ -1,31 +0,0 @@
1
- <template>
2
- <div :style="{ width: '400px', height: '400px' }">
3
- <st-echarts
4
- :option="option"
5
- />
6
- </div>
7
- </template>
8
-
9
- <script setup lang="ts">
10
- import { ref } from 'vue'
11
-
12
- const option = ref({
13
- xAxis: {
14
- type: 'category',
15
- data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
16
- },
17
- yAxis: {
18
- type: 'value'
19
- },
20
- series: [
21
- {
22
- data: [150, 230, 224, 218, 135, 147, 260],
23
- type: 'line'
24
- }
25
- ]
26
- })
27
- </script>
28
-
29
- <style scoped>
30
-
31
- </style>
@@ -1,12 +0,0 @@
1
- <template>
2
- <div>
3
- Echarts
4
- </div>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- </script>
9
-
10
- <style lang="scss" scoped>
11
-
12
- </style>