@utogether/udp-core 1.0.1-beta.10 → 1.0.1-beta.12

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 (84) hide show
  1. package/dist/{403-Ctxjn4q8.js → 403-D7L5zm05.js} +1 -1
  2. package/dist/{404-W5yzyiZ9.js → 404-BQKzkK5W.js} +1 -1
  3. package/dist/{500-DXuGEOm4.js → 500-BM6k8XR5.js} +1 -1
  4. package/dist/{AuthorityInfo-C2tflCt8.js → AuthorityInfo-Dc-7W4L_.js} +1 -1
  5. package/dist/{AuthorityInfo.vue_vue_type_style_index_0_lang-SVgy3HX7.js → AuthorityInfo.vue_vue_type_style_index_0_lang-CKvlh3lm.js} +1 -1
  6. package/dist/{Company-PLez5GoH.js → Company-BgwMUr-I.js} +3 -3
  7. package/dist/{CompanyPanel-CIGaQooL.js → CompanyPanel-CDfVCPKC.js} +1 -1
  8. package/dist/{Department-B9wLsXFm.js → Department-CFvEB4Ys.js} +3 -3
  9. package/dist/{DepartmentPanel-DSM4lTaz.js → DepartmentPanel-11Ytcj2u.js} +1 -1
  10. package/dist/{DesignPanel-B6a9wW_A.js → DesignPanel-CP8z6teZ.js} +1 -1
  11. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-DtHfoDQk.js → DesignPanel.vue_vue_type_style_index_0_lang-Cp-WR8yE.js} +2 -2
  12. package/dist/{DictView-DhFbQxdJ.js → DictView-13NoDgPW.js} +1 -1
  13. package/dist/InvOrganization-DOD4QdEX.js +72 -0
  14. package/dist/{Org-DxBkYabD.js → Org-cezJs-6P.js} +1 -1
  15. package/dist/{Preview-BFtRpBxw.js → Preview-DzOKwnp8.js} +1 -1
  16. package/dist/{ReportDefine-BIa2QryC.js → ReportDefine-DWJq2q0f.js} +1 -1
  17. package/dist/{ReportDesign-CnyjI-WD.js → ReportDesign-f_ed8u_q.js} +2 -2
  18. package/dist/{ReportQuery-BiK7yEhV.js → ReportQuery-D58gv_yZ.js} +1 -1
  19. package/dist/{ReportQueryFrom-C2rqdFTm.js → ReportQueryFrom-R0R6EbYv.js} +1 -1
  20. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-Ba9HLnXQ.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-CIFpgUAH.js} +1 -1
  21. package/dist/{ReportTemplate-DdkLscP3.js → ReportTemplate-BTknctTT.js} +1 -1
  22. package/dist/{Role-BrsxgK8D.js → Role-QTDJ16h8.js} +3 -3
  23. package/dist/{RoleAssign-DiqwJqDa.js → RoleAssign-7aZ3ufp5.js} +3 -3
  24. package/dist/{RolePanel-Dqx5dI3f.js → RolePanel-CSe-UoR5.js} +1 -1
  25. package/dist/{RolePanel-BDusGyo7.js → RolePanel-XXwmaAgy.js} +1 -1
  26. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-2Z1q_5uW.js → RolePanel.vue_vue_type_script_setup_true_lang-BsNhkvFo.js} +1 -1
  27. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-B5lUnaMI.js → RolePanel.vue_vue_type_script_setup_true_lang-kConrKpo.js} +3 -3
  28. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-vSP23fEq.js → ScrollPanel.vue_vue_type_style_index_0_lang-DtaqM_iA.js} +1 -1
  29. package/dist/{Staff-Cwi9LQiZ.js → Staff-BsREgfrQ.js} +3 -3
  30. package/dist/{StaffInfo-XjVtyaMv.js → StaffInfo-CQtVXfvS.js} +1 -1
  31. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-wSrAuyet.js → StaffInfo.vue_vue_type_script_setup_true_lang-BRRtcGIH.js} +1 -1
  32. package/dist/{StaffPanel-C-wYcFdv.js → StaffPanel-cQTAulcP.js} +1 -1
  33. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-DZNArmnC.js → StaffPanel.vue_vue_type_script_setup_true_lang-BLeXlrI1.js} +2 -2
  34. package/dist/{SysUser-O4tvr-Ur.js → SysUser-DN5_46io.js} +2 -2
  35. package/dist/{SysUserPanel-B853docZ.js → SysUserPanel-DTBNR42y.js} +1 -1
  36. package/dist/{SysUserPanel.vue_vue_type_script_setup_true_lang-DhiYYC97.js → SysUserPanel.vue_vue_type_script_setup_true_lang-CF2pHcPP.js} +1 -1
  37. package/dist/{SystemMenu-CXR6mrXr.js → SystemMenu-D9TKZwgb.js} +2 -2
  38. package/dist/{UserInfo-BkP8pE2a.js → UserInfo-DJ5LRTMe.js} +1 -1
  39. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-D4r_umjV.js → UserInfo.vue_vue_type_style_index_0_lang-CIpPef_S.js} +1 -1
  40. package/dist/{childView-D0HwbgDT.js → childView-CGZSd19y.js} +1 -1
  41. package/dist/{childView-TRqUkSDC.js → childView-DrL_Qi-q.js} +1 -1
  42. package/dist/{childView.vue_vue_type_style_index_0_lang-BzISq0Jf.js → childView.vue_vue_type_style_index_0_lang-B8wEeuFX.js} +1 -1
  43. package/dist/{childView.vue_vue_type_style_index_0_lang-DQRgNsJY.js → childView.vue_vue_type_style_index_0_lang-D2AzjPNV.js} +1 -1
  44. package/dist/{code-rule-BV7PQWhK.js → code-rule-DVEoh1Z4.js} +1 -1
  45. package/dist/core.es.js +1 -1
  46. package/dist/{cron-task-9ZS9bi7K.js → cron-task-BBpccUV_.js} +1 -1
  47. package/dist/{frameView-DE83AN50.js → frameView-Cw6_EqfJ.js} +1 -1
  48. package/dist/index-BAkwQh8m.js +4467 -0
  49. package/dist/{layoutView-D1U-c4By.js → layoutView-CL2Ef3bw.js} +1187 -1183
  50. package/dist/{login-sPCEiTGT.js → login-BDocwo7t.js} +115 -108
  51. package/dist/{lov-view-76NcYTYl.js → lov-view-R8nnUEbA.js} +2 -2
  52. package/dist/{menuInfo-CxjfjFpm.js → menuInfo-B-nGOcSv.js} +1 -1
  53. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-C2qahH3r.js → menuInfo.vue_vue_type_style_index_0_lang-1VuzxMb0.js} +1 -1
  54. package/dist/{pda-app-BUH16bLj.js → pda-app-D5wBClj0.js} +1 -1
  55. package/dist/{resource-CCuHzoA6.js → resource-BXGSsXzw.js} +1 -1
  56. package/dist/{su-welcome-mRArONsd.js → su-welcome-DISZAkBB.js} +1 -1
  57. package/dist/sys-config-DuyYdzXL.js +290 -0
  58. package/dist/udp-core.css +2 -2
  59. package/dist/{utogether-Dm_VBQHR.js → utogether-C2KGHvut.js} +1 -1
  60. package/package.json +18 -18
  61. package/src/api/index.ts +31 -31
  62. package/src/components/udp/form.vue +2 -2
  63. package/src/components/udp/modal-form.vue +2 -1
  64. package/src/components/udp/modal-grid.vue +11 -1
  65. package/src/layout/components/lay-navbar/index.vue +239 -237
  66. package/src/layout/components/lay-search/index.vue +1 -1
  67. package/src/layout/components/lay-select-org/index.vue +64 -69
  68. package/src/layout/components/lay-sidebar/horizontal.vue +190 -191
  69. package/src/layout/components/lay-sidebar/mixNav.vue +260 -258
  70. package/src/layout/components/lay-sidebar/sidebar-logo.vue +92 -98
  71. package/src/layout/hooks/useNav.ts +173 -173
  72. package/src/main.ts +119 -119
  73. package/src/plugins/i18n/zh.ts +1 -0
  74. package/src/router/index.ts +3 -13
  75. package/src/store/modules/permission.ts +1 -4
  76. package/src/utils/propTypes.ts +42 -47
  77. package/src/utils/udp/http/index.ts +283 -281
  78. package/src/views/login/login-view.vue +300 -314
  79. package/src/views/organization/inv-org/InvOrganization.vue +68 -53
  80. package/src/views/system/sys/sys-config.vue +287 -291
  81. package/src/views/ulogin/login.vue +3 -4
  82. package/dist/InvOrganization-D90AbR3b.js +0 -66
  83. package/dist/index-DVARtten.js +0 -2623
  84. package/dist/sys-config-Cvt05yF6.js +0 -277
