H5 支持 ?mp=1 嵌入微信 WebView;user-h5/admin-h5 底部展示蜀ICP备2025140386号-2 并链至工信部;补充小程序+H5 部署说明。 Co-authored-by: Cursor <cursoragent@cursor.com>
74 lines
2.0 KiB
Vue
74 lines
2.0 KiB
Vue
<script setup lang="ts">
|
|
import { ref } from 'vue'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import BrandLogo from '@/components/BrandLogo.vue'
|
|
import IcpFooter from '@/components/IcpFooter.vue'
|
|
import { useAuthStore } from '@/stores/auth'
|
|
|
|
const auth = useAuthStore()
|
|
const router = useRouter()
|
|
const route = useRoute()
|
|
const username = ref('admin')
|
|
const password = ref('')
|
|
const error = ref('')
|
|
const loading = ref(false)
|
|
|
|
async function onSubmit() {
|
|
error.value = ''
|
|
loading.value = true
|
|
try {
|
|
await auth.login(username.value.trim(), password.value)
|
|
const redirect = typeof route.query.redirect === 'string' ? route.query.redirect : '/'
|
|
await router.replace(redirect)
|
|
} catch (e) {
|
|
error.value = e instanceof Error ? e.message : '登录失败'
|
|
} finally {
|
|
loading.value = false
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="wrap">
|
|
<form class="card login" @submit.prevent="onSubmit">
|
|
<BrandLogo size="login" />
|
|
<h1>愈心谷</h1>
|
|
<p class="muted">内部运营工具</p>
|
|
<label class="field">
|
|
<span>用户名</span>
|
|
<input v-model="username" autocomplete="username" required />
|
|
</label>
|
|
<label class="field">
|
|
<span>密码</span>
|
|
<input v-model="password" type="password" autocomplete="current-password" required />
|
|
</label>
|
|
<p v-if="error" class="err">{{ error }}</p>
|
|
<button class="btn" type="submit" :disabled="loading">
|
|
{{ loading ? '登录中…' : '登录' }}
|
|
</button>
|
|
</form>
|
|
<IcpFooter />
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.wrap {
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 1.5rem;
|
|
}
|
|
.wrap :deep(.icp-footer) {
|
|
margin-top: auto;
|
|
width: 100%;
|
|
padding-bottom: 0.25rem;
|
|
}
|
|
.login { width: min(380px, 100%); text-align: center; }
|
|
.login :deep(.field) { text-align: left; }
|
|
h1 { margin: 0 0 0.25rem; font-size: 1.45rem; font-family: "Noto Serif SC", "Songti SC", serif; }
|
|
.muted { margin: 0 0 1.2rem; }
|
|
.btn { width: 100%; }
|
|
</style>
|