@utogether/udp-core 2.0.0-beta.25 → 2.0.0-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/{403-QwBKrRZE.js → 403-D6Wb3JJh.js} +1 -1
  2. package/dist/{404-Cr7MbzNV.js → 404-B_HNbPNV.js} +1 -1
  3. package/dist/{500-B7kCOeIA.js → 500-BMemTTy1.js} +1 -1
  4. package/dist/{AuthorityInfo-Dwml2K4S.js → AuthorityInfo-6wHxwiFM.js} +1 -1
  5. package/dist/{AuthorityPanel-DzPhsPpa.js → AuthorityPanel-OqF_DvXA.js} +1 -1
  6. package/dist/{Company-BhOlvl7Q.js → Company-BLXSfow0.js} +1 -1
  7. package/dist/{CompanyPanel-ByhY5-Sq.js → CompanyPanel-B4kRZ5Cg.js} +1 -1
  8. package/dist/{Department-QvngN63N.js → Department-oFhsa7cd.js} +1 -1
  9. package/dist/{DepartmentPanel-DntGycxr.js → DepartmentPanel-B1UGpu-r.js} +2 -2
  10. package/dist/DepartmentPanel-BL58AdoT.js +2 -0
  11. package/dist/{DesignPanel-BMN4DZ0R.js → DesignPanel-DmkFVw1N.js} +2 -2
  12. package/dist/{DictView-ERFqZ5VD.js → DictView-CC5yMzOq.js} +1 -1
  13. package/dist/{Preview-CVZdnHB1.js → Preview-CAzWxLmP.js} +1 -1
  14. package/dist/{ReportDesign-CjfTyyy_.js → ReportDesign-DwchGG2P.js} +1 -1
  15. package/dist/{ReportQuery-CP-E0Puv.js → ReportQuery-D5jaRJEn.js} +1 -1
  16. package/dist/{ReportQueryFrom-D7SPPAps.js → ReportQueryFrom-CNlmtYey.js} +1 -1
  17. package/dist/{ReportTemplate-DE25zc1f.js → ReportTemplate-CNcTmccs.js} +1 -1
  18. package/dist/{Role-K7v_ZhFE.js → Role-Be8WfdCA.js} +1 -1
  19. package/dist/{RoleAssign-C16fjLaX.js → RoleAssign-CtehGAUf.js} +1 -1
  20. package/dist/{RolePanel-DPCe9k8f.js → RolePanel-CAwITg_q.js} +1 -1
  21. package/dist/{RolePanel-CV-xPlYJ.js → RolePanel-SN0FGFZ7.js} +3 -3
  22. package/dist/{Staff-w2ly4qd0.js → Staff-V2YsNKcj.js} +1 -1
  23. package/dist/{StaffInfo-DPDRpz6F.js → StaffInfo-CKRPW0r4.js} +1 -1
  24. package/dist/{StaffPanel-DI1eTTp9.js → StaffPanel-BxcgMg7u.js} +2 -2
  25. package/dist/{SysUser-BMTX1cJM.js → SysUser-Dxyj5w5m.js} +1 -1
  26. package/dist/{SysUserPanel-xwZdVjdp.js → SysUserPanel-DI6CWcZo.js} +1 -1
  27. package/dist/{SystemMenu-TXhiQZVm.js → SystemMenu-BBHREM8T.js} +2 -2
  28. package/dist/{UserInfo-JQqw8FMT.js → UserInfo-BMVQ0xwE.js} +1 -1
  29. package/dist/{authority-Bi6BGB5B.js → authority-BJFEUdrh.js} +1 -1
  30. package/dist/{childView-CyrcwshT.js → childView-BBjPEraB.js} +1 -1
  31. package/dist/{childView-Bk8OD9bV.js → childView-DNqG2UVm.js} +1 -1
  32. package/dist/core.es.js +5 -5
  33. package/dist/{layoutView-DFUjrqAS.js → layoutView-B6Mx2ERA.js} +237 -237
  34. package/dist/{login-BdCDnuXL.js → login-D_Hjy3Jd.js} +82 -84
  35. package/dist/{lov-view-DkmG4K57.js → lov-view-DM5Nm5tW.js} +1 -1
  36. package/dist/{menuInfo-kp2wNYOp.js → menuInfo-BlOY1KZW.js} +1 -1
  37. package/dist/{su-welcome-JeiovGpe.js → su-welcome-DVD3S_du.js} +4 -4
  38. package/dist/{router-CeluSGiD.js → system-Cm3lyBas.js} +451 -454
  39. package/dist/{udp-core-Dhm-BlAs.js → udp-core-DaQd5CF1.js} +212 -216
  40. package/dist/udp-core.css +1 -1
  41. package/dist/{useDataThemeChange-BCy8JBG7.js → useDataThemeChange-DJ4K3VGp.js} +31 -31
  42. package/dist/{useNav-DY8FkltH.js → useNav-BhOJIdrJ.js} +8 -8
  43. package/package.json +1 -1
  44. package/src/App.vue +5 -0
  45. package/src/components/udp/grid/index.vue +9 -11
  46. package/src/components/udp/utils.ts +420 -414
  47. package/src/main.ts +109 -110
  48. package/src/router/utils.ts +2 -3
  49. package/src/views/login/login-view.vue +297 -301
  50. package/src/views/ulogin/login.vue +3 -32
  51. package/dist/DepartmentPanel-BCXqC39J.js +0 -2