@@ -1,314 +1,300 @@
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.username'), trigger: 'blur' }]"
56
- prop="username"
57
- >
58
- <el-input
59
- v-model.trim="ruleForm.username"
60
- autofocus
61
- clearable
62
- :prefix-icon="useRenderIcon(User)"
63
- />
64
- </el-form-item>
65
- </Motion>
66
-
67
- <Motion :delay="150">
68
- <el-form-item prop="passWord">
69
- <el-input
70
- v-model="ruleForm.passWord"
71
- clearable
72
- show-password
73
- :prefix-icon="useRenderIcon(Lock)"
74
- />
75
- </el-form-item>
76
- </Motion>
77
- <Motion :delay="250">
78
- <el-form-item>
79
- <el-button
80
- class="w-full mt-4"
81
- size="default"
82
- type="primary"
83
- :loading="loading"
84
- @click="onLogin(ruleFormRef)"
85
- >
86
- {{ $t('message.udp.login') }}
87
- </el-button>
88
- </el-form-item>
89
- </Motion>
90
- </el-form>
91
- </div>
92
- <div class="fixed text-xs text-gray-500 bottom-4">
93
- Copyright ©2021{{ sysConfig['copyright'] }}版权所有
94
- </div>
95
- </div>
96
- </div>
97
- </div>
98
- </template>
99
-
100
- <script setup lang="ts">
101
- import { ref, reactive, onMounted, onBeforeMount, onBeforeUnmount } from 'vue';
102
- import { useRouter } from 'vue-router';
103
- import type { FormInstance } from 'element-plus';
104
- import { storageLocal, cookies, successMessage, delay } from '@utogether/utils';
105
- import { toDateString } from 'xe-utils';
106
- import to from 'await-to-js';
107
-
108
- import Motion from './utils/motion';
109
- import { loginRules } from './utils/rule';
110
- import TypeIt from '@/components/SuTypeit';
111
- import { useRenderIcon } from '@/components/ReIcon/src/hooks';
112
- // import { useTranslationLang } from '@/layout/hooks/useTranslationLang';
113
- import { useLayout } from '@/layout/hooks/useLayout';
114
- // import { useNav } from '@/layout/hooks/useNav';
115
- // import { useDataThemeChange } from '@/layout/hooks/useDataThemeChange';
116
- import { useSystemStoreHook } from '@/store/modules/system';
117
-
118
- import { getServiceApi } from '../../api';
119
- import { initDict } from '../../api/user';
120
- import { getPlatform, getBrower } from '@/utils/browers';
121
- // import dayIcon from '@/assets/svg/day.svg?component';
122
- // import darkIcon from '@/assets/svg/dark.svg?component';
123
- // import globalization from '@/assets/svg/globalization.svg?component';
124
- import Lock from '@iconify-icons/ri/lock-fill';
125
- import User from '@iconify-icons/ri/user-3-fill';
126
-
127
- defineOptions({ name: 'LoginView' });
128
-
129
- interface IRSAPublic {
130
- publicKeyExponent: string;
131
- publicKeyModulus: string;
132
- requestKey: string;
133
- }
134
-
135
- const router = useRouter();
136
-
137
- // const bgStyle = ref({});
138
- const sysConfig = ref({});
139
- const loading = ref(false);
140
- const ruleFormRef = ref<FormInstance>();
141
-
142
- const serviceApi = getServiceApi();
143
-
144
- const { initStorage } = useLayout();
145
- initStorage();
146
- // const { dataTheme, dataThemeChange } = useDataThemeChange();
147
- // dataThemeChange();
148
- // const { getDropdownItemStyle, getDropdownItemClass } = useNav();
149
- // const { locale, translationCh, translationEn } = useTranslationLang();
150
-
151
- const ruleForm = reactive({
152
- username: '',
153
- passWord: ''
154
- });
155
-
156
- const publicRSA: IRSAPublic = reactive({
157
- publicKeyExponent: '10001',
158
- publicKeyModulus:
159
- 'a12708ab26367e1711bd767f6bb1f29afbd85380185723d7b492230e2567c95cf5718eca745da0643400ca619fbeec892df61abe1f71ad3b822d076ed831080c53782edf8c0627ee95c57e2bee12fe55da2b3cadec59947a75ccccbbf36fb3b781c93b4bf51489789f1c0849f9023a16ec70bef41a504785e1082b6f13588e29',
160
- requestKey: ''
161
- });
162
-
163
- const onLogin = async (formEl: FormInstance | undefined) => {
164
- if (!formEl) return;
165
- await formEl.validate(valid => {
166
- if (valid) {
167
- loading.value = true;
168
- const { username, passWord } = ruleForm;
169
-
170
- // @ts-ignore
171
- setMaxDigits(200);
172
- // @ts-ignore
173
- const rsakeypair = new RSAKeyPair(publicRSA.publicKeyExponent, '', publicRSA.publicKeyModulus);
174
- // @ts-ignore
175
- const password = encryptedString(rsakeypair, passWord.split('').reverse().join(''));
176
- const param = {
177
- username,
178
- password,
179
- requestKey: publicRSA.requestKey,
180
- domain: window.location.origin
181
- };
182
- serviceApi
183
- .post('/uath/login', param)
184
- .then(async (data: IResponseData) => {
185
- successMessage(`👏 恭喜,成功登录${sysConfig.value['title']}!!!🎉`);
186
- useSystemStoreHook().setSessionKey(data);
187
- cacheToken(data);
188
- cookies.set('loginer', username);
189
- if (!storageLocal.getItem('kLov')) {
190
- initDict().then(res => useSystemStoreHook().setDict(res));
191
- }
192
- await delay(300);
193
- router.push('/');
194
- await insertLoginInfo(username);
195
- })
196
- .finally(() => {
197
- loading.value = false;
198
- });
199
- }
200
- });
201
- };
202
-
203
- /**
204
- * @description: 缓存token
205
- * @param {*} token token数据
206
- * @return {*}
207
- */
208
- const cacheToken = token => {
209
- const { access_token, expires_in, refresh_token } = token;
210
- const cache = {
211
- accessToken: access_token,
212
- refreshToken: refresh_token,
213
- expires: Date.now() + expires_in * 1000
214
- };
215
- const kTOKENKEY = 'authorized-token';
216
-
217
- cookies.set('kCookies_token', token.access_token);
218
- const dataString = JSON.stringify(cache);
219
- expires_in > 0 ? cookies.set(kTOKENKEY, dataString) : cookies.set(kTOKENKEY, dataString);
220
- };
221
-
222
- const insertLoginInfo = username => {
223
- const userAgent = navigator.userAgent.toLowerCase();
224
- const { browser, browserVersion } = getBrower(userAgent);
225
- const obj = {
226
- userName: username,
227
- loginTime: toDateString(new Date()),
228
- browser,
229
- browserVersion,
230
- operatingSystem: getPlatform(userAgent)
231
- };
232
- serviceApi.post('/upfm/v1/userMonitor', obj);
233
- };
234
-
235
- /** 使用公共函数,避免`removeEventListener`失效 */
236
- function onkeypress({ code }: KeyboardEvent) {
237
- if (['Enter', 'NumpadEnter'].includes(code)) {
238
- onLogin(ruleFormRef.value);
239
- }
240
- }
241
-
242
- onMounted(() => {
243
- window.document.addEventListener('keypress', onkeypress);
244
- });
245
-
246
- onBeforeUnmount(() => {
247
- window.document.removeEventListener('keypress', onkeypress);
248
- });
249
- /**
250
- * @description: 获取系统配置
251
- * @return {*}
252
- */
253
- const getSysConfig = async () => {
254
- const [err, data]: [Error, any] = await to(serviceApi.get('/upfm/v1/sysConfig', {}));
255
- if (!err) {
256
- const config = {};
257
- data.list?.forEach(item => {
258
- config[item.configCode] = item.configValue;
259
- if (item.fileName) {
260
- config[item.configCode] = window.location.origin + '/ufil' + item.configValue;
261
- }
262
- });
263
- const env = process.env.NODE_ENV;
264
- const title = data.list?.find(
265
- f => f.configCode === `${env}Title` || f.configCode === 'title'
266
- )?.configValue;
267
- config['title'] = title || 'U-DP';
268
- sysConfig.value = config;
269
- setFavicon();
270
- storageLocal.setItem('kSysConfig', config);
271
- }
272
- };
273
-
274
- const setFavicon = () => {
275
- let favicon = document.querySelector('link[rel="icon"]') as HTMLElement;
276
- // console.log('app', favicon)
277
- if (favicon !== null) {
278
- favicon['href'] = sysConfig.value['favicon'] || '../../../public/favicon.ico';
279
- } else {
280
- favicon = document.createElement('link');
281
- favicon['rel'] = 'icon';
282
- favicon['href'] = sysConfig.value['favicon'] || '../../../public/favicon.ico';
283
- document.head.appendChild(favicon);
284
- }
285
- };
286
-
287
- onBeforeMount(() => {
288
- getSysConfig();
289
- });
290
- </script>
291
-
292
- <style scoped>
293
- @import url('@/style/login2.css');
294
-
295
- /* .translation {
296
- ::v-deep(.el-dropdown-menu__item) {
297
- padding: 5px 40px;
298
- }
299
- } */
300
-
301
- .check-zh {
302
- position: absolute;
303
- left: 20px;
304
- }
305
-
306
- .check-en {
307
- position: absolute;
308
- left: 20px;
309
- }
310
-
311
- :deep(.el-input-group__append, .el-input-group__prepend) {
312
- padding: 0;
313
- }
314
- </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.username'), trigger: 'blur' }]"
56
+ prop="username"
57
+ >
58
+ <el-input v-model.trim="ruleForm.username" autofocus clearable :prefix-icon="useRenderIcon(User)" />
59
+ </el-form-item>
60
+ </Motion>
61
+
62
+ <Motion :delay="150">
63
+ <el-form-item prop="passWord">
64
+ <el-input v-model="ruleForm.passWord" clearable show-password :prefix-icon="useRenderIcon(Lock)" />
65
+ </el-form-item>
66
+ </Motion>
67
+ <Motion :delay="250">
68
+ <el-form-item>
69
+ <el-button
70
+ class="w-full mt-4"
71
+ size="default"
72
+ type="primary"
73
+ :loading="loading"
74
+ @click="onLogin(ruleFormRef)"
75
+ >
76
+ {{ $t('message.udp.login') }}
77
+ </el-button>
78
+ </el-form-item>
79
+ </Motion>
80
+ </el-form>
81
+ </div>
82
+ <div class="fixed text-xs text-gray-500 bottom-4">Copyright ©2021{{ sysConfig['copyright'] }}版权所有</div>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </template>
87
+
88
+ <script setup lang="ts">
89
+ import { ref, reactive, onMounted, onBeforeMount, onBeforeUnmount } from 'vue';
90
+ import { useRouter } from 'vue-router';
91
+ import type { FormInstance } from 'element-plus';
92
+ import { storageLocal, cookies, successMessage, delay } from '@utogether/utils';
93
+ import { toDateString } from 'xe-utils';
94
+ import to from 'await-to-js';
95
+
96
+ import Motion from './utils/motion';
97
+ import { loginRules } from './utils/rule';
98
+ import TypeIt from '@/components/SuTypeit';
99
+ import { useRenderIcon } from '@/components/ReIcon/src/hooks';
100
+ // import { useTranslationLang } from '@/layout/hooks/useTranslationLang';
101
+ import { useLayout } from '@/layout/hooks/useLayout';
102
+ // import { useNav } from '@/layout/hooks/useNav';
103
+ // import { useDataThemeChange } from '@/layout/hooks/useDataThemeChange';
104
+ import { useSystemStoreHook } from '@/store/modules/system';
105
+
106
+ import { getServiceApi } from '../../api';
107
+ import { initDict } from '../../api/user';
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
+ if (!storageLocal.getItem('kLov')) {
178
+ initDict().then(res => useSystemStoreHook().setDict(res));
179
+ }
180
+ await delay(300);
181
+ router.push('/');
182
+ await insertLoginInfo(username);
183
+ })
184
+ .finally(() => {
185
+ loading.value = false;
186
+ });
187
+ }
188
+ });
189
+ };
190
+
191
+ /**
192
+ * @description: 缓存token
193
+ * @param {*} token token数据
194
+ * @return {*}
195
+ */
196
+ const cacheToken = token => {
197
+ const { access_token, expires_in, refresh_token } = token;
198
+ const cache = {
199
+ accessToken: access_token,
200
+ refreshToken: refresh_token,
201
+ expires: Date.now() + expires_in * 1000
202
+ };
203
+ const kTOKENKEY = 'authorized-token';
204
+
205
+ cookies.set('kCookies_token', token.access_token);
206
+ const dataString = JSON.stringify(cache);
207
+ expires_in > 0 ? cookies.set(kTOKENKEY, dataString) : cookies.set(kTOKENKEY, dataString);
208
+ };
209
+
210
+ const insertLoginInfo = username => {
211
+ const userAgent = navigator.userAgent.toLowerCase();
212
+ const { browser, browserVersion } = getBrower(userAgent);
213
+ const obj = {
214
+ userName: username,
215
+ loginTime: toDateString(new Date()),
216
+ browser,
217
+ browserVersion,
218
+ operatingSystem: getPlatform(userAgent)
219
+ };
220
+ serviceApi.post('/upfm/v1/userMonitor', obj);
221
+ };
222
+
223
+ /** 使用公共函数,避免`removeEventListener`失效 */
224
+ function onkeypress({ code }: KeyboardEvent) {
225
+ if (['Enter', 'NumpadEnter'].includes(code)) {
226
+ onLogin(ruleFormRef.value);
227
+ }
228
+ }
229
+
230
+ onMounted(() => {
231
+ window.document.addEventListener('keypress', onkeypress);
232
+ });
233
+
234
+ onBeforeUnmount(() => {
235
+ window.document.removeEventListener('keypress', onkeypress);
236
+ });
237
+ /**
238
+ * @description: 获取系统配置
239
+ * @return {*}
240
+ */
241
+ const getSysConfig = async () => {
242
+ const [err, data]: [Error, any] = await to(serviceApi.get('/upfm/v1/sysConfig', {}));
243
+ if (!err) {
244
+ const config = {};
245
+ data.list?.forEach(item => {
246
+ config[item.configCode] = item.configValue;
247
+ if (item.fileName) {
248
+ config[item.configCode] = window.location.origin + '/ufil' + item.configValue;
249
+ }
250
+ });
251
+ const env = process.env.NODE_ENV;
252
+ const title = data.list?.find(f => f.configCode === `${env}Title` || f.configCode === 'title')?.configValue;
253
+ config['title'] = title || 'U-DP';
254
+ sysConfig.value = config;
255
+ setFavicon();
256
+ storageLocal.setItem('kSysConfig', config);
257
+ }
258
+ };
259
+
260
+ const setFavicon = () => {
261
+ let favicon = document.querySelector('link[rel="icon"]') as HTMLElement;
262
+ // console.log('app', favicon)
263
+ if (favicon !== null) {
264
+ favicon['href'] = sysConfig.value['favicon'] || '../../../public/favicon.ico';
265
+ } else {
266
+ favicon = document.createElement('link');
267
+ favicon['rel'] = 'icon';
268
+ favicon['href'] = sysConfig.value['favicon'] || '../../../public/favicon.ico';
269
+ document.head.appendChild(favicon);
270
+ }
271
+ };
272
+
273
+ onBeforeMount(() => {
274
+ getSysConfig();
275
+ });
276
+ </script>
277
+
278
+ <style scoped>
279
+ @import url('@/style/login2.css');
280
+
281
+ /* .translation {
282
+ ::v-deep(.el-dropdown-menu__item) {
283
+ padding: 5px 40px;
284
+ }
285
+ } */
286
+
287
+ .check-zh {
288
+ position: absolute;
289
+ left: 20px;
290
+ }
291
+
292
+ .check-en {
293
+ position: absolute;
294
+ left: 20px;
295
+ }
296
+
297
+ :deep(.el-input-group__append, .el-input-group__prepend) {
298
+ padding: 0;
299
+ }
300
+ </style>