Commit 3443f0554edbd9a2ae0b216875c3a3ba09181379
Merge branch 'sqy_dev' into 'main'
oem内容定制修改中 See merge request huang/yun-teng-iot-front!17
Showing
3 changed files
with
29 additions
and
16 deletions
... | ... | @@ -2,9 +2,10 @@ |
2 | 2 | * @Author: Vben |
3 | 3 | * @Description: logo component |
4 | 4 | --> |
5 | +<!-- TODO: appLogo --> | |
5 | 6 | <template> |
6 | 7 | <div class="anticon" :class="getAppLogoClass" @click="goHome"> |
7 | - <img src="../../../assets/images/logo.png" /> | |
8 | + <img :src="getLogoUrl" /> | |
8 | 9 | <div class="ml-2 md:opacity-100" :class="getTitleClass" v-show="showTitle"> |
9 | 10 | {{ title }} |
10 | 11 | </div> |
... | ... | @@ -18,7 +19,7 @@ |
18 | 19 | import { useDesign } from '/@/hooks/web/useDesign'; |
19 | 20 | import { PageEnum } from '/@/enums/pageEnum'; |
20 | 21 | import { useUserStore } from '/@/store/modules/user'; |
21 | - | |
22 | + import { createLocalStorage } from '/@/utils/cache/index'; | |
22 | 23 | const props = defineProps({ |
23 | 24 | /** |
24 | 25 | * The theme of the current parent component |
... | ... | @@ -46,6 +47,14 @@ |
46 | 47 | { 'collapsed-show-title': unref(getCollapsedShowTitle) }, |
47 | 48 | ]); |
48 | 49 | |
50 | + const storage = createLocalStorage(); | |
51 | + // 获取AppLogo | |
52 | + const getLogoUrl = computed(() => { | |
53 | + return storage.get('platformInfo') | |
54 | + ? storage.get('platformInfo').logo | |
55 | + : '/src/assets/images/logo.png'; | |
56 | + }); | |
57 | + | |
49 | 58 | const getTitleClass = computed(() => [ |
50 | 59 | `${prefixCls}__title`, |
51 | 60 | { | ... | ... |
... | ... | @@ -35,8 +35,8 @@ |
35 | 35 | :before-upload="beforeUploadIconPic" |
36 | 36 | > |
37 | 37 | <div v-if="iconPic"> |
38 | - <img :src="iconPic" /> | |
39 | - <div style="background-color: #ccc">重新上传</div> | |
38 | + <img :src="iconPic" class="m-auto" /> | |
39 | + <div style="background-color: #ccc; margin-top: 20px">重新上传</div> | |
40 | 40 | </div> |
41 | 41 | <div v-else> |
42 | 42 | <PlusOutlined style="font-size: 30px" /> |
... | ... | @@ -95,6 +95,7 @@ |
95 | 95 | import type { FileItem } from '/@/components/Upload/src/typing'; |
96 | 96 | import { logoUpload, iconUpload, bgUpload, getPlatForm, updatePlatForm } from '/@/api/oem/index'; |
97 | 97 | import { PlusOutlined } from '@ant-design/icons-vue'; |
98 | + import { createLocalStorage } from '/@/utils/cache/index'; | |
98 | 99 | export default defineComponent({ |
99 | 100 | components: { |
100 | 101 | BasicForm, |
... | ... | @@ -146,7 +147,7 @@ |
146 | 147 | } |
147 | 148 | return isJpgOrPng && isLt2M; |
148 | 149 | }; |
149 | - | |
150 | + // Icon上传 | |
150 | 151 | async function customUploadIconPic({ file }) { |
151 | 152 | if (beforeUploadIconPic(file)) { |
152 | 153 | const formData = new FormData(); |
... | ... | @@ -158,9 +159,9 @@ |
158 | 159 | } |
159 | 160 | } |
160 | 161 | const beforeUploadIconPic = (file: FileItem) => { |
161 | - const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'; | |
162 | + const isJpgOrPng = file.type === 'image/x-icon'; | |
162 | 163 | if (!isJpgOrPng) { |
163 | - createMessage.error('只能上传图片文件!'); | |
164 | + createMessage.error('只能上传.icon图片文件!'); | |
164 | 165 | } |
165 | 166 | const isLt2M = (file.size as number) / 1024 < 500; |
166 | 167 | if (!isLt2M) { |
... | ... | @@ -198,12 +199,16 @@ |
198 | 199 | compState.value.loading = true; |
199 | 200 | await updatePlatForm({ |
200 | 201 | ...fieldValue, |
201 | - background: unref(bgPic), | |
202 | - icon: unref(bgPic), | |
203 | 202 | logo: unref(logoPic), |
203 | + icon: unref(iconPic), | |
204 | + background: unref(bgPic), | |
204 | 205 | }); |
205 | 206 | compState.value.loading = false; |
206 | 207 | createMessage.success('保存信息成功'); |
208 | + | |
209 | + // 保存一份数据到本地缓存中. | |
210 | + const storage = createLocalStorage(); | |
211 | + storage.set('PlatformInfo', fieldValue); | |
207 | 212 | } catch (e) { |
208 | 213 | createMessage.error('保存信息失败'); |
209 | 214 | } | ... | ... |
... | ... | @@ -61,13 +61,6 @@ |
61 | 61 | } |
62 | 62 | }; |
63 | 63 | |
64 | - onMounted(async () => { | |
65 | - const res = await getEnterPriseDetail(); | |
66 | - console.log(res); | |
67 | - updateCityData(res.codeProv, res.codeCity, res.codeCoun); | |
68 | - setFieldsValue(res); | |
69 | - }); | |
70 | - | |
71 | 64 | async function updateCityData(codeProv: string, codeCity: string, codeCoun: string) { |
72 | 65 | const nameCity = await getTownChild('codeProv', codeProv); |
73 | 66 | const nameCoun = await getTownChild('codeCity', codeCity); |
... | ... | @@ -182,6 +175,12 @@ |
182 | 175 | }); |
183 | 176 | } |
184 | 177 | |
178 | + onMounted(async () => { | |
179 | + const res = await getEnterPriseDetail(); | |
180 | + updateCityData(res.codeProv, res.codeCity, res.codeCoun); | |
181 | + setFieldsValue(res); | |
182 | + }); | |
183 | + | |
185 | 184 | return { |
186 | 185 | registerForm, |
187 | 186 | compState, | ... | ... |