From 35e1809b8218a2ecff238f3449da117acd27e4ea Mon Sep 17 00:00:00 2001
From: sws <1141121512@qq.com>
Date: Fri, 16 Aug 2024 15:53:17 +0800
Subject: [PATCH 1/3] =?UTF-8?q?1.=E6=8B=96=E6=8B=BD=E7=94=9F=E6=88=90?=
=?UTF-8?q?=E7=83=AD=E5=8C=BA=E4=BF=AE=E5=A4=8D=E9=BC=A0=E6=A0=87=E6=8B=96?=
=?UTF-8?q?=E6=8B=BD=E5=88=B0=E5=A4=96=E9=83=A8=E6=97=B6=EF=BC=8C=E5=9D=90?=
=?UTF-8?q?=E6=A0=87=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98=20sws=202024-08-1?=
=?UTF-8?q?6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/common/hot/index.vue | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/components/common/hot/index.vue b/src/components/common/hot/index.vue
index afc60918..d1e801d6 100644
--- a/src/components/common/hot/index.vue
+++ b/src/components/common/hot/index.vue
@@ -148,6 +148,7 @@ const end_drag = (event: MouseEvent) => {
drag_end: cloneDeep(rect_end.value),
});
}
+ rect_start.value = { x: 0, y: 0, width: 0, height: 0 };
rect_end.value = { x: 0, y: 0, width: 0, height: 0 };
};
From 51b8af20ebd827b92e5edfe1fb98609bbcf5ef84 Mon Sep 17 00:00:00 2001
From: sws <1141121512@qq.com>
Date: Fri, 16 Aug 2024 17:16:25 +0800
Subject: [PATCH 2/3] =?UTF-8?q?1.=E8=A7=A3=E5=86=B3api=E6=8E=A5=E5=8F=A3?=
=?UTF-8?q?=E9=97=AE=E9=A2=98=20sws=202024-08-16?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/utils/index.ts | 67 +++++++++++++++++++++++++++++++++++++-------
src/utils/request.ts | 20 +++++++------
2 files changed, 69 insertions(+), 18 deletions(-)
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 4338315e..aeb961b1 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,4 +1,4 @@
-import { isEmpty } from "lodash";
+import { isEmpty } from 'lodash';
/**
* 判断一个对象是否为空。
*
@@ -41,13 +41,13 @@ export function gradient_handle(color_list: color_list[], direction: string) {
new_color_list.forEach((item: any, index: number) => {
container_common_styles += `${item.color ? item.color : 'rgb(255 255 255 / 0%)'}`;
if (color_list.length == 1) {
- container_common_styles += ` ${ item.color_percentage || 0 }%, ${ item.color } 100%`;
+ container_common_styles += ` ${item.color_percentage || 0}%, ${item.color} 100%`;
} else {
if (!isEmpty(item.color_percentage)) {
if (index == color_list.length - 1) {
- container_common_styles += ` ${ item.color_percentage }%`;
+ container_common_styles += ` ${item.color_percentage}%`;
} else {
- container_common_styles += ` ${ item.color_percentage }%,`;
+ container_common_styles += ` ${item.color_percentage}%,`;
}
} else {
if (index == color_list.length - 1) {
@@ -58,7 +58,6 @@ export function gradient_handle(color_list: color_list[], direction: string) {
container_common_styles += ` ${(100 / color_list.length) * index}%,`;
}
}
-
}
});
container_common_styles += `);`;
@@ -200,7 +199,6 @@ export const ext_name = (name: string) => {
return '';
};
-
/**
* 将大小计算成百分比
*
@@ -209,9 +207,9 @@ export const ext_name = (name: string) => {
* @returns 计算后的百分比值,含4位小数
*/
export const percentage_count = (num: number, container_size: number) => {
- const marks = num / container_size * 100;
- return marks.toFixed(4)+ '%';
-}
+ const marks = (num / container_size) * 100;
+ return marks.toFixed(4) + '%';
+};
/**
* 计算当前偏移量
@@ -232,4 +230,53 @@ export const location_compute = (size: number, location: number, container_size:
} else {
return location;
}
-}
\ No newline at end of file
+};
+
+/**
+ * 读取指定名称的cookie值
+ * @param name 需要读取的cookie的名称
+ * @returns 返回cookie的值,如果未找到则返回空字符串
+ */
+export const get_cookie = (name: string) => {
+ // 初始化cookie值为空字符串
+ var cookievalue = '';
+ // 定义要搜索的cookie名称字符串
+ var search = name + '=';
+ // 检查是否存在cookie
+ if (document.cookie.length > 0) {
+ // 尝试查找cookie名称的位置
+ let offset = document.cookie.indexOf(search);
+ // 如果找到了cookie名称
+ if (offset != -1) {
+ // 跳过cookie名称的长度
+ offset += search.length;
+ // 查找cookie值的结束位置(可能是分号或者字符串末尾)
+ let end = document.cookie.indexOf(';', offset);
+ if (end == -1) end = document.cookie.length;
+ // 提取并解码cookie值
+ cookievalue = decodeURIComponent(document.cookie.substring(offset, end));
+ }
+ }
+ // 返回获取到的cookie值
+ return cookievalue;
+};
+/**
+ * 设置cookie
+ * 该函数用于设置一个cookie,包括cookie的名称、值和过期时间
+ * @param name {string} - cookie的名称
+ * @param value {string} - cookie的值
+ * @param expire_time {number} - cookie的过期时间,单位为天
+ */
+export const set_cookie = (name: string, value: string, expire_time?: number) => {
+ // 构造cookie字符串
+ var cookie_str = name + '=' + encodeURIComponent(value);
+ if (expire_time) {
+ // 获取当前时间
+ var now = new Date();
+ // 计算过期时间
+ var expire_date = new Date(now.getTime() + expire_time * 86400);
+ cookie_str += ';expires=' + expire_date.toUTCString();
+ // 将新增的cookie储存到cookie中,可以存储多个而不是替换
+ document.cookie = cookie_str;
+ }
+};
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 6122e5b2..69b56b29 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -1,8 +1,11 @@
import axios, { InternalAxiosRequestConfig, AxiosResponse } from 'axios';
import { ElMessage, ElMessageBox } from 'element-plus';
+import { get_cookie } from './index';
// 创建 axios 实例
+const index = window.location.href.lastIndexOf('?');
+const pro_url = window.location.href.substring(0, index);
const service = axios.create({
- baseURL: import.meta.env.VITE_APP_BASE_API == '/dev-api' ? import.meta.env.VITE_APP_BASE_API : window.location.origin,
+ baseURL: import.meta.env.VITE_APP_BASE_API == '/dev-api' ? import.meta.env.VITE_APP_BASE_API : pro_url,
timeout: 50000,
headers: { 'Content-Type': 'application/json;charset=utf-8' },
});
@@ -10,13 +13,14 @@ const service = axios.create({
// 请求拦截器
service.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
- // const userStore = useUserStoreHook();
- // const accessToken = localStorage.getItem(TOKEN_KEY);
- const accessToken = { token: 'b84c6cac0dacd1bc624393cd522dec37' };
- if (accessToken.token) {
- // config.headers.Authorization = accessToken.token;
- // config.data = { ...config.data, token: accessToken.token };
- config.url = config.url + '?token=' + accessToken.token;
+ // 如果是本地则使用静态tonken如果是线上则使用cookie的token
+ const cookie = get_cookie('admin_info');
+ let token_key = '';
+ if (cookie) {
+ token_key = import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '68f4eba5f67a758a972cca831885dfda' : JSON.parse(cookie);
+ }
+ if (token_key) {
+ config.url = config.url + '?token=' + token_key;
}
return config;
},
From bc611830e8b4bb2a9b32ee332a4eaafedc31c855 Mon Sep 17 00:00:00 2001
From: sws <1141121512@qq.com>
Date: Fri, 16 Aug 2024 17:47:31 +0800
Subject: [PATCH 3/3] =?UTF-8?q?1.=E8=A7=A3=E5=86=B3=E7=83=AD=E5=8C=BA?=
=?UTF-8?q?=E5=9B=9E=E6=98=BE=E9=97=AE=E9=A2=98=20sws=202024-08-16?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/model-hot-zone/index copy.vue | 87 ++++++++++++++++++++
src/components/model-hot-zone/index.vue | 2 +-
src/utils/request.ts | 12 +--
3 files changed, 94 insertions(+), 7 deletions(-)
create mode 100644 src/components/model-hot-zone/index copy.vue
diff --git a/src/components/model-hot-zone/index copy.vue b/src/components/model-hot-zone/index copy.vue
new file mode 100644
index 00000000..1b7ea686
--- /dev/null
+++ b/src/components/model-hot-zone/index copy.vue
@@ -0,0 +1,87 @@
+
+
+
+
+
diff --git a/src/components/model-hot-zone/index.vue b/src/components/model-hot-zone/index.vue
index be21a435..69180133 100644
--- a/src/components/model-hot-zone/index.vue
+++ b/src/components/model-hot-zone/index.vue
@@ -49,7 +49,7 @@ watch(
w_scale2.value = hotRef.value?.clientWidth / containerRef.value?.clientWidth;
h_scale2.value = hotRef.value?.clientHeight / containerRef.value?.clientHeight;
}
- }, 50);
+ }, 200);
},
{ immediate: true, deep: true }
);
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 69b56b29..998cc0db 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -15,12 +15,12 @@ service.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
// 如果是本地则使用静态tonken如果是线上则使用cookie的token
const cookie = get_cookie('admin_info');
- let token_key = '';
- if (cookie) {
- token_key = import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '68f4eba5f67a758a972cca831885dfda' : JSON.parse(cookie);
- }
- if (token_key) {
- config.url = config.url + '?token=' + token_key;
+ if (import.meta.env.VITE_APP_BASE_API == '/dev-api') {
+ config.url = config.url + '?token=' + 'f714594929c39071f21856b885f91556';
+ } else {
+ if (cookie) {
+ config.url = config.url + '?token=' + JSON.parse(cookie).token;
+ }
}
return config;
},