|
@@ -44,263 +44,266 @@
|
44
|
44
|
</div>
|
45
|
45
|
</template>
|
46
|
46
|
<script setup>
|
47
|
|
-import LoginInput from './LoginInput.vue'
|
|
47
|
+ import LoginInput from './LoginInput.vue'
|
48
|
48
|
|
49
|
|
-const showPWD = ref(false)
|
50
|
|
-import loginApi from '@/api/auth/loginApi'
|
51
|
|
-import PhoneLoginForm from './phoneLoginForm.vue'
|
52
|
|
-import ThreeLogin from './threeLogin.vue'
|
53
|
|
-import smCrypto from '@/utils/smCrypto'
|
54
|
|
-import { required } from '@/utils/formRules'
|
55
|
|
-import { afterLogin } from './util'
|
56
|
|
-import configData from '@/config'
|
57
|
|
-import configApi from '@/api/dev/configApi'
|
58
|
|
-import tool from '@/utils/tool'
|
59
|
|
-import { message } from 'ant-design-vue'
|
|
49
|
+ const showPWD = ref(false)
|
|
50
|
+ import loginApi from '@/api/auth/loginApi'
|
|
51
|
+ import PhoneLoginForm from './phoneLoginForm.vue'
|
|
52
|
+ import ThreeLogin from './threeLogin.vue'
|
|
53
|
+ import smCrypto from '@/utils/smCrypto'
|
|
54
|
+ import { required } from '@/utils/formRules'
|
|
55
|
+ import { afterLogin } from './util'
|
|
56
|
+ import configData from '@/config'
|
|
57
|
+ import configApi from '@/api/dev/configApi'
|
|
58
|
+ import tool from '@/utils/tool'
|
|
59
|
+ import { message } from 'ant-design-vue'
|
60
|
60
|
|
61
|
|
-import { globalStore, iframeStore, keepAliveStore, viewTagsStore, enumMaplistStore } from '@/store'
|
62
|
|
-const { proxy } = getCurrentInstance()
|
63
|
61
|
|
64
|
|
-const activeKey = ref('userAccount')
|
65
|
|
-const captchaOpen = ref(configData.SYS_BASE_CONFIG.SNOWY_SYS_DEFAULT_CAPTCHA_OPEN)
|
66
|
|
-const validCodeBase64 = ref('')
|
67
|
|
-const loading = ref(false)
|
68
|
62
|
|
69
|
|
-const ruleForm = reactive({
|
70
|
|
- // account: 'superAdmin',
|
71
|
|
- // password: '123456',
|
72
|
|
- account: '',
|
73
|
|
- password: '',
|
74
|
|
- validCode: '',
|
75
|
|
- validCodeReqNo: '',
|
76
|
|
- autologin: false
|
77
|
|
-})
|
78
|
63
|
|
79
|
|
-const rules = reactive({
|
80
|
|
- account: [required(proxy.$t('login.accountError'), 'blur')],
|
81
|
|
- password: [required(proxy.$t('login.PWError'), 'blur')]
|
82
|
|
-})
|
83
|
|
-const lang = ref([
|
84
|
|
- {
|
85
|
|
- name: '简体中文',
|
86
|
|
- value: 'zh-cn'
|
87
|
|
- },
|
88
|
|
- {
|
89
|
|
- name: 'English',
|
90
|
|
- value: 'en'
|
91
|
|
- }
|
92
|
|
-])
|
93
|
|
-const config = ref({
|
94
|
|
- lang: tool.data.get('APP_LANG') || proxy.$CONFIG.LANG,
|
95
|
|
- theme: tool.data.get('APP_THEME') || 'default'
|
96
|
|
-})
|
97
|
|
-
|
98
|
|
-const store = globalStore()
|
99
|
|
-const kStore = keepAliveStore()
|
100
|
|
-const iStore = iframeStore()
|
101
|
|
-const vStore = viewTagsStore()
|
102
|
|
-// const StoreDEl = enumMaplistStore()
|
|
64
|
+ import { globalStore, iframeStore, keepAliveStore, viewTagsStore, enumMaplistStore } from '@/store'
|
|
65
|
+ const { proxy } = getCurrentInstance()
|
103
|
66
|
|
104
|
|
-const setSysBaseConfig = store.setSysBaseConfig
|
105
|
|
-const clearKeepLive = kStore.clearKeepLive
|
106
|
|
-const clearIframeList = iStore.clearIframeList
|
107
|
|
-const clearViewTags = vStore.clearViewTags
|
108
|
|
-// const businessDElasync = StoreDEl.businessDElasync
|
|
67
|
+ const activeKey = ref('userAccount')
|
|
68
|
+ const captchaOpen = ref(configData.SYS_BASE_CONFIG.SNOWY_SYS_DEFAULT_CAPTCHA_OPEN)
|
|
69
|
+ const validCodeBase64 = ref('')
|
|
70
|
+ const loading = ref(false)
|
109
|
71
|
|
110
|
|
-const sysBaseConfig = computed(() => {
|
111
|
|
- return store.sysBaseConfig
|
112
|
|
-})
|
|
72
|
+ const ruleForm = reactive({
|
|
73
|
+ // account: 'superAdmin',
|
|
74
|
+ // password: '123456',
|
|
75
|
+ account: '',
|
|
76
|
+ password: '',
|
|
77
|
+ validCode: '',
|
|
78
|
+ validCodeReqNo: '',
|
|
79
|
+ autologin: false
|
|
80
|
+ })
|
113
|
81
|
|
114
|
|
-onMounted(() => {
|
115
|
|
- let formData = ref(configData.SYS_BASE_CONFIG)
|
116
|
|
- configApi.configSysBaseList().then((data) => {
|
117
|
|
- if (data) {
|
118
|
|
- data.forEach((item) => {
|
119
|
|
- formData.value[item.configKey] = item.configValue
|
120
|
|
- })
|
121
|
|
- captchaOpen.value = formData.value.SNOWY_SYS_DEFAULT_CAPTCHA_OPEN
|
122
|
|
- tool.data.set('SNOWY_SYS_BASE_CONFIG', formData.value)
|
123
|
|
- setSysBaseConfig(formData.value)
|
124
|
|
- refreshSwitch()
|
|
82
|
+ const rules = reactive({
|
|
83
|
+ account: [required(proxy.$t('login.accountError'), 'blur')],
|
|
84
|
+ password: [required(proxy.$t('login.PWError'), 'blur')]
|
|
85
|
+ })
|
|
86
|
+ const lang = ref([
|
|
87
|
+ {
|
|
88
|
+ name: '简体中文',
|
|
89
|
+ value: 'zh-cn'
|
|
90
|
+ },
|
|
91
|
+ {
|
|
92
|
+ name: 'English',
|
|
93
|
+ value: 'en'
|
125
|
94
|
}
|
|
95
|
+ ])
|
|
96
|
+ const config = ref({
|
|
97
|
+ lang: tool.data.get('APP_LANG') || proxy.$CONFIG.LANG,
|
|
98
|
+ theme: tool.data.get('APP_THEME') || 'default'
|
126
|
99
|
})
|
127
|
|
-})
|
128
|
100
|
|
129
|
|
-onBeforeMount(() => {
|
130
|
|
- clearViewTags()
|
131
|
|
- clearKeepLive()
|
132
|
|
- clearIframeList()
|
133
|
|
-})
|
|
101
|
+ const store = globalStore()
|
|
102
|
+ const kStore = keepAliveStore()
|
|
103
|
+ const iStore = iframeStore()
|
|
104
|
+ const vStore = viewTagsStore()
|
|
105
|
+ const StoreDEl = enumMaplistStore()
|
134
|
106
|
|
135
|
|
-// 监听语言
|
136
|
|
-watch(
|
137
|
|
- () => config.value.lang,
|
138
|
|
- (newValue) => {
|
139
|
|
- proxy.$i18n.locale = newValue
|
140
|
|
- tool.data.set('APP_LANG', newValue)
|
141
|
|
- }
|
142
|
|
-)
|
143
|
|
-// 主题
|
144
|
|
-watch(
|
145
|
|
- () => config.value.theme,
|
146
|
|
- (newValue) => {
|
147
|
|
- document.body.setAttribute('data-theme', newValue)
|
148
|
|
- }
|
149
|
|
-)
|
150
|
|
-// 通过开关加载内容
|
151
|
|
-const refreshSwitch = () => {
|
152
|
|
- // 判断是否开启验证码
|
153
|
|
- if (captchaOpen.value === 'true') {
|
154
|
|
- // 加载验证码
|
155
|
|
- loginCaptcha()
|
156
|
|
- // 加入校验
|
157
|
|
- rules.validCode = [required(proxy.$t('login.validError'), 'blur')]
|
158
|
|
- }
|
159
|
|
-}
|
|
107
|
+ const setSysBaseConfig = store.setSysBaseConfig
|
|
108
|
+ const clearKeepLive = kStore.clearKeepLive
|
|
109
|
+ const clearIframeList = iStore.clearIframeList
|
|
110
|
+ const clearViewTags = vStore.clearViewTags
|
|
111
|
+ const businessDElasync = StoreDEl.businessDElasync
|
|
112
|
+
|
|
113
|
+ const sysBaseConfig = computed(() => {
|
|
114
|
+ return store.sysBaseConfig
|
|
115
|
+ })
|
|
116
|
+
|
|
117
|
+ onMounted(() => {
|
|
118
|
+ let formData = ref(configData.SYS_BASE_CONFIG)
|
|
119
|
+ configApi.configSysBaseList().then((data) => {
|
|
120
|
+ if (data) {
|
|
121
|
+ data.forEach((item) => {
|
|
122
|
+ formData.value[item.configKey] = item.configValue
|
|
123
|
+ })
|
|
124
|
+ captchaOpen.value = formData.value.SNOWY_SYS_DEFAULT_CAPTCHA_OPEN
|
|
125
|
+ tool.data.set('SNOWY_SYS_BASE_CONFIG', formData.value)
|
|
126
|
+ setSysBaseConfig(formData.value)
|
|
127
|
+ refreshSwitch()
|
|
128
|
+ }
|
|
129
|
+ })
|
|
130
|
+ })
|
160
|
131
|
|
161
|
|
-// 获取验证码
|
162
|
|
-const loginCaptcha = () => {
|
163
|
|
- loginApi.getPicCaptcha().then((data) => {
|
164
|
|
- validCodeBase64.value = data.validCodeBase64
|
165
|
|
- ruleForm.validCodeReqNo = data.validCodeReqNo
|
|
132
|
+ onBeforeMount(() => {
|
|
133
|
+ clearViewTags()
|
|
134
|
+ clearKeepLive()
|
|
135
|
+ clearIframeList()
|
166
|
136
|
})
|
167
|
|
-}
|
168
|
|
-//登陆
|
169
|
|
-const loginForm = ref()
|
170
|
|
-const login = async () => {
|
171
|
|
- if (!ruleForm.account) {
|
172
|
|
- message.error('请输入账号')
|
173
|
|
- return
|
|
137
|
+
|
|
138
|
+ // 监听语言
|
|
139
|
+ watch(
|
|
140
|
+ () => config.value.lang,
|
|
141
|
+ (newValue) => {
|
|
142
|
+ proxy.$i18n.locale = newValue
|
|
143
|
+ tool.data.set('APP_LANG', newValue)
|
|
144
|
+ }
|
|
145
|
+ )
|
|
146
|
+ // 主题
|
|
147
|
+ watch(
|
|
148
|
+ () => config.value.theme,
|
|
149
|
+ (newValue) => {
|
|
150
|
+ document.body.setAttribute('data-theme', newValue)
|
|
151
|
+ }
|
|
152
|
+ )
|
|
153
|
+ // 通过开关加载内容
|
|
154
|
+ const refreshSwitch = () => {
|
|
155
|
+ // 判断是否开启验证码
|
|
156
|
+ if (captchaOpen.value === 'true') {
|
|
157
|
+ // 加载验证码
|
|
158
|
+ loginCaptcha()
|
|
159
|
+ // 加入校验
|
|
160
|
+ rules.validCode = [required(proxy.$t('login.validError'), 'blur')]
|
|
161
|
+ }
|
174
|
162
|
}
|
175
|
|
- if (!ruleForm.password) {
|
176
|
|
- message.error('请输入密码')
|
177
|
|
- return
|
|
163
|
+
|
|
164
|
+ // 获取验证码
|
|
165
|
+ const loginCaptcha = () => {
|
|
166
|
+ loginApi.getPicCaptcha().then((data) => {
|
|
167
|
+ validCodeBase64.value = data.validCodeBase64
|
|
168
|
+ ruleForm.validCodeReqNo = data.validCodeReqNo
|
|
169
|
+ })
|
178
|
170
|
}
|
179
|
|
- loading.value = true
|
180
|
|
- const loginData = {
|
181
|
|
- account: ruleForm.account,
|
182
|
|
- // 密码进行SM2加密,传输过程中看到的只有密文,后端存储使用hash
|
183
|
|
- password: smCrypto.doSm2Encrypt(ruleForm.password),
|
184
|
|
- validCode: ruleForm.validCode,
|
185
|
|
- validCodeReqNo: ruleForm.validCodeReqNo
|
|
171
|
+ //登陆
|
|
172
|
+ const loginForm = ref()
|
|
173
|
+ const login = async () => {
|
|
174
|
+ if (!ruleForm.account) {
|
|
175
|
+ message.error('请输入账号')
|
|
176
|
+ return
|
|
177
|
+ }
|
|
178
|
+ if (!ruleForm.password) {
|
|
179
|
+ message.error('请输入密码')
|
|
180
|
+ return
|
|
181
|
+ }
|
|
182
|
+ loading.value = true
|
|
183
|
+ const loginData = {
|
|
184
|
+ account: ruleForm.account,
|
|
185
|
+ // 密码进行SM2加密,传输过程中看到的只有密文,后端存储使用hash
|
|
186
|
+ password: smCrypto.doSm2Encrypt(ruleForm.password),
|
|
187
|
+ validCode: ruleForm.validCode,
|
|
188
|
+ validCodeReqNo: ruleForm.validCodeReqNo
|
|
189
|
+ }
|
|
190
|
+ // 获取token
|
|
191
|
+ try {
|
|
192
|
+ const loginToken = await loginApi.login(loginData)
|
|
193
|
+ afterLogin(loginToken)
|
|
194
|
+ } catch (err) {
|
|
195
|
+ loading.value = false
|
|
196
|
+ loginCaptcha()
|
|
197
|
+ }
|
|
198
|
+ businessDElasync()
|
186
|
199
|
}
|
187
|
|
- // 获取token
|
188
|
|
- try {
|
189
|
|
- const loginToken = await loginApi.login(loginData)
|
190
|
|
- afterLogin(loginToken)
|
191
|
|
- } catch (err) {
|
192
|
|
- loading.value = false
|
193
|
|
- loginCaptcha()
|
|
200
|
+ const configLang = (key) => {
|
|
201
|
+ config.value.lang = key
|
194
|
202
|
}
|
195
|
|
- // businessDElasync()
|
196
|
|
-}
|
197
|
|
-const configLang = (key) => {
|
198
|
|
- config.value.lang = key
|
199
|
|
-}
|
200
|
203
|
</script>
|
201
|
204
|
<style lang="less">
|
202
|
|
-.login_background {
|
203
|
|
- background: url('/img/login_bg.png') no-repeat center;
|
204
|
|
- position: relative;
|
205
|
|
- width: 100%;
|
206
|
|
- height: 100%;
|
207
|
|
- .login_left {
|
208
|
|
- position: absolute;
|
209
|
|
- top: 204px;
|
210
|
|
- left: 190px;
|
211
|
|
- img {
|
212
|
|
- width: 700px;
|
213
|
|
- }
|
214
|
|
- }
|
215
|
|
- .login_background_front {
|
216
|
|
- background: url('/img/login/LOGO.png') no-repeat center;
|
217
|
|
- width: 800px;
|
218
|
|
- height: 92px;
|
219
|
|
- position: absolute;
|
220
|
|
- left: 10%;
|
221
|
|
- top: 10%;
|
222
|
|
- }
|
223
|
|
- .login_main {
|
224
|
|
- width: 570px;
|
225
|
|
- height: 500px;
|
226
|
|
- position: absolute;
|
227
|
|
- right: 80px;
|
228
|
|
- top: 200px;
|
229
|
|
- background: rgba(255, 255, 255, 0.75);
|
230
|
|
- border-radius: 8px;
|
231
|
|
- }
|
232
|
|
- .login_head {
|
|
205
|
+ .login_background {
|
|
206
|
+ background: url('/img/login_bg.png') no-repeat center;
|
|
207
|
+ position: relative;
|
233
|
208
|
width: 100%;
|
234
|
|
- display: flex;
|
235
|
|
- justify-content: space-between;
|
236
|
|
- align-items: center;
|
237
|
|
- overflow: hidden;
|
238
|
|
- white-space: nowrap;
|
239
|
|
- padding: 50px 0 40px;
|
240
|
|
- user-select: none;
|
241
|
|
- .text {
|
242
|
|
- padding: 0 30px;
|
243
|
|
- font-size: 25px;
|
244
|
|
- }
|
245
|
|
- &:before,
|
246
|
|
- &:after {
|
247
|
|
- width: 50%;
|
248
|
|
- height: 1px;
|
249
|
|
- content: '';
|
250
|
|
- background: rgba(0, 0, 0, 0.3);
|
251
|
|
- }
|
252
|
|
- }
|
253
|
|
- .login_form {
|
254
|
|
- margin: 0 50px;
|
255
|
|
- .icon {
|
256
|
|
- font-size: 16px;
|
257
|
|
- padding: 0 6px;
|
258
|
|
- color: #666;
|
|
209
|
+ height: 100%;
|
|
210
|
+ .login_left {
|
|
211
|
+ position: absolute;
|
|
212
|
+ top: 204px;
|
|
213
|
+ left: 190px;
|
|
214
|
+ img {
|
|
215
|
+ width: 700px;
|
|
216
|
+ }
|
259
|
217
|
}
|
260
|
|
- .LoginInput {
|
261
|
|
- font-size: 15px;
|
262
|
|
- box-shadow: 0 0 3px rgba(0, 0, 0, 0.06);
|
263
|
|
- margin-top: 30px;
|
|
218
|
+ .login_background_front {
|
|
219
|
+ background: url('/img/login/LOGO.png') no-repeat center;
|
|
220
|
+ width: 800px;
|
|
221
|
+ height: 92px;
|
|
222
|
+ position: absolute;
|
|
223
|
+ left: 10%;
|
|
224
|
+ top: 10%;
|
264
|
225
|
}
|
265
|
|
- .login_auto {
|
266
|
|
- margin-top: 20px;
|
267
|
|
- .auto_text {
|
268
|
|
- color: #444;
|
269
|
|
- }
|
|
226
|
+ .login_main {
|
|
227
|
+ width: 570px;
|
|
228
|
+ height: 500px;
|
|
229
|
+ position: absolute;
|
|
230
|
+ right: 80px;
|
|
231
|
+ top: 200px;
|
|
232
|
+ background: rgba(255, 255, 255, 0.75);
|
|
233
|
+ border-radius: 8px;
|
270
|
234
|
}
|
271
|
|
- .login_btn {
|
272
|
|
- cursor: pointer;
|
|
235
|
+ .login_head {
|
273
|
236
|
width: 100%;
|
274
|
|
- border: none;
|
275
|
|
- background: url('/img/login_btn.png') no-repeat center;
|
276
|
|
- height: 74px;
|
277
|
|
- line-height: 50px;
|
278
|
|
- color: #fff;
|
279
|
|
- font-size: 18px;
|
280
|
|
- font-weight: bold;
|
281
|
|
- letter-spacing: 10px;
|
282
|
|
- margin-top: 50px;
|
283
|
237
|
display: flex;
|
284
|
|
- justify-content: center;
|
285
|
|
- align-items: flex-start;
|
286
|
|
- }
|
287
|
|
- .login_forgetbox {
|
288
|
|
- margin-top: 20px;
|
289
|
|
- text-align: right;
|
290
|
|
- .login_forget {
|
291
|
|
- color: #444;
|
|
238
|
+ justify-content: space-between;
|
|
239
|
+ align-items: center;
|
|
240
|
+ overflow: hidden;
|
|
241
|
+ white-space: nowrap;
|
|
242
|
+ padding: 50px 0 40px;
|
|
243
|
+ user-select: none;
|
|
244
|
+ .text {
|
|
245
|
+ padding: 0 30px;
|
|
246
|
+ font-size: 25px;
|
|
247
|
+ }
|
|
248
|
+ &:before,
|
|
249
|
+ &:after {
|
|
250
|
+ width: 50%;
|
|
251
|
+ height: 1px;
|
|
252
|
+ content: '';
|
|
253
|
+ background: rgba(0, 0, 0, 0.3);
|
292
|
254
|
}
|
293
|
255
|
}
|
294
|
|
- }
|
295
|
|
- @media (max-width: 1000px) {
|
296
|
|
- .login_background_front {
|
297
|
|
- left: 50%;
|
298
|
|
- margin-left: -400px;
|
|
256
|
+ .login_form {
|
|
257
|
+ margin: 0 50px;
|
|
258
|
+ .icon {
|
|
259
|
+ font-size: 16px;
|
|
260
|
+ padding: 0 6px;
|
|
261
|
+ color: #666;
|
|
262
|
+ }
|
|
263
|
+ .LoginInput {
|
|
264
|
+ font-size: 15px;
|
|
265
|
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.06);
|
|
266
|
+ margin-top: 30px;
|
|
267
|
+ }
|
|
268
|
+ .login_auto {
|
|
269
|
+ margin-top: 20px;
|
|
270
|
+ .auto_text {
|
|
271
|
+ color: #444;
|
|
272
|
+ }
|
|
273
|
+ }
|
|
274
|
+ .login_btn {
|
|
275
|
+ cursor: pointer;
|
|
276
|
+ width: 100%;
|
|
277
|
+ border: none;
|
|
278
|
+ background: url('/img/login_btn.png') no-repeat center;
|
|
279
|
+ height: 74px;
|
|
280
|
+ line-height: 50px;
|
|
281
|
+ color: #fff;
|
|
282
|
+ font-size: 18px;
|
|
283
|
+ font-weight: bold;
|
|
284
|
+ letter-spacing: 10px;
|
|
285
|
+ margin-top: 50px;
|
|
286
|
+ display: flex;
|
|
287
|
+ justify-content: center;
|
|
288
|
+ align-items: flex-start;
|
|
289
|
+ }
|
|
290
|
+ .login_forgetbox {
|
|
291
|
+ margin-top: 20px;
|
|
292
|
+ text-align: right;
|
|
293
|
+ .login_forget {
|
|
294
|
+ color: #444;
|
|
295
|
+ }
|
|
296
|
+ }
|
299
|
297
|
}
|
300
|
|
- .login_main {
|
301
|
|
- left: calc(50% - 285px);
|
302
|
|
- top: 24%;
|
|
298
|
+ @media (max-width: 1000px) {
|
|
299
|
+ .login_background_front {
|
|
300
|
+ left: 50%;
|
|
301
|
+ margin-left: -400px;
|
|
302
|
+ }
|
|
303
|
+ .login_main {
|
|
304
|
+ left: calc(50% - 285px);
|
|
305
|
+ top: 24%;
|
|
306
|
+ }
|
303
|
307
|
}
|
304
|
308
|
}
|
305
|
|
-}
|
306
|
309
|
</style>
|