1.静态地址优化

v1.0.0
sws 2024-10-23 17:06:41 +08:00
parent 50f65db813
commit c6c3b3a2be
3 changed files with 28 additions and 7 deletions

View File

@ -139,7 +139,7 @@
</div>
</template>
<script setup lang="ts">
import { common_img_computer, common_styles_computer, gradient_computer, online_url } from '@/utils';
import { common_img_computer, common_styles_computer, gradient_computer } from '@/utils';
import { isEmpty, cloneDeep } from 'lodash';
import CouponAPI from '@/api/coupon';
import { commonStore } from '@/store';

View File

@ -1,3 +1,4 @@
import CommonAPI from '@/api/common';
// 定义一组预定义的颜色数组,用于在各种场景中轻松引用这些颜色
// 这些颜色包括从白色到黑色的不同灰度以及一些鲜艳的颜色格式有十六进制、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'];
@ -414,6 +415,14 @@ export const online_url = async (directory: string = '') => {
} else {
// let attachemnt_host = common.config.attachment_host;
let attachemnt_host = get_cookie('attachment_host') && get_cookie('attachment_host') !== 'null' && get_cookie('attachment_host') !== null ? get_cookie('attachment_host') : '';
if (attachemnt_host.length <= 0) {
await CommonAPI.getInit().then((res: any) => {
set_cookie('attachment_host', res.data.config.attachment_host);
attachemnt_host = res.data.config.attachment_host;
// 将数据存到localStorage中
localStorage.setItem('diy_init_common', res.data);
});
}
return attachemnt_host + directory;
}
};

View File

@ -18,7 +18,7 @@
</template>
<script setup lang="ts">
import { is_obj, set_cookie } from '@/utils';
import { is_obj, set_cookie, get_cookie } from '@/utils';
import { Settings, AppMain } from './components/index';
import defaultSettings from './components/main/index';
import defaultConfigSetting from '@/config/setting';
@ -182,11 +182,23 @@ const default_merge = (data: any, key: string) => {
//
const common_init = () => {
CommonAPI.getInit().then((res: any) => {
common_store.set_common(res.data);
set_cookie('attachment_host', res.data.config.attachment_host);
init();
});
if (get_cookie('attachment_host') || get_cookie('attachment_host') !== 'null' || get_cookie('attachment_host') !== null) {
CommonAPI.getInit().then((res: any) => {
common_store.set_common(res.data);
set_cookie('attachment_host', res.data.config.attachment_host);
init();
});
} else {
// localStorage
// localStorage
if (localStorage.getItem('diy_init_common')) {
const data = JSON.parse(localStorage.getItem('diy_init_common') || '');
common_store.set_common(data);
//
localStorage.removeItem('diy_init_common');
init();
}
}
};
//
const loading = ref(true);