@utogether/udp-core 1.0.1-beta.1 → 1.0.1-beta.11

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 (147) hide show
  1. package/build/plugins.ts +39 -32
  2. package/dist/{403-Dp617CWX.js → 403-Dsgsr2M-.js} +1 -1
  3. package/dist/{404-Cz_Axb6Y.js → 404-DmPHEfqM.js} +1 -1
  4. package/dist/{500-BGCtRNse.js → 500-OYEgHR2a.js} +1 -1
  5. package/dist/{AuthorityInfo-DGGfm7IS.js → AuthorityInfo-B1H1txG-.js} +1 -1
  6. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-BUlmQtjQ.js +100 -0
  7. package/dist/{Company-IV3GTnzY.js → Company-C8ojgx93.js} +3 -3
  8. package/dist/{CompanyPanel-qV-_VtoL.js → CompanyPanel-Dageer1t.js} +16 -16
  9. package/dist/{Department-B3W-OxW8.js → Department-Dr94_85I.js} +3 -3
  10. package/dist/{DepartmentPanel-Cw3OWxE7.js → DepartmentPanel-Bc5r1HpT.js} +1 -1
  11. package/dist/{DesignPanel-BFxR2fHJ.js → DesignPanel-CcWt1Myp.js} +1 -1
  12. package/dist/{DesignPanel.vue_vue_type_style_index_0_lang-DljbeFba.js → DesignPanel.vue_vue_type_style_index_0_lang-CKA6nx1l.js} +24 -26
  13. package/dist/DictView-BHj6wexC.js +110 -0
  14. package/dist/InvOrganization-DP3Le9g-.js +72 -0
  15. package/dist/Org-BRGHTwsw.js +39 -0
  16. package/dist/{Preview-BlDMmpdR.js → Preview-CqMaUD_3.js} +1 -1
  17. package/dist/{ReportDefine-Cub_85LA.js → ReportDefine-PEQdTCOY.js} +1 -1
  18. package/dist/{ReportDesign-hFhq5UVE.js → ReportDesign-CB4bv8ba.js} +43 -43
  19. package/dist/{ReportQuery-ChkWEyxT.js → ReportQuery-B7t4lMK0.js} +1 -1
  20. package/dist/{ReportQueryFrom-KVyD_8Dj.js → ReportQueryFrom-VBxUIMRJ.js} +1 -1
  21. package/dist/{ReportQueryFrom.vue_vue_type_style_index_0_lang-CLNODquq.js → ReportQueryFrom.vue_vue_type_style_index_0_lang-HeLA4Qs5.js} +1 -1
  22. package/dist/{ReportTemplate-ag9NDvh2.js → ReportTemplate-DNkv7F5p.js} +28 -28
  23. package/dist/{Role-_q3lQ8CZ.js → Role-BGfTpZK4.js} +6 -6
  24. package/dist/{RoleAssign-DZb9IRsm.js → RoleAssign-DrKFWZzA.js} +8 -8
  25. package/dist/{RolePanel-CsLsz-Ds.js → RolePanel-3lvRh7aS.js} +1 -1
  26. package/dist/{RolePanel-BQb1LlhD.js → RolePanel-BRI5QYe4.js} +1 -1
  27. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-BXKZb7yt.js +132 -0
  28. package/dist/{RolePanel.vue_vue_type_script_setup_true_lang-BrnRgHEk.js → RolePanel.vue_vue_type_script_setup_true_lang-Cci_Ysty.js} +44 -38
  29. package/dist/{ScrollPanel.vue_vue_type_style_index_0_lang-CaFKRwXu.js → ScrollPanel.vue_vue_type_style_index_0_lang-BmId6zzA.js} +21 -21
  30. package/dist/{Staff-BSf9Ypbk.js → Staff-Dr0dq3fW.js} +3 -3
  31. package/dist/{StaffInfo-BNKasyMF.js → StaffInfo-_N9g2hPa.js} +1 -1
  32. package/dist/{StaffInfo.vue_vue_type_script_setup_true_lang-DDZ7ukd0.js → StaffInfo.vue_vue_type_script_setup_true_lang-DiTJY2ug.js} +11 -11
  33. package/dist/{StaffPanel-Bpq0WVlH.js → StaffPanel-mxJQiW3G.js} +1 -1
  34. package/dist/{StaffPanel.vue_vue_type_script_setup_true_lang-BhiJ0Q-Q.js → StaffPanel.vue_vue_type_script_setup_true_lang-GRGn-5t6.js} +2 -2
  35. package/dist/{SysUser-FAABuNti.js → SysUser-DgA19hZE.js} +2 -2
  36. package/dist/{SysUserPanel-PxJeOgHm.js → SysUserPanel-Bc85z5_K.js} +1 -1
  37. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-BHDrP1Pk.js +294 -0
  38. package/dist/{SystemMenu-C-7NAGon.js → SystemMenu-Be-gFIie.js} +26 -26
  39. package/dist/{UserInfo-ClXKtyGo.js → UserInfo-BCYuwFmr.js} +1 -1
  40. package/dist/{UserInfo.vue_vue_type_style_index_0_lang-8N7P4Hl7.js → UserInfo.vue_vue_type_style_index_0_lang-B1lgokO6.js} +39 -37
  41. package/dist/{childView-C_HmDQNd.js → childView-DhcBr1UA.js} +1 -1
  42. package/dist/{childView-uUlBcTza.js → childView-Dk4zZoXd.js} +1 -1
  43. package/dist/{childView.vue_vue_type_style_index_0_lang-Ckjmw6wJ.js → childView.vue_vue_type_style_index_0_lang-CVnLnl03.js} +40 -40
  44. package/dist/{childView.vue_vue_type_style_index_0_lang-y0sDvYx5.js → childView.vue_vue_type_style_index_0_lang-D4GYVhOc.js} +1 -1
  45. package/dist/{code-rule-AgCVDKFy.js → code-rule-BSwPwuAL.js} +9 -10
  46. package/dist/core.es.js +14 -11
  47. package/dist/{cron-task-C6FgQxTi.js → cron-task-T1ztyra7.js} +1 -1
  48. package/dist/{frameView-BDgISK7N.js → frameView-BDgngiBq.js} +1 -1
  49. package/dist/img/l_img.svg +1 -1
  50. package/dist/img/minicolors.png +0 -0
  51. package/dist/img/v_img.svg +1 -1
  52. package/dist/index-BSj2AtVL.js +4468 -0
  53. package/dist/{layoutView-yb3DV2DQ.js → layoutView-i7dLLBzJ.js} +1181 -1176
  54. package/dist/{login-RRpljbkm.js → login-K5Ludp8x.js} +105 -113
  55. package/dist/{login-log-CvVnyGi3.js → login-log-kqKzKTto.js} +1 -1
  56. package/dist/{lov-view-C9-rjzZR.js → lov-view-lAexiucu.js} +2 -2
  57. package/dist/{menuInfo-CzPQyFhp.js → menuInfo-BaN5YZPp.js} +1 -1
  58. package/dist/{menuInfo.vue_vue_type_style_index_0_lang-BumXunCg.js → menuInfo.vue_vue_type_style_index_0_lang-yI4QOYxG.js} +100 -97
  59. package/dist/{pda-app-Dvy3U-b6.js → pda-app-DEtDXFvM.js} +211 -197
  60. package/dist/{resource-Fy0lFkSV.js → resource-Bztmz7pn.js} +15 -15
  61. package/dist/{su-welcome-DYvSCUST.js → su-welcome-Bx8nBPi9.js} +109 -110
  62. package/dist/sys-config-nvrtYGgi.js +290 -0
  63. package/dist/udp-core.css +2 -2
  64. package/dist/{utogether-CjmJiHoE.js → utogether-yPnwDAIH.js} +1 -1
  65. package/index.ts +40 -36
  66. package/package.json +18 -18
  67. package/src/App.vue +65 -70
  68. package/src/api/index.ts +31 -31
  69. package/src/components/SuCharts/src/UserInfo.vue +78 -78
  70. package/src/components/SuScrollTree/ScrollPanel.vue +3 -3
  71. package/src/components/udp/count-down.vue +536 -0
  72. package/src/components/udp/flip-down/FlipCard/flip-card.vue +251 -0
  73. package/src/components/udp/flip-down/FlipCard/interfaces.ts +4 -0
  74. package/src/components/udp/flip-down/FlipClock/flip-clock.vue +113 -0
  75. package/src/components/udp/form-upload.vue +414 -64
  76. package/src/components/udp/form.vue +112 -0
  77. package/src/components/udp/grid.vue +495 -0
  78. package/src/components/udp/index.ts +10 -4
  79. package/src/components/udp/lov.vue +388 -0
  80. package/src/components/udp/modal-form.vue +13 -3
  81. package/src/components/udp/modal-grid.vue +298 -0
  82. package/src/components/udp/upload.vue +423 -0
  83. package/src/components/udp/utils.ts +447 -40
  84. package/src/directives/permission/index.ts +1 -1
  85. package/src/layout/components/lay-navbar/index.vue +239 -237
  86. package/src/layout/components/lay-panel/index.vue +150 -150
  87. package/src/layout/components/lay-search/index.vue +25 -25
  88. package/src/layout/components/lay-select-org/index.vue +64 -69
  89. package/src/layout/components/lay-sidebar/breadCrumb.vue +1 -1
  90. package/src/layout/components/lay-sidebar/horizontal.vue +190 -191
  91. package/src/layout/components/lay-sidebar/mixNav.vue +260 -258
  92. package/src/layout/components/lay-sidebar/sidebar-logo.vue +92 -98
  93. package/src/layout/components/lay-tag/index.vue +625 -625
  94. package/src/layout/hooks/useNav.ts +173 -173
  95. package/src/layout/layoutView.vue +215 -215
  96. package/src/main.ts +119 -109
  97. package/src/plugins/i18n/en.ts +302 -289
  98. package/src/plugins/i18n/zh.ts +349 -337
  99. package/src/plugins/vxe-table/index.ts +53 -46
  100. package/src/plugins/vxe-table/render.tsx +956 -817
  101. package/src/router/index.ts +177 -183
  102. package/src/router/modules/remaining.ts +58 -83
  103. package/src/store/modules/permission.ts +1 -4
  104. package/src/style/button.scss +85 -78
  105. package/src/style/tailwind.css +1 -68
  106. package/src/style/vxetable.scss +44 -11
  107. package/src/utils/authority/index.ts +1 -1
  108. package/src/utils/{http → udp/http}/index.ts +283 -297
  109. package/src/utils/{http → udp/http}/types.d.ts +8 -5
  110. package/src/utils/udp/useRender.ts +17 -6
  111. package/src/views/login/login-view.vue +300 -314
  112. package/src/views/organization/company/CompanyPanel.vue +259 -259
  113. package/src/views/organization/inv-org/InvOrganization.vue +68 -54
  114. package/src/views/organization/org/Org.vue +9 -5
  115. package/src/views/system/menu/SystemMenu.vue +183 -197
  116. package/src/views/system/menu/menuInfo.vue +363 -371
  117. package/src/views/system/role/AuthorityInfo.vue +19 -15
  118. package/src/views/system/role/Role.vue +1 -5
  119. package/src/views/system/role/RolePanel.vue +11 -2
  120. package/src/views/system/role/UserInfo.vue +195 -193
  121. package/src/views/system/role-assign/RoleAssign.vue +57 -57
  122. package/src/views/system/role-assign/RolePanel.vue +139 -136
  123. package/src/views/system/sys/sys-config.vue +287 -291
  124. package/src/views/system/sysUser/SysUserPanel.vue +278 -278
  125. package/src/views/uapp/pda/pda-app.vue +208 -176
  126. package/src/views/udev/dict/DictView.vue +118 -106
  127. package/src/views/udev/dict/childView.vue +7 -7
  128. package/src/views/udev/lov/lov-view.vue +91 -91
  129. package/src/views/ufile/aggregation/File.vue +5 -5
  130. package/src/views/ufile/file/water-mark.vue +14 -14
  131. package/src/views/uhome/su-welcome.vue +3 -3
  132. package/src/views/ulogin/login.vue +12 -8
  133. package/src/views/upms/user/login-log.vue +1 -1
  134. package/src/views/urpt/design/DesignPanel.vue +507 -526
  135. package/src/views/urpt/design/ReportDesign.vue +15 -19
  136. package/src/views/urpt/static-resource/resource.vue +3 -3
  137. package/src/views/urpt/template/ReportTemplate.vue +7 -7
  138. package/types/global.d.ts +2 -1
  139. package/vite.config.ts +6 -2
  140. package/dist/AuthorityInfo.vue_vue_type_style_index_0_lang-BqccGW7v.js +0 -102
  141. package/dist/DictView-C-i7e4hZ.js +0 -95
  142. package/dist/InvOrganization-cfT6riGU.js +0 -260
  143. package/dist/Org-CA7vTDIF.js +0 -35
  144. package/dist/RolePanel.vue_vue_type_script_setup_true_lang-cmW7zBLu.js +0 -126
  145. package/dist/SysUserPanel.vue_vue_type_script_setup_true_lang-njefUln5.js +0 -288
  146. package/dist/index-DzOzUkf6.js +0 -3388
  147. package/dist/sys-config-DJ1vNQTy.js +0 -277
@@ -1,314 +1,300 @@
1
- <template>
2
- <div class="select-none">
3
- <div class="absolute flex-c 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('/upms/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>