diff --git a/src/store/modules/common.ts b/src/store/modules/common.ts index f2faa6ed..50f7fa18 100644 --- a/src/store/modules/common.ts +++ b/src/store/modules/common.ts @@ -20,6 +20,7 @@ export const commonStore = defineStore('common', () => { common_tencent_map_ak: '', common_tianditu_map_ak: '', currency_symbol: '', + attachment_host: '', } as any, // 基础数据配置参数 }); // 存储链接数据 diff --git a/src/utils/index.ts b/src/utils/index.ts index cdfde37b..80c7c24a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,8 @@ import { isEmpty } from 'lodash'; +import { commonStore } from '@/store'; +const { common } = commonStore(); +// 定义一组预定义的颜色数组,用于在各种场景中轻松引用这些颜色 +// 这些颜色包括从白色到黑色的不同灰度,以及一些鲜艳的颜色,格式有十六进制、RGB、RGBA、HSV、HSL等 export const predefine_colors = ['#fff', '#ddd', '#ccc', '#999', '#666', '#333', '#000', '#ff4500', '#ff8c00', '#ffd700', '#90ee90', '#00ced1', '#c71585', 'rgba(255, 69, 0, 0.68)', 'rgb(255, 120, 0)', 'hsv(51, 100, 98)', 'hsva(120, 40, 94, 0.5)', 'hsl(181, 100%, 37%)', '#1F93FF', '#c7158577']; /** * 判断一个对象是否为空。 @@ -67,7 +71,7 @@ export function gradient_handle(color_list: color_list[], direction: string, is_ if (color_list.length == 1) { container_common_styles += ` ${item.color_percentage || 0}%, ${item.color} 100%`; } else { - if (typeof item.color_percentage === "number") { + if (typeof item.color_percentage === 'number') { if (index == color_list.length - 1) { container_common_styles += ` ${item.color_percentage}%`; } else { @@ -332,10 +336,11 @@ export const tabs_style = (color: string, style: string | number | boolean | und * @returns {Promise} 返回一个Promise,解析为包含资源URL的字符串 */ export const online_url = async (directory: string) => { + const attachemnt_host = common.config.attachment_host; if (import.meta.env.VITE_APP_BASE_API == '/dev-api') { let temp_data = await import(import.meta.env.VITE_APP_BASE_API == '/dev-api' ? '../../temp.d' : '../../temp_pro.d'); return temp_data.default.temp_attachment_host + directory; } else { - return get_cookie('attachment_host') + directory; + return attachemnt_host + directory; } };