Commit e7f4a57c225a1835a8e59bc19309eef9afe91b60

Authored by xp.Huang
2 parents 4636dcb9 a00fc81c

Merge branch 'local_dev_ft' into 'main'

pref:优化部分问题

See merge request yunteng/thingskit-front!475
... ... @@ -182,12 +182,16 @@ export const formSchemas: FormSchema[] = [
182 182 componentProps: {
183 183 placeholder: '如:关',
184 184 },
  185 + defaultValue: '关',
185 186 ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL,
186 187 dynamicRules: ({ model }) => {
187 188 const close = model[FormField.BOOL_CLOSE];
188 189 const open = model[FormField.BOOL_OPEN];
189 190 return [
190 191 {
  192 + required: true,
  193 + },
  194 + {
191 195 validator() {
192 196 if (open === close) return Promise.reject('布尔值不能相同');
193 197 return Promise.resolve();
... ... @@ -207,12 +211,16 @@ export const formSchemas: FormSchema[] = [
207 211 componentProps: {
208 212 placeholder: '如:开',
209 213 },
  214 + defaultValue: '开',
210 215 ifShow: ({ values }) => values[FormField.TYPE] === DataTypeEnum.IS_BOOL,
211 216 dynamicRules: ({ model }) => {
212 217 const close = model[FormField.BOOL_CLOSE];
213 218 const open = model[FormField.BOOL_OPEN];
214 219 return [
215 220 {
  221 + required: true,
  222 + },
  223 + {
216 224 validator() {
217 225 if (open === close) return Promise.reject('布尔值不能相同');
218 226 return Promise.resolve();
... ...
... ... @@ -80,7 +80,10 @@
80 80 // import { useUserStore } from '/@/store/modules/user';
81 81 import { getPlatForm } from '/@/api/oem/index';
82 82 import defaultShowLogoImg from '/@/assets/svg/login-bg.svg';
  83 + import defaultShowLogoDarkImg from '/@/assets/svg/login-bg-dark.svg';
83 84 import { useTitle } from '@vueuse/core';
  85 + import { createLocalStorage } from '/@/utils/cache';
  86 + // import {usePlatform} from '/@/views/system/customize/hook/usePlatformInfo'
84 87
85 88 defineProps({
86 89 sessionTimeout: {
... ... @@ -91,8 +94,14 @@
91 94 const defaultTitle = ref('');
92 95 const defaultLogo = ref('');
93 96 const logoUrl = ref('');
  97 + // const userStore = useUserStore();
  98 + const storage = createLocalStorage();
  99 +
94 100 onMounted(async () => {
95   - const res = await getPlatForm();
  101 + let res = storage.get('platformInfo');
  102 + if (res === '' || res === null) {
  103 + res = await getPlatForm();
  104 + }
96 105 logoUrl.value = res?.background;
97 106 defaultTitle.value = res?.name || title;
98 107 defaultLogo.value = res?.logo;
... ... @@ -100,13 +109,38 @@
100 109 document.createElement('link')) as HTMLLinkElement;
101 110 link.type = 'image/x-icon';
102 111 link.rel = 'shortcut icon';
103   - link.href = res.icon ?? '/favicon.ico';
  112 + link.href = res?.icon ?? '/favicon.ico';
104 113 document.getElementsByTagName('head')[0].appendChild(link);
  114 + let defaultLogoBg = document.createElement('style');
  115 + let defaultLogoDarkBg = document.createElement('style');
105 116 if (logoUrl.value !== undefined) {
  117 + //企业自定义
106 118 ifCustom.value = false;
  119 + //默认图片
  120 + defaultLogoBg.innerHTML = `.vben-login::before{
  121 + background-image:url("");
  122 + position:absolute;
  123 + }`;
  124 + //切换黑暗模式图片
  125 + defaultLogoDarkBg.innerHTML = `html[data-theme='dark'] .vben-login::before{
  126 + background-image:url("");
  127 + position:absolute;
  128 + }`;
107 129 } else {
108 130 logoUrl.value = 'url(' + defaultShowLogoImg + ')';
  131 + //默认图片
  132 + defaultLogoBg.innerHTML = `.vben-login::before{
  133 + background-image:url(${defaultShowLogoImg});
  134 + position:absolute;
  135 + }`;
  136 + //切换黑暗模式图片
  137 + defaultLogoDarkBg.innerHTML = `html[data-theme='dark'] .vben-login::before{
  138 + background-image:url(${defaultShowLogoDarkImg});
  139 + position:absolute;
  140 + }`;
109 141 }
  142 + document.head.appendChild(defaultLogoBg);
  143 + document.head.appendChild(defaultLogoDarkBg);
110 144 });
111 145
112 146 // const userStore = useUserStore();
... ... @@ -200,9 +234,8 @@
200 234 width: 100%;
201 235 height: 100%;
202 236 margin-left: -48%;
203   - background-image: v-bind(logourl);
204   - // background-image: url(/@/assets/svg/login-bg.svg);
205 237 background-position: 100%;
  238 + // background-image: url(/@/assets/svg/login-bg.svg);
206 239 background-repeat: no-repeat;
207 240 background-size: auto 100%;
208 241 content: '';
... ...
... ... @@ -106,17 +106,20 @@ export const schemas: FormSchema[] = [
106 106 },
107 107 {
108 108 field: 'nameCountry',
109   - component: 'ApiSelect',
  109 + component: 'Select',
110 110 label: '国家/地区',
111 111 colProps: {
112 112 span: 24,
113 113 },
  114 + // componentProps: {
  115 + // api: getAreaList,
  116 + // params: { parentId: 0 },
  117 + // labelField: 'name',
  118 + // valueField: 'code',
  119 + // placeholder: '国家/地区',
  120 + // },
114 121 componentProps: {
115   - api: getAreaList,
116   - params: { parentId: 0 },
117   - labelField: 'name',
118   - valueField: 'code',
119   - placeholder: '国家/地区',
  122 + options: [{ label: '中国', value: 1 }],
120 123 },
121 124 },
122 125 {
... ...
1 1 import { getPlatForm } from '/@/api/oem';
  2 +import { createLocalStorage } from '/@/utils/cache';
2 3
3 4 enum DefaultPlatform {
4 5 LOGO = '/resource/img/logo.png',
... ... @@ -8,6 +9,16 @@ enum DefaultPlatform {
8 9
9 10 export const usePlatform = async () => {
10 11 const platformInfo = await getPlatForm();
  12 + const storage = createLocalStorage();
  13 + if (
  14 + platformInfo === '' ||
  15 + platformInfo === null ||
  16 + Object.getOwnPropertyNames(platformInfo).length === 0
  17 + ) {
  18 + storage.set('platformInfo', 1234);
  19 + } else {
  20 + storage.set('platformInfo', platformInfo);
  21 + }
11 22
12 23 const createLoadingEffect = () => {
13 24 const wrap = document.createElement('div');
... ...