cutechicken commited on
Commit
eb62174
Β·
verified Β·
1 Parent(s): 7e1ea6f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +20 -29
index.html CHANGED
@@ -322,32 +322,24 @@
322
  state.token = token;
323
  console.log('인증 μ‹œλ„ (토큰 일뢀):', token.substring(0, 4) + '...');
324
 
325
- try {
326
- // μ‚¬μš©μž 정보 κ°€μ Έμ˜€κΈ° μ‹œλ„
327
- const userInfo = await fetchUserInfo();
328
- console.log('μ‚¬μš©μž 정보:', userInfo);
329
-
330
- // μ‚¬μš©μž 이름 μΆ”μΆœ (API 응닡 ꡬ쑰에 따라 λ‹€λ₯Ό 수 있음)
331
- if (userInfo.name) {
332
- state.username = userInfo.name;
333
- } else if (userInfo.user && userInfo.user.username) {
334
- state.username = userInfo.user.username;
335
- } else if (userInfo.username) {
336
- state.username = userInfo.username;
337
- } else {
338
- state.username = '인증된 μ‚¬μš©μž';
339
- }
340
-
341
- // μ’‹μ•„μš” λͺ©λ‘ κ°€μ Έμ˜€κΈ°
342
- state.likedModels = await fetchLikedRepos();
343
- } catch (error) {
344
- console.warn('API 호좜 μ‹€νŒ¨, ν…ŒμŠ€νŠΈ λͺ¨λ“œλ‘œ μ „ν™˜:', error);
345
-
346
- // API 호좜이 μ‹€νŒ¨ν•΄λ„ ν…ŒμŠ€νŠΈ λͺ¨λ“œλ‘œ μ§„ν–‰
347
- state.username = 'ν…ŒμŠ€νŠΈ μ‚¬μš©μž';
348
- state.likedModels = {};
349
  }
350
 
 
 
 
351
  // UI μ—…λ°μ΄νŠΈ
352
  elements.authStatus.textContent = `${state.username}λ‹˜μœΌλ‘œ 인증됨`;
353
  elements.tokenInput.style.display = 'none';
@@ -401,21 +393,20 @@
401
  setLoading(true);
402
 
403
  try {
404
- // API 호좜 없이 UI만 λ³€κ²½ (ν…ŒμŠ€νŠΈμš©)
405
- // μ‹€μ œ μ„œλΉ„μŠ€μ—μ„œλŠ” μ•„λž˜ 주석을 ν•΄μ œν•˜κ³  API 호좜 μΆ”κ°€
406
- // await toggleLikeAPI(modelInfo.type, modelInfo.owner, modelInfo.repo, isCurrentlyLiked);
407
 
408
  // μƒνƒœ μ—…λ°μ΄νŠΈ
409
  if (isCurrentlyLiked) {
410
  delete state.likedModels[modelId];
411
  button.classList.remove("liked");
412
  button.classList.add("not-liked");
413
- showMessage(`${modelInfo.repo}에 λŒ€ν•œ μ’‹μ•„μš”λ₯Ό μ·¨μ†Œν–ˆμŠ΅λ‹ˆλ‹€. (ν…ŒμŠ€νŠΈ λͺ¨λ“œ)`);
414
  } else {
415
  state.likedModels[modelId] = true;
416
  button.classList.add("liked");
417
  button.classList.remove("not-liked");
418
- showMessage(`${modelInfo.repo}λ₯Ό μ’‹μ•„μš” ν–ˆμŠ΅λ‹ˆλ‹€. (ν…ŒμŠ€νŠΈ λͺ¨λ“œ)`);
419
  }
420
  } catch (error) {
421
  showMessage('μ’‹μ•„μš” 처리 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.', true);
 
322
  state.token = token;
323
  console.log('인증 μ‹œλ„ (토큰 일뢀):', token.substring(0, 4) + '...');
324
 
325
+ // μ‚¬μš©μž 정보 κ°€μ Έμ˜€κΈ°
326
+ const userInfo = await fetchUserInfo();
327
+ console.log('μ‚¬μš©μž 정보:', userInfo);
328
+
329
+ // μ‚¬μš©μž 이름 μΆ”μΆœ (API 응닡 ꡬ쑰에 따라 λ‹€λ₯Ό 수 있음)
330
+ if (userInfo.name) {
331
+ state.username = userInfo.name;
332
+ } else if (userInfo.user && userInfo.user.username) {
333
+ state.username = userInfo.user.username;
334
+ } else if (userInfo.username) {
335
+ state.username = userInfo.username;
336
+ } else {
337
+ state.username = '인증된 μ‚¬μš©μž';
 
 
 
 
 
 
 
 
 
 
 
338
  }
339
 
340
+ // μ‹€μ œ μ’‹μ•„μš” λͺ©λ‘ κ°€μ Έμ˜€κΈ°
341
+ state.likedModels = await fetchLikedRepos();
342
+
343
  // UI μ—…λ°μ΄νŠΈ
344
  elements.authStatus.textContent = `${state.username}λ‹˜μœΌλ‘œ 인증됨`;
345
  elements.tokenInput.style.display = 'none';
 
393
  setLoading(true);
394
 
395
  try {
396
+ // μ‹€μ œ API 호좜둜 μ’‹μ•„μš” μƒνƒœ ν† κΈ€
397
+ await toggleLikeAPI(modelInfo.type, modelInfo.owner, modelInfo.repo, isCurrentlyLiked);
 
398
 
399
  // μƒνƒœ μ—…λ°μ΄νŠΈ
400
  if (isCurrentlyLiked) {
401
  delete state.likedModels[modelId];
402
  button.classList.remove("liked");
403
  button.classList.add("not-liked");
404
+ showMessage(`${modelInfo.repo}에 λŒ€ν•œ μ’‹μ•„μš”λ₯Ό μ·¨μ†Œν–ˆμŠ΅λ‹ˆλ‹€.`);
405
  } else {
406
  state.likedModels[modelId] = true;
407
  button.classList.add("liked");
408
  button.classList.remove("not-liked");
409
+ showMessage(`${modelInfo.repo}λ₯Ό μ’‹μ•„μš” ν–ˆμŠ΅λ‹ˆλ‹€.`);
410
  }
411
  } catch (error) {
412
  showMessage('μ’‹μ•„μš” 처리 쀑 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.', true);