chore: 初始化项目 — uni-app + Vue3 + TypeScript 脚手架

This commit is contained in:
jacobxu666
2026-06-14 17:16:18 +08:00
commit 046e84a564
37 changed files with 13763 additions and 0 deletions
+156
View File
@@ -0,0 +1,156 @@
<template>
<view class="container">
<view class="header">
<text class="welcome">欢迎使用</text>
<text class="app-name">zhy-test</text>
</view>
<view class="form">
<view class="form-item">
<text class="label">账号</text>
<input
class="input"
v-model="form.username"
placeholder="请输入账号"
type="text"
/>
</view>
<view class="form-item">
<text class="label">密码</text>
<input
class="input"
v-model="form.password"
placeholder="请输入密码"
password
/>
</view>
<button class="btn-primary" @click="handleLogin" :disabled="loading">
{{ loading ? '登录中...' : '登 录' }}
</button>
<view class="tips">
<text>当前为演示版本,后端接口未配置时无法真实登录</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, reactive } from 'vue'
import { useUserStore } from '../../store/user'
import { showToast } from '../../utils'
const userStore = useUserStore()
const loading = ref(false)
const form = reactive({
username: '',
password: ''
})
async function handleLogin() {
if (!form.username || !form.password) {
showToast('请输入账号和密码')
return
}
loading.value = true
try {
await userStore.login({
username: form.username,
password: form.password
})
showToast('登录成功', 'success')
setTimeout(() => {
uni.switchTab({ url: '/pages/profile/profile' })
}, 1000)
} catch (err: any) {
console.error('登录失败:', err)
} finally {
loading.value = false
}
}
</script>
<style scoped>
.container {
padding: 60rpx 40rpx;
min-height: 100vh;
box-sizing: border-box;
background: #f5f5f5;
}
.header {
text-align: center;
margin-bottom: 80rpx;
padding-top: 40rpx;
}
.welcome {
display: block;
font-size: 32rpx;
color: #666;
margin-bottom: 20rpx;
}
.app-name {
display: block;
font-size: 56rpx;
font-weight: bold;
color: #333;
}
.form {
background: #fff;
border-radius: 20rpx;
padding: 40rpx;
}
.form-item {
margin-bottom: 40rpx;
}
.label {
display: block;
font-size: 28rpx;
color: #333;
margin-bottom: 16rpx;
}
.input {
width: 100%;
height: 80rpx;
padding: 0 20rpx;
background: #f8f8f8;
border-radius: 12rpx;
font-size: 28rpx;
box-sizing: border-box;
}
.btn-primary {
width: 100%;
height: 90rpx;
line-height: 90rpx;
background: #007aff;
color: #fff;
border-radius: 12rpx;
font-size: 32rpx;
margin-top: 20rpx;
}
.btn-primary[disabled] {
background: #99c9ff;
}
.tips {
margin-top: 30rpx;
text-align: center;
}
.tips text {
font-size: 24rpx;
color: #999;
}
</style>