Commit e18b63989384c5900627da00d0d9f448221d610b

Authored by sqy
1 parent 3443f055

'oem暂存'

... ... @@ -5,7 +5,7 @@
5 5 <!-- TODO: appLogo -->
6 6 <template>
7 7 <div class="anticon" :class="getAppLogoClass" @click="goHome">
8   - <img :src="getLogoUrl" />
  8 + <img src="../../../assets/images/logo.png" />
9 9 <div class="ml-2 md:opacity-100" :class="getTitleClass" v-show="showTitle">
10 10 {{ title }}
11 11 </div>
... ... @@ -19,7 +19,6 @@
19 19 import { useDesign } from '/@/hooks/web/useDesign';
20 20 import { PageEnum } from '/@/enums/pageEnum';
21 21 import { useUserStore } from '/@/store/modules/user';
22   - import { createLocalStorage } from '/@/utils/cache/index';
23 22 const props = defineProps({
24 23 /**
25 24 * The theme of the current parent component
... ... @@ -46,15 +45,6 @@
46 45 props.theme,
47 46 { 'collapsed-show-title': unref(getCollapsedShowTitle) },
48 47 ]);
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   -
58 48 const getTitleClass = computed(() => [
59 49 `${prefixCls}__title`,
60 50 {
... ...
... ... @@ -27,6 +27,7 @@ import { RouteRecordRaw } from 'vue-router';
27 27 import { PAGE_NOT_FOUND_ROUTE } from '/@/router/routes/basic';
28 28
29 29 interface UserState {
  30 + platInfo: any;
30 31 userInfo: Nullable<UserInfo>;
31 32 token?: string;
32 33 roleList: RoleEnum[];
... ... @@ -39,6 +40,8 @@ interface UserState {
39 40 export const useUserStore = defineStore({
40 41 id: 'app-user',
41 42 state: (): UserState => ({
  43 + //平台信息
  44 + platInfo: null,
42 45 // user info
43 46 userInfo: null,
44 47 // token
... ... @@ -52,7 +55,11 @@ export const useUserStore = defineStore({
52 55 // Last fetch time
53 56 lastUpdateTime: 0,
54 57 }),
  58 +
55 59 getters: {
  60 + getPlatInfo(): any {
  61 + return this.platInfo;
  62 + },
56 63 getUserInfo(): UserInfo {
57 64 return this.userInfo || getAuthCache<UserInfo>(USER_INFO_KEY) || {};
58 65 },
... ... @@ -73,6 +80,9 @@ export const useUserStore = defineStore({
73 80 },
74 81 },
75 82 actions: {
  83 + setPlatInfo(platInfo: any) {
  84 + this.platInfo = platInfo;
  85 + },
76 86 storeToken(jwtToken: string, refreshToken: string) {
77 87 this.jwtToken = jwtToken;
78 88 this.refreshToken = refreshToken;
... ...
... ... @@ -60,7 +60,7 @@
60 60 <script lang="ts" setup>
61 61 import { reactive, ref, toRaw, unref, computed } from 'vue';
62 62
63   - import { Checkbox, Form, Input, Row, Col, Button, Divider } from 'ant-design-vue';
  63 + import { Form, Input, Row, Col, Button } from 'ant-design-vue';
64 64 import LoginFormTitle from './LoginFormTitle.vue';
65 65
66 66 import { useI18n } from '/@/hooks/web/useI18n';
... ... @@ -69,7 +69,8 @@
69 69 import { useUserStore } from '/@/store/modules/user';
70 70 import { LoginStateEnum, useLoginState, useFormRules, useFormValid } from './useLogin';
71 71 import { useDesign } from '/@/hooks/web/useDesign';
72   - //import { onKeyStroke } from '@vueuse/core';
  72 + import { getPlatForm } from '/@/api/oem/index';
  73 + import { createLocalStorage } from '/@/utils/cache/index';
73 74
74 75 const ACol = Col;
75 76 const ARow = Row;
... ... @@ -85,7 +86,6 @@
85 86
86 87 const formRef = ref();
87 88 const loading = ref(false);
88   - const rememberMe = ref(false);
89 89
90 90 const formData = reactive({
91 91 account: 'sysadmin',
... ... @@ -116,8 +116,11 @@
116 116 description: `${t('sys.login.loginSuccessDesc')}: ${userInfo.realName}`,
117 117 duration: 3,
118 118 });
  119 + const res = await getPlatForm();
  120 + const storage = createLocalStorage();
  121 + storage.set('platformInfo', res);
119 122 }
120   - } catch (error) {
  123 + } catch (error: any) {
121 124 createErrorModal({
122 125 title: t('sys.api.loginFailed'),
123 126 content:
... ...
... ... @@ -96,6 +96,7 @@
96 96 import { logoUpload, iconUpload, bgUpload, getPlatForm, updatePlatForm } from '/@/api/oem/index';
97 97 import { PlusOutlined } from '@ant-design/icons-vue';
98 98 import { createLocalStorage } from '/@/utils/cache/index';
  99 +
99 100 export default defineComponent({
100 101 components: {
101 102 BasicForm,
... ... @@ -208,7 +209,15 @@
208 209
209 210 // 保存一份数据到本地缓存中.
210 211 const storage = createLocalStorage();
211   - storage.set('PlatformInfo', fieldValue);
  212 + storage.set('platformInfo', fieldValue);
  213 + //保存到store
  214 + // 设置icon
  215 + let link = (document.querySelector("link[rel*='icon']") ||
  216 + document.createElement('link')) as HTMLLinkElement;
  217 + link.type = 'image/x-icon';
  218 + link.rel = 'shortcut icon';
  219 + link.href = fieldValue.icon;
  220 + document.getElementsByTagName('head')[0].appendChild(link);
212 221 } catch (e) {
213 222 createMessage.error('保存信息失败');
214 223 }
... ...
... ... @@ -61,6 +61,7 @@
61 61 }
62 62 };
63 63
  64 + // 地区显示回显和数据联动
64 65 async function updateCityData(codeProv: string, codeCity: string, codeCoun: string) {
65 66 const nameCity = await getTownChild('codeProv', codeProv);
66 67 const nameCoun = await getTownChild('codeCity', codeCity);
... ... @@ -100,7 +101,6 @@
100 101 });
101 102 }
102 103 let nameTown = await getTownChild('codeCoun', value);
103   - console.log(111);
104 104 nameTown.forEach((item) => {
105 105 item.label = item.nameTown;
106 106 item.value = item.codeTown;
... ...