Sfoglia il codice sorgente

perf(views): 编写"登陆页"跳转逻辑

wangshun 3 giorni fa
parent
commit
d105d4b586
3 ha cambiato i file con 74 aggiunte e 13 eliminazioni
  1. 13 0
      src/api/index.ts
  2. 29 0
      src/i18n/locales/zh.json
  3. 32 13
      src/views/login-component/LoginView.vue

+ 13 - 0
src/api/index.ts

@@ -99,6 +99,7 @@ import type {
   PageParams,
   ParameterVerification,
   ParamValueListAutomaticQuery,
+  PasswordParams,
   PermissionGroupItem,
   PermissionList,
   PointTimeSeriesQuery,
@@ -365,6 +366,18 @@ export const getUserPageList = async (params: UserPageParams) => {
   return data;
 };
 
+export const getNeedFirstWizard = async () => {
+  const data = await request<boolean>(apiSys('/sysUser/needFirstWizard'));
+  return data;
+};
+
+export const addRevisePassword = async (params: PasswordParams) => {
+  await request(apiSys('/sysUser/currentUser/password'), {
+    method: 'POST',
+    body: JSON.stringify(params),
+  });
+};
+
 // 内部用户表
 export const getOrgUsers = async () => {
   const data = await request<UserPageItem[]>(apiSys('/inner/sysUser/orgUsers'));

+ 29 - 0
src/i18n/locales/zh.json

@@ -155,6 +155,7 @@
     "keepNo": "不保持",
     "manual": "手动",
     "maximize": "最大化",
+    "modifySuccess": "修改成功!",
     "month": "月",
     "needHelp": "需要帮助?",
     "newAddition": "新增",
@@ -534,6 +535,27 @@
     "protocolName": "网关协议名称",
     "searchTip": "请输入协议名称"
   },
+  "hcacAside": {
+    "changePassword": "修改密码",
+    "confirmNewPassword": "确认新密码",
+    "deviceEventName": "二级设备分组/事件名称",
+    "deviceMonitoringPoint": "设备监测点",
+    "logout": "退出登陆",
+    "messageCenter": "消息中心",
+    "newPassword": "新密码",
+    "newPasswordError": "确认新密码错误!",
+    "originalPassword": "原密码",
+    "pleaseEnterNewPassword": "请输入新密码",
+    "pleaseEnterOriginalPassword": "请输入原密码"
+  },
+  "homePage": {
+    "aboutUs": "关于我们",
+    "energyConsumptionCommander": "能耗指挥官",
+    "homePage": "首页",
+    "productIntroduction": "产品介绍",
+    "thermalBalance": "冷热平衡",
+    "tryNow": "立即体验"
+  },
   "hvacHome": {},
   "keywordLibrary": {},
   "largeScreen": {},
@@ -548,6 +570,13 @@
     "selectTimeRange": "选择时间段",
     "smartControlLogs": "智控日志"
   },
+  "logView": {
+    "account": "账号",
+    "hvacIntelligentControlPlatform": "暖通智控平台",
+    "invalidPhoneNumberFormat": "手机号格式错误",
+    "login": "登陆",
+    "pleaseEnterMobileNumber": "请输入手机号"
+  },
   "navigation": {
     "alarmManage": "事件响应",
     "algorithmManage": "算法管理",

+ 32 - 13
src/views/login-component/LoginView.vue

@@ -6,7 +6,7 @@ import SvgIcon from '@/components/SvgIcon.vue';
 import { useRequest } from '@/hooks/request';
 import { useUserInfoStore } from '@/stores/user-info';
 import { t } from '@/i18n';
-import { loginUser } from '@/api';
+import { getNeedFirstWizard, loginUser } from '@/api';
 
 import { setToken } from '../../utils/auth';
 
@@ -26,7 +26,7 @@ const rules: Record<string, Rule[]> = {
     {
       validator: (_rule: unknown, value: string) => {
         if (!isValidPhone(value)) {
-          return Promise.reject('手机号格式错误');
+          return Promise.reject(t('logView.invalidPhoneNumberFormat'));
         }
         return Promise.resolve();
       },
@@ -46,24 +46,33 @@ const addLog = () => {
     if (access_token) {
       saveToken(access_token);
       setToken(access_token);
-      router.push('/env-monitor/index');
+      const data = await getNeedFirstWizard();
+      if (data) {
+        router.push('/first-usage');
+      } else {
+        router.push('/env-monitor/index');
+      }
     }
   });
 };
+
+const clickReturn = () => {
+  router.push('/index');
+};
 </script>
 
 <template>
   <div>
     <AFlex>
       <div class="login-bgc">
-        <AButton type="text" @click="$router.go(-1)">
-          <AFlex align="center"> <SvgIcon class="icon-left" name="left" /> 返回 </AFlex>
+        <AButton type="text" @click="clickReturn">
+          <AFlex align="center"> <SvgIcon class="icon-left" name="left" /> {{ t('common.return') }} </AFlex>
         </AButton>
       </div>
 
       <AFlex class="login-div" align="center">
         <div>
-          <div class="login-title">暖通智控平台</div>
+          <div class="login-title">{{ t('logView.hvacIntelligentControlPlatform') }}</div>
           <AForm
             ref="formRef"
             :colon="false"
@@ -72,22 +81,30 @@ const addLog = () => {
             :rules="rules"
             :hide-required-mark="true"
           >
-            <AFormItem label="账号" name="mobile">
-              <AInput class="input-width" v-model:value="loginForm.mobile" placeholder="请输入手机号">
+            <AFormItem :label="t('logView.account')" name="mobile">
+              <AInput
+                class="input-width"
+                v-model:value="loginForm.mobile"
+                :placeholder="t('logView.pleaseEnterMobileNumber')"
+              >
                 <template #prefix>
-                  <SvgIcon name="calendar" class="icon-style" />
+                  <SvgIcon name="a-accountnumber" class="icon-style" />
                 </template>
               </AInput>
             </AFormItem>
-            <AFormItem label="密码" name="password">
-              <AInput class="input-width" v-model:value="loginForm.password" placeholder="请输入密码">
+            <AFormItem :label="t('userManage.password')" name="password">
+              <AInput
+                class="input-width"
+                v-model:value="loginForm.password"
+                :placeholder="t('registerGateway.pleasePassword')"
+              >
                 <template #prefix>
-                  <SvgIcon name="calendar" class="icon-style" />
+                  <SvgIcon name="password" class="icon-style" />
                 </template>
               </AInput>
             </AFormItem>
           </AForm>
-          <AButton type="primary" class="button-style" @click="addLog">登陆</AButton>
+          <AButton type="primary" class="button-style" @click="addLog">{{ t('logView.login') }}</AButton>
         </div>
       </AFlex>
     </AFlex>
@@ -103,6 +120,8 @@ const addLog = () => {
 
 .icon-style {
   margin-right: 10px;
+  font-size: 24px;
+  color: #999;
 }
 
 .button-style {