Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+6
-7
@@ -1,11 +1,10 @@
|
||||
# 앱(Capacitor) 빌드 전용 환경변수 — `vite build --mode capacitor` 가 로드합니다.
|
||||
# 앱 안에서는 상대경로(/api)가 서버로 가지 않으므로 백엔드 절대 URL 을 지정해야 합니다.
|
||||
#
|
||||
# [로컬 + 에뮬레이터 테스트] 에뮬레이터에서 10.0.2.2 = PC의 localhost
|
||||
VITE_API_BASE_URL=http://10.0.2.2:8080/api
|
||||
# [운영 서버 HTTPS] app.sblog.kr 의 /api 를 Nginx 가 백엔드로 프록시
|
||||
VITE_API_BASE_URL=https://app.sblog.kr/api
|
||||
#
|
||||
# [실기기 테스트] 같은 Wi-Fi 의 PC LAN IP 로 (예)
|
||||
# VITE_API_BASE_URL=http://192.168.0.10:8080/api
|
||||
#
|
||||
# [배포 서버(HTTPS)] 운영 시
|
||||
# VITE_API_BASE_URL=https://yourdomain.com/api
|
||||
# [로컬 PC + 실기기] 같은 Wi-Fi
|
||||
# VITE_API_BASE_URL=http://172.30.1.43:8080/api
|
||||
# [에뮬레이터]
|
||||
# VITE_API_BASE_URL=http://10.0.2.2:8080/api
|
||||
|
||||
@@ -13,17 +13,18 @@ function goSignup() {
|
||||
ui.openSignup()
|
||||
}
|
||||
|
||||
const form = reactive({ loginId: '', password: '' })
|
||||
const form = reactive({ loginId: '', password: '', rememberMe: true })
|
||||
const loading = ref(false)
|
||||
const error = ref(null)
|
||||
|
||||
// 팝업이 열릴 때마다 입력값 초기화
|
||||
// 팝업이 열릴 때마다 입력값 초기화 (로그인 상태 유지는 기본 켜둠)
|
||||
watch(
|
||||
() => ui.loginOpen,
|
||||
(open) => {
|
||||
if (open) {
|
||||
form.loginId = ''
|
||||
form.password = ''
|
||||
form.rememberMe = true
|
||||
error.value = null
|
||||
}
|
||||
},
|
||||
@@ -37,7 +38,7 @@ async function handleLogin() {
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
await auth.login(form.loginId, form.password)
|
||||
await auth.login(form.loginId, form.password, form.rememberMe)
|
||||
const redirect = ui.redirectPath
|
||||
ui.closeLogin()
|
||||
if (redirect) router.push(redirect)
|
||||
@@ -71,6 +72,10 @@ onUnmounted(() => window.removeEventListener('keydown', onKeydown))
|
||||
<form class="form" @submit.prevent="handleLogin">
|
||||
<input v-model="form.loginId" type="text" placeholder="아이디" autocomplete="username" :disabled="loading" />
|
||||
<input v-model="form.password" type="password" placeholder="비밀번호" autocomplete="current-password" :disabled="loading" />
|
||||
<label class="remember">
|
||||
<input v-model="form.rememberMe" type="checkbox" :disabled="loading" />
|
||||
로그인 상태 유지
|
||||
</label>
|
||||
<button class="submit" type="submit" :disabled="loading">{{ loading ? '로그인 중...' : '로그인' }}</button>
|
||||
</form>
|
||||
|
||||
@@ -141,6 +146,18 @@ h2 {
|
||||
background: var(--color-background-soft);
|
||||
color: var(--color-text);
|
||||
}
|
||||
.remember {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
font-size: 0.88rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.remember input {
|
||||
width: auto;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.submit,
|
||||
.naver {
|
||||
padding: 0.6rem 1rem;
|
||||
|
||||
+2
-2
@@ -20,8 +20,8 @@ export const useAuthStore = defineStore('auth', () => {
|
||||
else localStorage.removeItem(USER_KEY)
|
||||
}
|
||||
|
||||
async function login(loginId, password) {
|
||||
const res = await authApi.login({ loginId, password })
|
||||
async function login(loginId, password, rememberMe = false) {
|
||||
const res = await authApi.login({ loginId, password, rememberMe })
|
||||
token.value = res.token
|
||||
user.value = res.member
|
||||
persist()
|
||||
|
||||
Reference in New Issue
Block a user