st-comp 0.0.127 → 0.0.129

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "st-comp",
3
3
  "public": true,
4
- "version": "0.0.127",
4
+ "version": "0.0.129",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -1,31 +1,31 @@
1
1
  import { initRequest, isLogin, getToken, loginout, getUserData } from "st-func";
2
2
 
3
- const env = { VITE_BASE_URL: 'http://127.0.0.1:7001' }
4
-
5
- const { get, post } = initRequest(env, {
6
- handleReq: (request) => {
7
- if (isLogin()) {
8
- request.headers["token"] = getToken();
9
- }
10
- },
11
- handleRes: (response) => {
12
- const { data } = response;
13
- // 登录失效
14
- if (data.code === 401) {
15
- if (location.origin.includes("localhost")) {
16
- location.href = `${location.origin}/#/404`;
17
- } else {
18
- loginout();
3
+ let get = null;
4
+ let post = null;
5
+
6
+ export const initRequestByEnv = (env) => {
7
+ const requestFn = initRequest(env, {
8
+ handleReq: (request) => {
9
+ if (isLogin()) {
10
+ request.headers["token"] = getToken();
19
11
  }
20
- return true;
21
- }
22
- },
23
- timeout: 20 * 60 * 1000,
24
- });
25
-
26
-
27
- const token = getToken();
28
- const host = "http://127.0.0.1:7001";
12
+ },
13
+ handleRes: (response) => {
14
+ const { data } = response;
15
+ // 登录失效
16
+ if (data.code === 401) {
17
+ if (location.origin.includes("localhost")) {
18
+ location.href = `${location.origin}/#/404`;
19
+ } else {
20
+ loginout();
21
+ }
22
+ return true;
23
+ }
24
+ },
25
+ });
26
+ get = requestFn.get;
27
+ post = requestFn.post;
28
+ }
29
29
 
30
30
  // 获取K线数据以及基础数据
31
31
  export const getKlineBasic = (data) => {
@@ -84,7 +84,7 @@
84
84
  import { onMounted, onUnmounted, ref, watch, computed } from "vue"
85
85
  import * as echarts from "echarts"
86
86
  import dayjs from "dayjs"
87
- import { getKlineBasic, getKline, getWarningLine, addWarningLine, updateWarningLine, deleteWarningLine } from './api'
87
+ import { initRequestByEnv, getKlineBasic, getKline, getWarningLine, addWarningLine, updateWarningLine, deleteWarningLine } from './api'
88
88
  import { addResizeListener } from 'st-func'
89
89
  import { getMainOptions, getWarningLineOptions } from './utils'
90
90
  import KlineTips from './components/KlineTips/index.vue'
@@ -149,6 +149,10 @@ const props = defineProps({
149
149
  type: Object,
150
150
  default: () => ({})
151
151
  }, // 配置
152
+ env: {
153
+ type: Object,
154
+ default: () => ({})
155
+ }, // 环境变量
152
156
  })
153
157
 
154
158
  const isEmpty = ref(false) // 是否无数据
@@ -196,7 +200,7 @@ watch(
196
200
  )
197
201
 
198
202
  onMounted(() => {
199
- console.log(import.meta.env)
203
+ initRequestByEnv(props.env)
200
204
  getMainData()
201
205
  })
202
206
 
@@ -308,7 +312,7 @@ const getMainData = async () => {
308
312
  params.limit = defaultShowCounts + addCounts
309
313
  } else {
310
314
  // 未传入时间,使用最新时间作为结束时间请求数据
311
- params.endTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
315
+ params.endTime = dayjs().add(1, "hour").format('YYYY-MM-DD HH:mm:ss')
312
316
  params.limit = defaultShowCounts + addCounts
313
317
  }
314
318
  const res = await getKlineBasic(params)
@@ -1,7 +1,7 @@
1
1
  import axios from "axios";
2
2
 
3
3
  const token = "490cdb08082fe518cdfa476bd53edc86";
4
- const host = "http://127.0.0.1:7001";
4
+ const host = "http://192.168.12.38:5173";
5
5
 
6
6
  // 获取指标线配置
7
7
  export const getIndicator = async () => {
@@ -32,6 +32,7 @@
32
32
  :mainIndicator="mainIndicator"
33
33
  :indicatorStore="indicatorStore"
34
34
  :config="config"
35
+ :env="{ VITE_BASE_URL: 'http://192.168.12.38:5173' }"
35
36
  />
36
37
  </div>
37
38
  </div>