refactor: support i18n in frontend
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
} from '@/api/admin';
|
||||
import TokenItem from '@/components/admin/TokenItem.vue';
|
||||
import UserItem from '@/components/admin/UserItem.vue';
|
||||
import { i18n } from '@/utils/i18n';
|
||||
|
||||
const token = useTokenStore();
|
||||
const messagebox = ref<InstanceType<typeof MessageBox>>();
|
||||
@@ -54,10 +55,10 @@ const changePassword = async () => {
|
||||
|
||||
const rv = await apiProfileChangePassword(token.currentToken, newpassword);
|
||||
if (rv) {
|
||||
messagebox.value?.show("Operation OK.");
|
||||
messagebox.value?.show(i18n.global.t('js-success'));
|
||||
profilePendingPassword.value = "";
|
||||
} else {
|
||||
messagebox.value?.show("An update operation failed. It may caused by wrong arguments or lost target. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
messagebox.value?.show(i18n.global.t('js-fail-update'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ const refreshTokenList = async () => {
|
||||
const deleteTokenItem = async (uuid: string) => {
|
||||
const rv = await apiProfileDeleteToken(token.currentToken, uuid);
|
||||
if (!rv) {
|
||||
messagebox.value?.show("A delete operation failed. It may caused by no matched item. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
messagebox.value?.show(i18n.global.t('js-fail-delete'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ const addUser = async () => {
|
||||
|
||||
const rv = await apiAdminAdd(token.currentToken, username);
|
||||
if (typeof rv === 'undefined') {
|
||||
messagebox.value?.show("An add operation failed. It may caused by wrong arguments. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
messagebox.value?.show(i18n.global.t('js-fail-add'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,7 +134,7 @@ const addUser = async () => {
|
||||
const deleteUser = async (username: string) => {
|
||||
const rv = await apiAdminDel(token.currentToken, username);
|
||||
if (!rv) {
|
||||
messagebox.value?.show("A delete operation failed. It may caused by no matched item. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
messagebox.value?.show(i18n.global.t('js-fail-delete'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,7 +148,7 @@ const updateUser = async (username: string, newPassword: string, newIsAdmin: boo
|
||||
|
||||
const rv = await apiAdminUpdate(token.currentToken, username, passwordArg, isAdminArg);
|
||||
if (!rv) {
|
||||
messagebox.value?.show("An update operation failed. It may caused by wrong arguments or lost target. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
messagebox.value?.show(i18n.global.t('js-fail-update'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -163,15 +164,15 @@ const updateUser = async (username: string, newPassword: string, newIsAdmin: boo
|
||||
<div class="container" style="margin-top: 20px;">
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li :class="{ 'is-active': activeTab === 1 }" @click="activeTab = 1"><a>My Profile</a></li>
|
||||
<li :class="{ 'is-active': activeTab === 2 }" @click="activeTab = 2"><a>Manage Multi-login</a></li>
|
||||
<li v-if="showUserTab" :class="{ 'is-active': activeTab === 3 }" @click="activeTab = 3"><a>Manager User</a></li>
|
||||
<li :class="{ 'is-active': activeTab === 1 }" @click="activeTab = 1"><a>{{ $t('admin-tabcontrol-tabProfile') }}</a></li>
|
||||
<li :class="{ 'is-active': activeTab === 2 }" @click="activeTab = 2"><a>{{ $t('admin-tabcontrol-tabToken') }}</a></li>
|
||||
<li v-if="showUserTab" :class="{ 'is-active': activeTab === 3 }" @click="activeTab = 3"><a>{{ $t('admin-tabcontrol-tabUserList') }}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="activeTab === 1" class="container" style="margin-top: 20px;">
|
||||
<h1 class="title">Change Password</h1>
|
||||
<h1 class="title">{{ $t('admin-changePassword') }}</h1>
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
<input v-model="profilePendingPassword" class="input" type="password">
|
||||
@@ -185,9 +186,8 @@ const updateUser = async (username: string, newPassword: string, newIsAdmin: boo
|
||||
</div>
|
||||
|
||||
<div v-show="activeTab === 2" class="container" style="margin-top: 20px;">
|
||||
<h1 class="title">Manage multi-login</h1>
|
||||
<h2 class="subtitle">Manage the multi-login of the current account. You can forced logout some login in
|
||||
there.</h2>
|
||||
<h1 class="title">{{ $t('admin-manageToken') }}</h1>
|
||||
<h2 class="subtitle">{{ $t('admin-manageToken-desc') }}</h2>
|
||||
<div class="control" @click="refreshTokenList">
|
||||
<a class="button is-primary">
|
||||
<span class="icon is-small"><font-awesome-icon icon="fas fa-sync"></font-awesome-icon></span>
|
||||
@@ -205,7 +205,7 @@ const updateUser = async (username: string, newPassword: string, newIsAdmin: boo
|
||||
</div>
|
||||
|
||||
<div v-show="activeTab === 3" class="container" style="margin-top: 20px;">
|
||||
<h1 class="title">User List</h1>
|
||||
<h1 class="title">{{ $t('admin-userList') }}</h1>
|
||||
<div class="button-list">
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
|
||||
Reference in New Issue
Block a user