diff --git a/ui/env.js b/ui/env.js index 0a53ae3..820d544 100644 --- a/ui/env.js +++ b/ui/env.js @@ -4,19 +4,26 @@ import VBase from './vbase.js' export default async ($env) => { // Load i18n try { - const langs = await (await fetch('/langs.json')).json() + const langs = await (await fetch($env.scoped + '/langs.json')).json() $env.$i18n.load(langs) } catch (e) { console.error('Failed to load langs.json', e) } // Initialize VBase Service - const vbase = new VBase('vb', '/'); // Relative path + const vbase = new VBase('vb', $env.scoped); // Relative path $env.$vbase = vbase; - // Wrap Axios + // Wrap Axios: add auth header vbase.wrapAxios($env.$axios); + $env.$axios.interceptors.response.use(function(response) { + return response?.data + }, function(error) { + let data = error.response ? error.response.data : error.response + return Promise.reject(data?.message || data); + }); + // Router Guard $env.$router.beforeEnter = async (to, from, next) => { const isAuth = to.meta && to.meta.auth; diff --git a/ui/langs.json b/ui/langs.json index 029c169..8bcf1e5 100644 --- a/ui/langs.json +++ b/ui/langs.json @@ -41,6 +41,21 @@ "auth.register_failed": "Registration failed", "auth.invalid_response": "Invalid server response", "auth.oauth_not_ready": "{provider} login is not ready yet", + "auth.logging_in": "Logging in...", + "auth.back_to_login": "Back to Login", + "auth.bind_account": "Bind Account", + "auth.bind_new_desc": "Create a new account to bind with {provider}", + "auth.sign_up_bind": "Sign Up & Bind", + "auth.bind_existing": "Bind Existing", + "auth.bind_exist_desc": "Bind your {provider} to an existing account", + "auth.account": "Username/Email", + "auth.login_bind": "Login & Bind", + "auth.bind_login_tip": "To keep connected with us please login with your personal info", + "auth.bind_register_tip": "Enter your personal details and start journey with us", + "auth.bind_success": "Binding successful", + "auth.fill_required": "Please fill in all required fields", + "auth.username_required": "Username is required", + "common.processing": "Processing...", "common.actions": "Actions", "common.back": "Back", "common.cancel": "Cancel", @@ -199,7 +214,22 @@ "auth.register_success": "注册成功", "auth.register_failed": "注册失败", "auth.invalid_response": "服务器响应异常", - "auth.oauth_not_ready": "{provider} 登录暂未开放", + "auth.oauth_not_ready": "{provider} 登录尚未就绪", + "auth.logging_in": "登录中...", + "auth.back_to_login": "返回登录", + "auth.bind_account": "绑定账号", + "auth.bind_new_desc": "创建新账号并绑定 {provider}", + "auth.sign_up_bind": "注册并绑定", + "auth.bind_existing": "绑定已有账号", + "auth.bind_exist_desc": "将 {provider} 绑定到现有账号", + "auth.account": "用户名/邮箱", + "auth.login_bind": "登录并绑定", + "auth.bind_login_tip": "请登录您的个人账号以保持连接", + "auth.bind_register_tip": "输入您的个人信息,开启您的旅程", + "auth.bind_success": "绑定成功", + "auth.fill_required": "请填写所有必填项", + "auth.username_required": "用户名必填", + "common.processing": "处理中...", "common.actions": "操作", "common.back": "返回", "common.cancel": "取消", diff --git a/ui/layout/default.html b/ui/layout/default.html index bb45e0d..d1fac62 100644 --- a/ui/layout/default.html +++ b/ui/layout/default.html @@ -109,17 +109,9 @@