feat: 号池操作列可以重新登录这个账号
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { NButton, NIcon, NInput, NModal, NTooltip, useDialog } from "naive-ui";
|
||||
import { CheckmarkCircleOutline, TrashOutline } from "@vicons/ionicons5";
|
||||
import { CheckmarkCircleOutline, LogInOutline, TrashOutline } from "@vicons/ionicons5";
|
||||
import Shell from "../../shell/Shell.vue";
|
||||
import LoginView from "../auth/LoginView.vue";
|
||||
import { api } from "../../shared/http";
|
||||
@@ -19,6 +19,7 @@ interface Account {
|
||||
const accounts = ref<Account[]>([]);
|
||||
const keyword = ref("");
|
||||
const show = ref(false);
|
||||
const relogin = ref("");
|
||||
const checkingAll = ref(false);
|
||||
const checkingId = ref<number | null>(null);
|
||||
const dialog = useDialog();
|
||||
@@ -87,6 +88,16 @@ async function remove(id: number) {
|
||||
}
|
||||
}
|
||||
|
||||
function openAdd() {
|
||||
relogin.value = "";
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
function openRelogin(account: Account) {
|
||||
relogin.value = account.loginId;
|
||||
show.value = true;
|
||||
}
|
||||
|
||||
function confirmRemove(account: Account) {
|
||||
dialog.warning({
|
||||
title: "删除账号",
|
||||
@@ -109,7 +120,7 @@ onMounted(load);
|
||||
<div class="page-head-actions">
|
||||
<n-input v-model:value="keyword" clearable placeholder="搜索账号、姓名或地市" />
|
||||
<n-button :loading="checkingAll" @click="checkAll">检查</n-button>
|
||||
<n-button type="primary" @click="show = true">添加账号</n-button>
|
||||
<n-button type="primary" @click="openAdd">添加账号</n-button>
|
||||
</div>
|
||||
</header>
|
||||
<div class="admin-scroll">
|
||||
@@ -144,6 +155,14 @@ onMounted(load);
|
||||
</template>
|
||||
检查
|
||||
</n-tooltip>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="重新登录" @click="openRelogin(account)">
|
||||
<template #icon><n-icon :component="LogInOutline" /></template>
|
||||
</n-button>
|
||||
</template>
|
||||
重新登录
|
||||
</n-tooltip>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button size="small" quaternary circle aria-label="删除" @click="confirmRemove(account)">
|
||||
@@ -163,8 +182,8 @@ onMounted(load);
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<n-modal v-model:show="show" class="app-dialog" preset="card" title="添加账号">
|
||||
<LoginView purpose="pool" @done="show = false; load()" />
|
||||
<n-modal v-model:show="show" class="app-dialog" preset="card" :title="relogin ? '重新登录' : '添加账号'">
|
||||
<LoginView :key="relogin || 'new'" purpose="pool" :account="relogin || undefined" @done="show = false; load()" />
|
||||
</n-modal>
|
||||
</Shell>
|
||||
</template>
|
||||
|
||||
@@ -8,13 +8,13 @@ import ThemeButton from "../../shell/ThemeButton.vue";
|
||||
import "./login-gate.css";
|
||||
|
||||
const BROKEN_CAPTCHA = "data:,";
|
||||
const props = defineProps<{ purpose?: "login" | "pool" }>();
|
||||
const props = defineProps<{ purpose?: "login" | "pool"; account?: string }>();
|
||||
const emit = defineEmits<{ done: [] }>();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const toast = useToast();
|
||||
const mode = ref("local");
|
||||
const username = ref("");
|
||||
const username = ref(props.account || "");
|
||||
const password = ref("");
|
||||
const captcha = ref("");
|
||||
const captchaUrl = ref("");
|
||||
@@ -189,7 +189,7 @@ async function startNqi() {
|
||||
try {
|
||||
const result = await api<{ status: string; token?: string; user?: { role: string; name: string }; sessionId?: string; captcha?: string }>("/api/auth/nqi/start", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ username: username.value, purpose: props.purpose || "login" }),
|
||||
body: JSON.stringify({ username: username.value, purpose: props.purpose || "login", lockAccount: Boolean(props.account) }),
|
||||
});
|
||||
if (result.status === "ok" && result.token && result.user) {
|
||||
saveSession(result.token, result.user);
|
||||
@@ -324,7 +324,7 @@ async function finishNqi() {
|
||||
<p v-if="noticeVisible" class="lv-notice">请使用大数据平台账号登录</p>
|
||||
<form class="lv-fields" @submit.prevent="submitLogin">
|
||||
<label for="pool-account">账号</label>
|
||||
<n-input :input-props="{ id: 'pool-account', autocomplete: 'username' }" v-model:value="username" @keyup.enter="submitLogin" />
|
||||
<n-input :input-props="{ id: 'pool-account', autocomplete: 'username' }" v-model:value="username" :disabled="Boolean(account)" @keyup.enter="submitLogin" />
|
||||
<label for="pool-password">密码</label>
|
||||
<n-input :input-props="{ id: 'pool-password', autocomplete: 'current-password' }" v-model:value="password" type="password" show-password-on="click" @keyup.enter="submitLogin" />
|
||||
<label for="pool-captcha">验证码</label>
|
||||
@@ -335,7 +335,7 @@ async function finishNqi() {
|
||||
<img v-else :src="captchaSrc" :class="{ broken: captchaSrc === BROKEN_CAPTCHA }" alt="验证码" @error="markCaptchaBroken" />
|
||||
</button>
|
||||
</div>
|
||||
<n-button class="lv-go" type="primary" attr-type="submit" :loading="busy">添加</n-button>
|
||||
<n-button class="lv-go" type="primary" attr-type="submit" :loading="busy">{{ account ? "登录" : "添加" }}</n-button>
|
||||
</form>
|
||||
</section>
|
||||
<div v-else class="gate lv-tower">
|
||||
|
||||
Reference in New Issue
Block a user