Feat: optimize login ui

This commit is contained in:
unitwk 2023-12-27 16:27:24 +08:00
parent eeae5c93d0
commit 300ad76b46
5 changed files with 49 additions and 19 deletions

View File

@ -1,11 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { t } from "@/lang/i18n"; import { t } from "@/lang/i18n";
import { useLayoutContainerStore } from "@/stores/useLayoutContainerStore"; import { useLayoutContainerStore } from "@/stores/useLayoutContainerStore";
import { import { CloseCircleOutlined, ExclamationCircleOutlined } from "@ant-design/icons-vue";
CloseCircleOutlined,
ExclamationCircleOutlined,
InfoCircleOutlined
} from "@ant-design/icons-vue";
const { containerState } = useLayoutContainerStore(); const { containerState } = useLayoutContainerStore();
CloseCircleOutlined; CloseCircleOutlined;

View File

@ -152,8 +152,13 @@ export function useTerminal() {
termFitAddon.value = fitAddon; termFitAddon.value = fitAddon;
term.onData((data) => { term.onData((data) => {
socket?.emit("stream/stdin", { data }); socket?.emit("stream/write", {
data: {
input: data
}
});
}); });
term.writeln( term.writeln(
`${TERM_COLOR.TERM_TEXT_GREEN}[MCSManager] ${TERM_COLOR.TERM_TEXT_GRAY}Instance app terminal.${TERM_COLOR.TERM_RESET}` `${TERM_COLOR.TERM_TEXT_GREEN}[MCSManager] ${TERM_COLOR.TERM_TEXT_GRAY}Instance app terminal.${TERM_COLOR.TERM_RESET}`
); );

View File

@ -15,6 +15,7 @@ import { reportError } from "@/tools/validator";
import { useAppStateStore } from "@/stores/useAppStateStore"; import { useAppStateStore } from "@/stores/useAppStateStore";
import type { LayoutCard } from "@/types"; import type { LayoutCard } from "@/types";
import { markdownToHTML } from "@/tools/safe"; import { markdownToHTML } from "@/tools/safe";
import { message } from "ant-design-vue";
const { state: pageInfoResult, execute } = loginPageInfo(); const { state: pageInfoResult, execute } = loginPageInfo();
@ -36,6 +37,10 @@ const { updateUserInfo, isAdmin } = useAppStateStore();
const loginStep = ref(0); const loginStep = ref(0);
const handleLogin = async () => { const handleLogin = async () => {
if (!formData.username.trim() || !formData.password.trim()) {
return message.error(t("请完善账号信息!"));
}
loginStep.value++; loginStep.value++;
await sleep(1500); await sleep(1500);
@ -50,7 +55,6 @@ const handleLogin = async () => {
await updateUserInfo(); await updateUserInfo();
await loginSuccess(); await loginSuccess();
} catch (error: any) { } catch (error: any) {
console.log(error);
reportError(error.message ? error.message : error); reportError(error.message ? error.message : error);
loginStep.value--; loginStep.value--;
} }
@ -135,21 +139,22 @@ const loginSuccess = () => {
</a> </a>
</div> </div>
<a-button size="large" type="primary" style="min-width: 95px" @click="handleLogin"> <a-button size="large" type="primary" style="min-width: 95px" @click="handleLogin">
{{ t("TXT_CODE_940f7d5") }} {{ t("确定") }}
</a-button> </a-button>
</div> </div>
</div> </div>
</div> </div>
<div v-show="loginStep === 1" class="login-panel-body flex-center"> <div v-show="loginStep === 1" class="login-panel-body flex-center">
<div style="text-align: center"> <div style="text-align: center">
<LoadingOutlined :style="{ fontSize: '50px' }" /> <LoadingOutlined class="logging-icon" :style="{ fontSize: '62px', fontWeight: 800 }" />
</div> </div>
</div> </div>
<div v-show="loginStep >= 2" class="login-panel-body flex-center"> <div v-show="loginStep >= 2" class="login-panel-body flex-center">
<div style="text-align: center"> <div style="text-align: center">
<CheckCircleOutlined <CheckCircleOutlined
class="login-success-icon"
:style="{ :style="{
fontSize: '40px', fontSize: '68px',
color: 'var(--color-green-6)' color: 'var(--color-green-6)'
}" }"
/> />
@ -173,16 +178,10 @@ const loginSuccess = () => {
<style lang="scss" scoped> <style lang="scss" scoped>
.loginDone { .loginDone {
.login-page-container {
opacity: 0;
background-color: rgba(255, 255, 255, 0);
backdrop-filter: blur(0);
transform: scale(0.8) !important;
}
} }
.logging { .logging {
.login-panel { .login-panel {
transform: scale(0.8); transform: scale(0.96);
} }
} }
.login-panel { .login-panel {
@ -208,6 +207,30 @@ const loginSuccess = () => {
text-decoration: underline; text-decoration: underline;
} }
} }
.logging-icon {
animation: opacityAnimation 0.6s;
}
.login-success-icon {
animation: scaleAnimation 0.6s;
}
@keyframes opacityAnimation {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes scaleAnimation {
0% {
transform: scale(0);
}
100% {
transform: scale(1);
}
}
@keyframes moveAnimation { @keyframes moveAnimation {
0% { 0% {

View File

@ -23,6 +23,7 @@ import PingConfig from "./dialogs/PingConfig.vue";
import InstanceDetails from "./dialogs/InstanceDetails.vue"; import InstanceDetails from "./dialogs/InstanceDetails.vue";
import { GLOBAL_INSTANCE_NAME } from "../../config/const"; import { GLOBAL_INSTANCE_NAME } from "../../config/const";
import type { RouteLocationPathRaw } from "vue-router"; import type { RouteLocationPathRaw } from "vue-router";
import { TYPE_UNIVERSAL, TYPE_WEB_SHELL } from "../../hooks/useInstance";
const terminalConfigDialog = ref<InstanceType<typeof TermConfig>>(); const terminalConfigDialog = ref<InstanceType<typeof TermConfig>>();
const eventConfigDialog = ref<InstanceType<typeof EventConfig>>(); const eventConfigDialog = ref<InstanceType<typeof EventConfig>>();
const pingConfigDialog = ref<InstanceType<typeof PingConfig>>(); const pingConfigDialog = ref<InstanceType<typeof PingConfig>>();
@ -73,7 +74,12 @@ const btns = computed(() =>
{ {
title: t("TXT_CODE_d07742fe"), title: t("TXT_CODE_d07742fe"),
icon: ControlOutlined, icon: ControlOutlined,
condition: () => !isGlobalTerminal.value, condition: () => {
return (
!isGlobalTerminal.value &&
![TYPE_UNIVERSAL, TYPE_WEB_SHELL].includes(instanceInfo.value?.config.type || "")
);
},
click: (): void => { click: (): void => {
toPage({ toPage({
path: "/instances/terminal/serverConfig", path: "/instances/terminal/serverConfig",

View File

@ -526,7 +526,7 @@ function getDefaultFrontendLayoutConfig(): IPageLayoutConfig[] {
id: getRandomId(), id: getRandomId(),
meta: {}, meta: {},
type: "LoginCard", type: "LoginCard",
title: t("TXT_CODE_1f925226"), title: t("身份验证"),
width: 4, width: 4,
height: LayoutCardHeight.AUTO, height: LayoutCardHeight.AUTO,
disableDelete: true disableDelete: true