@@ -1,301 +1,297 @@
1
- <template>
2
- <div class="select-none">
3
- <div class="absolute flex justify-center items-center right-5 top-3">
4
- <!-- 主题 -->
5
- <!-- <el-switch
6
- v-model="dataTheme"
7
- inline-prompt
8
- :active-icon="dayIcon"
9
- :inactive-icon="darkIcon"
10
- @change="dataThemeChange"
11
- /> -->
12
- <!-- 国际化 -->
13
- <!-- <el-dropdown v-if="sysConfig['i18nEnabled'] === 'Y'" trigger="click">
14
- <globalization
15
- class="hover:text-primary hover:!bg-[transparent] w-[20px] h-[20px] ml-1.5 cursor-pointer outline-hidden duration-300"
16
- />
17
- <template #dropdown>
18
- <el-dropdown-menu class="translation">
19
- <el-dropdown-item
20
- :style="getDropdownItemStyle(locale, 'zh')"
21
- :class="['dark:text-white!', getDropdownItemClass(locale, 'zh')]"
22
- @click="translationCh"
23
- >
24
- <IconifyIconOffline v-show="locale === 'zh'" class="check-zh" :icon="ri:check-line" />
25
- 简体中文
26
- </el-dropdown-item>
27
- <el-dropdown-item
28
- :style="getDropdownItemStyle(locale, 'en')"
29
- :class="['dark:text-white!', getDropdownItemClass(locale, 'en')]"
30
- @click="translationEn"
31
- >
32
- <span v-show="locale === 'en'" class="check-en">
33
- <IconifyIconOffline :icon="ri:check-line" />
34
- </span>
35
- English
36
- </el-dropdown-item>
37
- </el-dropdown-menu>
38
- </template>
39
- </el-dropdown> -->
40
- </div>
41
- <div class="login-container">
42
- <div class="bg-img" :style="{ backgroundImage: `url(${sysConfig['backgroundImg']}` }" />
43
- <div class="login-box">
44
- <div class="login-form">
45
- <img v-if="sysConfig['logo']" class="login-logo-img" :src="sysConfig['logo']" />
46
- <Motion v-if="sysConfig['title']">
47
- <h2 class="outline-hidden">
48
- <TypeIt :values="[sysConfig['title']]" :cursor="false" :speed="150" />
49
- </h2>
50
- </Motion>
51
-
52
- <el-form ref="ruleFormRef" :model="ruleForm" :rules="loginRules" size="large">
53
- <Motion :delay="100">
54
- <el-form-item
55
- :rules="[{ required: true, message: $t('message.udp.loginUser'), trigger: 'blur' }]"
56
- :label="$t('message.udp.loginUser')"
57
- prop="username"
58
- >
59
- <el-input v-model.trim="ruleForm.username" autofocus clearable :prefix-icon="useRenderIcon(User)" />
60
- </el-form-item>
61
- </Motion>
62
-
63
- <Motion :delay="150">
64
- <el-form-item prop="passWord">
65
- <el-input v-model="ruleForm.passWord" clearable show-password :prefix-icon="useRenderIcon(Lock)" />
66
- </el-form-item>
67
- </Motion>
68
- <Motion :delay="250">
69
- <el-form-item>
70
- <el-button
71
- class="w-full mt-4"
72
- size="default"
73
- type="primary"
74
- :loading="loading"
75
- @click="onLogin(ruleFormRef)"
76
- >
77
- {{ $t('message.udp.login') }}
78
- </el-button>
79
- </el-form-item>
80
- </Motion>
81
- </el-form>
82
- </div>
83
- <div class="fixed text-xs text-gray-500 bottom-4">Copyright ©2021{{ sysConfig['copyright'] }}版权所有</div>
84
- </div>
85
- </div>
86
- </div>
87
- </template>
88
-
89
- <script setup lang="ts">
90
- import { ref, reactive, onMounted, onBeforeMount, onBeforeUnmount } from 'vue';
91
- import { useRouter } from 'vue-router';
92
- import type { FormInstance } from 'element-plus';
93
- import { storageLocal, cookies, successMessage, delay } from '@utogether/utils';
94
- import { toDateString } from 'xe-utils';
95
- import to from 'await-to-js';
96
-
97
- import Motion from './utils/motion';
98
- import { loginRules } from './utils/rule';
99
- import TypeIt from '@/components/SuTypeit';
100
- import { useRenderIcon } from '@/components/ReIcon/src/hooks';
101
- // import { useTranslationLang } from '@/layout/hooks/useTranslationLang';
102
- import { useLayout } from '@/layout/hooks/useLayout';
103
- // import { useNav } from '@/layout/hooks/useNav';
104
- // import { useDataThemeChange } from '@/layout/hooks/useDataThemeChange';
105
- import { useSystemStoreHook } from '@/store/modules/system';
106
-
107
- import { getServiceApi } from '../../api';
108
- import { initDict } from '../../api/user';
109
- import { getPlatform, getBrower } from '@/utils/browers';
110
- // import dayIcon from '@/assets/svg/day.svg?component';
111
- // import darkIcon from '@/assets/svg/dark.svg?component';
112
- // import globalization from '@/assets/svg/globalization.svg?component';
113
- import Lock from '@iconify-icons/ri/lock-fill';
114
- import User from '@iconify-icons/ri/user-3-fill';
115
-
116
- defineOptions({ name: 'LoginView' });
117
-
118
- interface IRSAPublic {
119
- publicKeyExponent: string;
120
- publicKeyModulus: string;
121
- requestKey: string;
122
- }
123
-
124
- const router = useRouter();
125
-
126
- // const bgStyle = ref({});
127
- const sysConfig = ref({});
128
- const loading = ref(false);
129
- const ruleFormRef = ref<FormInstance>();
130
-
131
- const serviceApi = getServiceApi();
132
-
133
- const { initStorage } = useLayout();
134
- initStorage();
135
- // const { dataTheme, dataThemeChange } = useDataThemeChange();
136
- // dataThemeChange();
137
- // const { getDropdownItemStyle, getDropdownItemClass } = useNav();
138
- // const { locale, translationCh, translationEn } = useTranslationLang();
139
-
140
- const ruleForm = reactive({
141
- username: '',
142
- passWord: ''
143
- });
144
-
145
- const publicRSA: IRSAPublic = reactive({
146
- publicKeyExponent: '10001',
147
- publicKeyModulus:
148
- 'a12708ab26367e1711bd767f6bb1f29afbd85380185723d7b492230e2567c95cf5718eca745da0643400ca619fbeec892df61abe1f71ad3b822d076ed831080c53782edf8c0627ee95c57e2bee12fe55da2b3cadec59947a75ccccbbf36fb3b781c93b4bf51489789f1c0849f9023a16ec70bef41a504785e1082b6f13588e29',
149
- requestKey: ''
150
- });
151
-
152
- const onLogin = async (formEl: FormInstance | undefined) => {
153
- if (!formEl) return;
154
- await formEl.validate(valid => {
155
- if (valid) {
156
- loading.value = true;
157
- const { username, passWord } = ruleForm;
158
-
159
- // @ts-ignore
160
- setMaxDigits(200);
161
- // @ts-ignore
162
- const rsakeypair = new RSAKeyPair(publicRSA.publicKeyExponent, '', publicRSA.publicKeyModulus);
163
- // @ts-ignore
164
- const password = encryptedString(rsakeypair, passWord.split('').reverse().join(''));
165
- const param = {
166
- username,
167
- password,
168
- requestKey: publicRSA.requestKey,
169
- domain: window.location.origin
170
- };
171
- serviceApi
172
- .post('/uath/login', param)
173
- .then(async (data: IResponseData) => {
174
- successMessage(`👏 恭喜,成功登录${sysConfig.value['title']}!!!🎉`);
175
- useSystemStoreHook().setSessionKey(data);
176
- cacheToken(data);
177
- cookies.set('loginer', username);
178
- if (!storageLocal.getItem('kLov')) {
179
- initDict().then(res => useSystemStoreHook().setDict(res));
180
- }
181
- await delay(300);
182
- router.push('/');
183
- await insertLoginInfo(username);
184
- })
185
- .finally(() => {
186
- loading.value = false;
187
- });
188
- }
189
- });
190
- };
191
-
192
- /**
193
- * @description: 缓存token
194
- * @param {*} token token数据
195
- * @return {*}
196
- */
197
- const cacheToken = token => {
198
- const { access_token, expires_in, refresh_token } = token;
199
- const cache = {
200
- accessToken: access_token,
201
- refreshToken: refresh_token,
202
- expires: Date.now() + expires_in * 1000
203
- };
204
- const kTOKENKEY = 'authorized-token';
205
-
206
- cookies.set('kCookies_token', token.access_token);
207
- const dataString = JSON.stringify(cache);
208
- expires_in > 0 ? cookies.set(kTOKENKEY, dataString) : cookies.set(kTOKENKEY, dataString);
209
- };
210
-
211
- const insertLoginInfo = username => {
212
- const userAgent = navigator.userAgent.toLowerCase();
213
- const { browser, browserVersion } = getBrower(userAgent);
214
- const obj = {
215
- userName: username,
216
- loginTime: toDateString(new Date()),
217
- browser,
218
- browserVersion,
219
- operatingSystem: getPlatform(userAgent)
220
- };
221
- serviceApi.post('/upfm/v1/userMonitor', obj);
222
- };
223
-
224
- /** 使用公共函数,避免`removeEventListener`失效 */
225
- function onkeypress({ code }: KeyboardEvent) {
226
- if (['Enter', 'NumpadEnter'].includes(code)) {
227
- onLogin(ruleFormRef.value);
228
- }
229
- }
230
-
231
- onMounted(() => {
232
- window.document.addEventListener('keypress', onkeypress);
233
- });
234
-
235
- onBeforeUnmount(() => {
236
- window.document.removeEventListener('keypress', onkeypress);
237
- });
238
- /**
239
- * @description: 获取系统配置
240
- * @return {*}
241
- */
242
- const getSysConfig = async () => {
243
- const [err, data]: [Error, any] = await to(serviceApi.get('/upfm/v1/sysConfig', {}));
244
- if (!err) {
245
- const config = {};
246
- data.list?.forEach(item => {
247
- config[item.configCode] = item.configValue;
248
- if (item.fileName) {
249
- config[item.configCode] = window.location.origin + '/ufil' + item.configValue;
250
- }
251
- });
252
- const env = process.env.NODE_ENV;
253
- const title = data.list?.find(f => f.configCode === `${env}Title` || f.configCode === 'title')?.configValue;
254
- config['title'] = title || 'U-DP';
255
- sysConfig.value = config;
256
- setFavicon();
257
- storageLocal.setItem('kSysConfig', config);
258
- }
259
- };
260
-
261
- const setFavicon = () => {
262
- let favicon = document.querySelector('link[rel="icon"]') as HTMLElement;
263
- // console.log('app', favicon)
264
- if (favicon !== null) {
265
- favicon['href'] = sysConfig.value['favicon'] || '../../../public/favicon.ico';
266
- } else {
267
- favicon = document.createElement('link');
268
- favicon['rel'] = 'icon';
269
- favicon['href'] = sysConfig.value['favicon'] || '../../../public/favicon.ico';
270
- document.head.appendChild(favicon);
271
- }
272
- };
273
-
274
- onBeforeMount(() => {
275
- getSysConfig();
276
- });
277
- </script>
278
-
279
- <style scoped>
280
- @import url('@/style/login2.css');
281
-
282
- /* .translation {
283
- ::v-deep(.el-dropdown-menu__item) {
284
- padding: 5px 40px;
285
- }
286
- } */
287
-
288
- .check-zh {
289
- position: absolute;
290
- left: 20px;
291
- }
292
-
293
- .check-en {
294
- position: absolute;
295
- left: 20px;
296
- }
297
-
298
- :deep(.el-input-group__append, .el-input-group__prepend) {
299
- padding: 0;
300
- }
301
- </style>
1
+ <template>
2
+ <div class="select-none">
3
+ <div class="absolute flex justify-center items-center right-5 top-3">
4
+ <!-- 主题 -->
5
+ <!-- <el-switch
6
+ v-model="dataTheme"
7
+ inline-prompt
8
+ :active-icon="dayIcon"
9
+ :inactive-icon="darkIcon"
10
+ @change="dataThemeChange"
11
+ /> -->
12
+ <!-- 国际化 -->
13
+ <!-- <el-dropdown v-if="sysConfig['i18nEnabled'] === 'Y'" trigger="click">
14
+ <globalization
15
+ class="hover:text-primary hover:!bg-[transparent] w-[20px] h-[20px] ml-1.5 cursor-pointer outline-hidden duration-300"
16
+ />
17
+ <template #dropdown>
18
+ <el-dropdown-menu class="translation">
19
+ <el-dropdown-item
20
+ :style="getDropdownItemStyle(locale, 'zh')"
21
+ :class="['dark:text-white!', getDropdownItemClass(locale, 'zh')]"
22
+ @click="translationCh"
23
+ >
24
+ <IconifyIconOffline v-show="locale === 'zh'" class="check-zh" :icon="ri:check-line" />
25
+ 简体中文
26
+ </el-dropdown-item>
27
+ <el-dropdown-item
28
+ :style="getDropdownItemStyle(locale, 'en')"
29
+ :class="['dark:text-white!', getDropdownItemClass(locale, 'en')]"
30
+ @click="translationEn"
31
+ >
32
+ <span v-show="locale === 'en'" class="check-en">
33
+ <IconifyIconOffline :icon="ri:check-line" />
34
+ </span>
35
+ English
36
+ </el-dropdown-item>
37
+ </el-dropdown-menu>
38
+ </template>
39
+ </el-dropdown> -->
40
+ </div>
41
+ <div class="login-container">
42
+ <div class="bg-img" :style="{ backgroundImage: `url(${sysConfig['backgroundImg']}` }" />
43
+ <div class="login-box">
44
+ <div class="login-form">
45
+ <img v-if="sysConfig['logo']" class="login-logo-img" :src="sysConfig['logo']" />
46
+ <Motion v-if="sysConfig['title']">
47
+ <h2 class="outline-hidden">
48
+ <TypeIt :values="[sysConfig['title']]" :cursor="false" :speed="150" />
49
+ </h2>
50
+ </Motion>
51
+
52
+ <el-form ref="ruleFormRef" :model="ruleForm" :rules="loginRules" size="large">
53
+ <Motion :delay="100">
54
+ <el-form-item
55
+ :rules="[{ required: true, message: $t('message.udp.loginUser'), trigger: 'blur' }]"
56
+ :label="$t('message.udp.loginUser')"
57
+ prop="username"
58
+ >
59
+ <el-input v-model.trim="ruleForm.username" autofocus clearable :prefix-icon="useRenderIcon(User)" />
60
+ </el-form-item>
61
+ </Motion>
62
+
63
+ <Motion :delay="150">
64
+ <el-form-item prop="passWord">
65
+ <el-input v-model="ruleForm.passWord" clearable show-password :prefix-icon="useRenderIcon(Lock)" />
66
+ </el-form-item>
67
+ </Motion>
68
+ <Motion :delay="250">
69
+ <el-form-item>
70
+ <el-button
71
+ class="w-full mt-4"
72
+ size="default"
73
+ type="primary"
74
+ :loading="loading"
75
+ @click="onLogin(ruleFormRef)"
76
+ >
77
+ {{ $t('message.udp.login') }}
78
+ </el-button>
79
+ </el-form-item>
80
+ </Motion>
81
+ </el-form>
82
+ </div>
83
+ <div class="fixed text-xs text-gray-500 bottom-4">Copyright ©2021{{ sysConfig['copyright'] }}版权所有</div>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ </template>
88
+
89
+ <script setup lang="ts">
90
+ import { ref, reactive, onMounted, onBeforeMount, onBeforeUnmount } from 'vue';
91
+ import { useRouter } from 'vue-router';
92
+ import type { FormInstance } from 'element-plus';
93
+ import { storageLocal, cookies, successMessage, delay } from '@utogether/utils';
94
+ import { toDateString } from 'xe-utils';
95
+ import to from 'await-to-js';
96
+
97
+ import Motion from './utils/motion';
98
+ import { loginRules } from './utils/rule';
99
+ import TypeIt from '@/components/SuTypeit';
100
+ import { useRenderIcon } from '@/components/ReIcon/src/hooks';
101
+ // import { useTranslationLang } from '@/layout/hooks/useTranslationLang';
102
+ import { useLayout } from '@/layout/hooks/useLayout';
103
+ // import { useNav } from '@/layout/hooks/useNav';
104
+ // import { useDataThemeChange } from '@/layout/hooks/useDataThemeChange';
105
+ import { useSystemStoreHook } from '@/store/modules/system';
106
+
107
+ import { getServiceApi } from '../../api';
108
+ import { getPlatform, getBrower } from '@/utils/browers';
109
+ // import dayIcon from '@/assets/svg/day.svg?component';
110
+ // import darkIcon from '@/assets/svg/dark.svg?component';
111
+ // import globalization from '@/assets/svg/globalization.svg?component';
112
+ import Lock from '@iconify-icons/ri/lock-fill';
113
+ import User from '@iconify-icons/ri/user-3-fill';
114
+
115
+ defineOptions({ name: 'LoginView' });
116
+
117
+ interface IRSAPublic {
118
+ publicKeyExponent: string;
119
+ publicKeyModulus: string;
120
+ requestKey: string;
121
+ }
122
+
123
+ const router = useRouter();
124
+
125
+ // const bgStyle = ref({});
126
+ const sysConfig = ref({});
127
+ const loading = ref(false);
128
+ const ruleFormRef = ref<FormInstance>();
129
+
130
+ const serviceApi = getServiceApi();
131
+
132
+ const { initStorage } = useLayout();
133
+ initStorage();
134
+ // const { dataTheme, dataThemeChange } = useDataThemeChange();
135
+ // dataThemeChange();
136
+ // const { getDropdownItemStyle, getDropdownItemClass } = useNav();
137
+ // const { locale, translationCh, translationEn } = useTranslationLang();
138
+
139
+ const ruleForm = reactive({
140
+ username: '',
141
+ passWord: ''
142
+ });
143
+
144
+ const publicRSA: IRSAPublic = reactive({
145
+ publicKeyExponent: '10001',
146
+ publicKeyModulus:
147
+ 'a12708ab26367e1711bd767f6bb1f29afbd85380185723d7b492230e2567c95cf5718eca745da0643400ca619fbeec892df61abe1f71ad3b822d076ed831080c53782edf8c0627ee95c57e2bee12fe55da2b3cadec59947a75ccccbbf36fb3b781c93b4bf51489789f1c0849f9023a16ec70bef41a504785e1082b6f13588e29',
148
+ requestKey: ''
149
+ });
150
+
151
+ const onLogin = async (formEl: FormInstance | undefined) => {
152
+ if (!formEl) return;
153
+ await formEl.validate(valid => {
154
+ if (valid) {
155
+ loading.value = true;
156
+ const { username, passWord } = ruleForm;
157
+
158
+ // @ts-ignore
159
+ setMaxDigits(200);
160
+ // @ts-ignore
161
+ const rsakeypair = new RSAKeyPair(publicRSA.publicKeyExponent, '', publicRSA.publicKeyModulus);
162
+ // @ts-ignore
163
+ const password = encryptedString(rsakeypair, passWord.split('').reverse().join(''));
164
+ const param = {
165
+ username,
166
+ password,
167
+ requestKey: publicRSA.requestKey,
168
+ domain: window.location.origin
169
+ };
170
+ serviceApi
171
+ .post('/uath/login', param)
172
+ .then(async (data: IResponseData) => {
173
+ successMessage(`👏 恭喜,成功登录${sysConfig.value['title']}!!!🎉`);
174
+ useSystemStoreHook().setSessionKey(data);
175
+ cacheToken(data);
176
+ cookies.set('loginer', username);
177
+ await delay(300);
178
+ router.push('/');
179
+ await insertLoginInfo(username);
180
+ })
181
+ .finally(() => {
182
+ loading.value = false;
183
+ });
184
+ }
185
+ });
186
+ };
187
+
188
+ /**
189
+ * @description: 缓存token
190
+ * @param {*} token token数据
191
+ * @return {*}
192
+ */
193
+ const cacheToken = token => {
194
+ const { access_token, expires_in, refresh_token } = token;
195
+ const cache = {
196
+ accessToken: access_token,
197
+ refreshToken: refresh_token,
198
+ expires: Date.now() + expires_in * 1000
199
+ };
200
+ const kTOKENKEY = 'authorized-token';
201
+
202
+ cookies.set('kCookies_token', token.access_token);
203
+ const dataString = JSON.stringify(cache);
204
+ expires_in > 0 ? cookies.set(kTOKENKEY, dataString) : cookies.set(kTOKENKEY, dataString);
205
+ };
206
+
207
+ const insertLoginInfo = username => {
208
+ const userAgent = navigator.userAgent.toLowerCase();
209
+ const { browser, browserVersion } = getBrower(userAgent);
210
+ const obj = {
211
+ userName: username,
212
+ loginTime: toDateString(new Date()),
213
+ browser,
214
+ browserVersion,
215
+ operatingSystem: getPlatform(userAgent)
216
+ };
217
+ serviceApi.post('/upfm/v1/userMonitor', obj);
218
+ };
219
+
220
+ /** 使用公共函数,避免`removeEventListener`失效 */
221
+ function onkeypress({ code }: KeyboardEvent) {
222
+ if (['Enter', 'NumpadEnter'].includes(code)) {
223
+ onLogin(ruleFormRef.value);
224
+ }
225
+ }
226
+
227
+ onMounted(() => {
228
+ window.document.addEventListener('keypress', onkeypress);
229
+ });
230
+
231
+ onBeforeUnmount(() => {
232
+ window.document.removeEventListener('keypress', onkeypress);
233
+ });
234
+ /**
235
+ * @description: 获取系统配置
236
+ * @return {*}
237
+ */
238
+ const getSysConfig = async () => {
239
+ const [err, data]: [Error, any] = await to(serviceApi.get('/upfm/v1/sysConfig', {}));
240
+ if (!err) {
241
+ const config = {};
242
+ data.list?.forEach(item => {
243
+ config[item.configCode] = item.configValue;
244
+ if (item.fileName) {
245
+ config[item.configCode] = window.location.origin + '/ufil' + item.configValue;
246
+ }
247
+ });
248
+ const env = process.env.NODE_ENV;
249
+ const title = data.list?.find(f => f.configCode === `${env}Title` || f.configCode === 'title')?.configValue;
250
+ config['title'] = title || 'U-DP';
251
+ sysConfig.value = config;
252
+ setFavicon();
253
+ storageLocal.setItem('kSysConfig', config);
254
+ }
255
+ };
256
+
257
+ const setFavicon = () => {
258
+ let favicon = document.querySelector('link[rel="icon"]') as HTMLElement;
259
+ // console.log('app', favicon)
260
+ if (favicon !== null) {
261
+ favicon['href'] = sysConfig.value['favicon'] || '../../../public/favicon.ico';
262
+ } else {
263
+ favicon = document.createElement('link');
264
+ favicon['rel'] = 'icon';
265
+ favicon['href'] = sysConfig.value['favicon'] || '../../../public/favicon.ico';
266
+ document.head.appendChild(favicon);
267
+ }
268
+ };
269
+
270
+ onBeforeMount(() => {
271
+ getSysConfig();
272
+ });
273
+ </script>
274
+
275
+ <style scoped>
276
+ @import url('@/style/login2.css');
277
+
278
+ /* .translation {
279
+ ::v-deep(.el-dropdown-menu__item) {
280
+ padding: 5px 40px;
281
+ }
282
+ } */
283
+
284
+ .check-zh {
285
+ position: absolute;
286
+ left: 20px;
287
+ }
288
+
289
+ .check-en {
290
+ position: absolute;
291
+ left: 20px;
292
+ }
293
+
294
+ :deep(.el-input-group__append, .el-input-group__prepend) {
295
+ padding: 0;
296
+ }
297
+ </style>