fix: update API endpoint for user login and adjust authentication logic in App component; modify rating display in MediaItem component
This commit is contained in:
@@ -120,12 +120,15 @@
|
||||
try {
|
||||
// 保存认证信息
|
||||
const auth = btoa(`${username}:${password}`);
|
||||
localStorage.setItem('auth', auth);
|
||||
|
||||
// 使用验证接口验证登录
|
||||
const response = await request.get<ApiResponse<{username: string}>>('/auth/verify');
|
||||
const response = await request.post<ApiResponse<{token: string}>>('/user/login', {
|
||||
username,
|
||||
password
|
||||
});
|
||||
|
||||
if (response.data.code === 0) {
|
||||
if (response.data.code === 200) {
|
||||
localStorage.setItem('auth', response.data.data.token);
|
||||
isAuthenticated = true;
|
||||
error = '';
|
||||
// 获取初始数据
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<div class="space-y-2 text-sm text-gray-600 flex justify-between">
|
||||
<p class="flex items-center gap-2">
|
||||
<span class="text-gray-500">评分:</span>
|
||||
<span class="flex items-center gap-1">{@html StarRating(media.rating ?? 0)}</span>
|
||||
<span class="flex items-center gap-1">{@html StarRating((media.rating ?? 0) / 2)}</span>
|
||||
</p>
|
||||
<p class="flex items-center gap-2">
|
||||
<span class="text-gray-500">日期:</span>
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
/*
|
||||
* @Date: 2025-05-26 17:39:36
|
||||
* @LastEditors: 陈子健
|
||||
* @LastEditTime: 2025-05-29 11:03:14
|
||||
* @LastEditTime: 2025-06-13 14:32:26
|
||||
* @FilePath: /my-score/frontend/src/lib/utils.ts
|
||||
*/
|
||||
export const StarRating = (rating: number, maxStars: number = 5) => {
|
||||
const stars = [];
|
||||
|
||||
for (let i = 1; i <= maxStars; i++) {
|
||||
const fill = i <= Math.floor(rating) ? '#FFD700' : 'white';
|
||||
const isHalfStar = i - 0.5 <= rating && rating < i;
|
||||
|
||||
if (isHalfStar) {
|
||||
console.log('isHalfStar', isHalfStar);
|
||||
stars.push(`
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Date: 2025-05-20 17:59:45
|
||||
* @LastEditors: 陈子健
|
||||
* @LastEditTime: 2025-05-20 18:04:34
|
||||
* @LastEditTime: 2025-06-13 14:07:41
|
||||
* @FilePath: /my-score/frontend/vite.config.ts
|
||||
*/
|
||||
import { defineConfig } from 'vite'
|
||||
@@ -13,7 +13,7 @@ export default defineConfig({
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://127.0.0.1:5000',
|
||||
target: 'http://127.0.0.1:8000',
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user