feat: complete web application — FastAPI backend + Vue 3 SPA frontend
- Full FastAPI backend with JWT auth, file management, processing pipeline, memory CRUD, barcode mappings, config management, cloud sync - Vue 3 + Element Plus frontend with dashboard, task history, HTTP logs, memory editor, barcode editor, config editor, sync page - HTTP request logging middleware with SQLite persistence - Task history tracking with progress and retry support - File metadata recording for upload/download operations - WebAuth section in config.ini for bcrypt password storage - Bug fix: logs.py count query returns tuple not dict Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import api from '../api'
|
||||
|
||||
export const useAuthStore = defineStore('auth', () => {
|
||||
const token = ref(localStorage.getItem('token') || '')
|
||||
const username = ref('')
|
||||
|
||||
const isAuthenticated = computed(() => !!token.value)
|
||||
|
||||
async function login(user: string, password: string) {
|
||||
const res = await api.post('/auth/login', { username: user, password })
|
||||
token.value = res.data.access_token
|
||||
localStorage.setItem('token', token.value)
|
||||
username.value = user
|
||||
}
|
||||
|
||||
function logout() {
|
||||
token.value = ''
|
||||
username.value = ''
|
||||
localStorage.removeItem('token')
|
||||
}
|
||||
|
||||
async function fetchUser() {
|
||||
try {
|
||||
const res = await api.get('/auth/me')
|
||||
username.value = res.data.username
|
||||
} catch {
|
||||
logout()
|
||||
}
|
||||
}
|
||||
|
||||
return { token, username, isAuthenticated, login, logout, fetchUser }
|
||||
})
|
||||
Reference in New Issue
Block a user