diff --git a/console/src/App.vue b/console/src/App.vue index 1a25ec082..49b30d27e 100644 --- a/console/src/App.vue +++ b/console/src/App.vue @@ -13,12 +13,12 @@ import { } from "overlayscrollbars-vue"; import type { FormKitConfig } from "@formkit/core"; import { i18n } from "./locales"; +import { AppName } from "./constants/app"; const { t } = useI18n(); const { configMap } = storeToRefs(useSystemConfigMapStore()); -const AppName = "Halo"; const route = useRoute(); const title = useTitle(); diff --git a/console/src/components/login/LoginForm.vue b/console/src/components/login/LoginForm.vue index b73d82e94..2a8fd66b0 100644 --- a/console/src/components/login/LoginForm.vue +++ b/console/src/components/login/LoginForm.vue @@ -11,14 +11,18 @@ import { submitForm } from "@formkit/core"; import { JSEncrypt } from "jsencrypt"; import { apiClient } from "@/utils/api-client"; import { useI18n } from "vue-i18n"; -import { useQuery } from "@tanstack/vue-query"; -import type { - GlobalInfo, - SocialAuthProvider, -} from "@/modules/system/actuator/types"; const { t } = useI18n(); +withDefaults( + defineProps<{ + buttonText?: string; + }>(), + { + buttonText: "core.login.button", + } +); + const emit = defineEmits<{ (event: "succeed"): void; }>(); @@ -104,22 +108,9 @@ onMounted(() => { handleGenerateToken(); }); -// auth providers -// fixme: Needs to be saved in Pinia. -const { data: socialAuthProviders } = useQuery({ - queryKey: ["social-auth-providers"], - queryFn: async () => { - const { data } = await axios.get( - `${import.meta.env.VITE_API_URL}/actuator/globalinfo`, - { - withCredentials: true, - } - ); - - return data.socialAuthProviders; - }, - refetchOnWindowFocus: false, -}); +const inputClasses = { + outer: "!py-3 first:!pt-0 last:!pb-0", +}; diff --git a/console/src/components/login/LoginModal.vue b/console/src/components/login/LoginModal.vue index b9e389851..1bcd6f272 100644 --- a/console/src/components/login/LoginModal.vue +++ b/console/src/components/login/LoginModal.vue @@ -3,6 +3,7 @@ import { Toast, VModal } from "@halo-dev/components"; import LoginForm from "@/components/login/LoginForm.vue"; import { useUserStore } from "@/stores/user"; import { useI18n } from "vue-i18n"; +import SocialAuthProviders from "./SocialAuthProviders.vue"; const userStore = useUserStore(); const { t } = useI18n(); @@ -27,5 +28,6 @@ const onLoginSucceed = () => { @update:visible="onVisibleChange" > + diff --git a/console/src/components/login/SocialAuthProviderItem.vue b/console/src/components/login/SocialAuthProviderItem.vue new file mode 100644 index 000000000..a93bff310 --- /dev/null +++ b/console/src/components/login/SocialAuthProviderItem.vue @@ -0,0 +1,58 @@ + + + diff --git a/console/src/components/login/SocialAuthProviders.vue b/console/src/components/login/SocialAuthProviders.vue new file mode 100644 index 000000000..8cb04b35f --- /dev/null +++ b/console/src/components/login/SocialAuthProviders.vue @@ -0,0 +1,30 @@ + + + diff --git a/console/src/components/signup/SignupForm.vue b/console/src/components/signup/SignupForm.vue index 514ae4b7e..ef8db20d2 100644 --- a/console/src/components/signup/SignupForm.vue +++ b/console/src/components/signup/SignupForm.vue @@ -1,6 +1,6 @@ diff --git a/console/src/composables/use-global-info.ts b/console/src/composables/use-global-info.ts new file mode 100644 index 000000000..c4c1fc461 --- /dev/null +++ b/console/src/composables/use-global-info.ts @@ -0,0 +1,24 @@ +import type { GlobalInfo } from "@/modules/system/actuator/types"; +import { useQuery } from "@tanstack/vue-query"; +import axios from "axios"; + +export function useGlobalInfoFetch() { + const { data } = useQuery({ + queryKey: ["globalinfo"], + queryFn: async () => { + const { data } = await axios.get( + `${import.meta.env.VITE_API_URL}/actuator/globalinfo`, + { + withCredentials: true, + } + ); + + return data; + }, + refetchOnWindowFocus: false, + }); + + return { + globalInfo: data, + }; +} diff --git a/console/src/constants/app.ts b/console/src/constants/app.ts new file mode 100644 index 000000000..f87d81822 --- /dev/null +++ b/console/src/constants/app.ts @@ -0,0 +1 @@ +export const AppName = "Halo"; diff --git a/console/src/locales/en.yaml b/console/src/locales/en.yaml index a2378484b..ace48c6dd 100644 --- a/console/src/locales/en.yaml +++ b/console/src/locales/en.yaml @@ -4,19 +4,22 @@ core: fields: username: placeholder: Username - validation: Please enter username password: placeholder: Password - validation: Please enter password operations: submit: toast_success: Login successful toast_failed: Login failed, incorrect username or password toast_csrf: CSRF Token expired, please try again + signup: + label: No account + button: Sign up + return_login: + label: Already have an account + button: Sign in button: Login modal: title: Re-login - other_login: "Other login:" signup: title: Sign up fields: @@ -34,6 +37,17 @@ core: toast_success: Sign up successfully binding: title: Account binding + common: + toast: + mounted: The current login method is not bound to an account, Please bind or sign up a new account first + operations: + login_and_bind: + button: Login and Bind + signup_and_bind: + button: Signup and Bind + bind: + toast_success: Binding successfully + toast_failed: Binding failed, no enabled login method found sidebar: search: placeholder: Search @@ -891,6 +905,7 @@ core: disable_privileged: tooltip: The authentication method reserved by the system cannot be disabled detail: + title: Identity authentication detail fields: display_name: Display name description: Description @@ -1051,6 +1066,8 @@ core: pagination: page_label: page size_label: items per page + social_auth_providers: + title: Third-party login composables: content_cache: toast_recovered: Recovered unsaved content from cache diff --git a/console/src/locales/zh-CN.yaml b/console/src/locales/zh-CN.yaml index fb1c7fb26..00f4abba9 100644 --- a/console/src/locales/zh-CN.yaml +++ b/console/src/locales/zh-CN.yaml @@ -4,19 +4,22 @@ core: fields: username: placeholder: 用户名 - validation: 请输入用户名 password: placeholder: 密码 - validation: 请输入密码 operations: submit: toast_success: 登录成功 toast_failed: 登录失败,用户名或密码错误 toast_csrf: CSRF Token 失效,请重新尝试 + signup: + label: 没有账号 + button: 立即注册 + return_login: + label: 已有账号 + button: 立即登录 button: 登录 modal: title: 重新登录 - other_login: 其他登录: signup: title: 注册 fields: @@ -34,6 +37,17 @@ core: toast_success: 注册成功 binding: title: 账号绑定 + common: + toast: + mounted: 当前登录方式未绑定账号,请先绑定或注册新账号 + operations: + login_and_bind: + button: 登录并绑定 + signup_and_bind: + button: 注册并绑定 + bind: + toast_success: 绑定成功 + toast_failed: 绑定失败,没有找到已启用的登录方式 sidebar: search: placeholder: 搜索 @@ -891,6 +905,7 @@ core: disable_privileged: tooltip: 系统保留的认证方式,无法禁用 detail: + title: 身份认证详情 fields: display_name: 名称 description: 描述 @@ -1051,6 +1066,8 @@ core: pagination: page_label: 页 size_label: 条 / 页 + social_auth_providers: + title: 三方登录 composables: content_cache: toast_recovered: 已从缓存中恢复未保存的内容 diff --git a/console/src/modules/system/auth-providers/module.ts b/console/src/modules/system/auth-providers/module.ts index 2feea3f23..d83a348ab 100644 --- a/console/src/modules/system/auth-providers/module.ts +++ b/console/src/modules/system/auth-providers/module.ts @@ -14,7 +14,7 @@ export default definePlugin({ name: "AuthProviders", component: AuthProviders, meta: { - title: "认证方式", + title: "core.identity_authentication.title", searchable: true, }, }, @@ -23,7 +23,7 @@ export default definePlugin({ name: "AuthProviderDetail", component: AuthProviderDetail, meta: { - title: "认证方式详情", + title: "core.identity_authentication.detail.title", }, }, ], diff --git a/console/src/modules/system/users/Binding.vue b/console/src/modules/system/users/Binding.vue index 7fbdbff93..cffe4f95e 100644 --- a/console/src/modules/system/users/Binding.vue +++ b/console/src/modules/system/users/Binding.vue @@ -1,19 +1,19 @@