Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GitHub Stars Manager - AI-Powered Repository Management</title>
<meta name="description" content="Intelligent management of your GitHub starred repositories with AI-powered analysis and release tracking" />
<!-- Font Awesome CDN -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- Material Icons CDN -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<script type="module" crossorigin src="./assets/index-D3ccCVvm.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DCCfF-Yx.css">
</head>
<body class="bg-gray-50 dark:bg-gray-900">
<div id="root"></div>
</body>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GitHub Stars Manager - AI-Powered Repository Management</title>
<meta name="description" content="Intelligent management of your GitHub starred repositories with AI-powered analysis and release tracking" />
<!-- Font Awesome CDN -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- Material Icons CDN -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<script type="module" crossorigin src="./assets/index-7x6M84Ug.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DW9FpI6u.css">
</head>
<body class="bg-gray-50 dark:bg-gray-900">
<div id="root"></div>
</body>
</html>
Expand Down
49 changes: 47 additions & 2 deletions src/components/RepositoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ export const RepositoryCard: React.FC<RepositoryCardProps> = ({
setLoading,
language,
customCategories,
updateRepository
updateRepository,
deleteRepository
} = useAppStore();

const [editModalOpen, setEditModalOpen] = useState(false);
const [showTooltip, setShowTooltip] = useState(false);
const [isTextTruncated, setIsTextTruncated] = useState(false);
const [unstarring, setUnstarring] = useState(false);

const descriptionRef = useRef<HTMLParagraphElement>(null);

Expand Down Expand Up @@ -311,6 +313,41 @@ export const RepositoryCard: React.FC<RepositoryCardProps> = ({

const t = (zh: string, en: string) => language === 'zh' ? zh : en;

const handleUnstar = async () => {
if (!githubToken) {
alert('GitHub token not found. Please login again.');
return;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

const confirmMessage = language === 'zh'
? `确定要取消 Star "${repository.full_name}" 吗?\n\n这将会从您的 GitHub 收藏中移除该仓库。`
: `Are you sure you want to unstar "${repository.full_name}"?\n\nThis will remove the repository from your GitHub stars.`;

if (!confirm(confirmMessage)) {
return;
}

setUnstarring(true);
try {
const githubApi = new GitHubApiService(githubToken);
const [owner, repo] = repository.full_name.split('/');
await githubApi.unstarRepository(owner, repo);
deleteRepository(repository.id);
const successMessage = language === 'zh'
? '已成功取消 Star'
: 'Successfully unstarred';
alert(successMessage);
} catch (error) {
console.error('Failed to unstar repository:', error);
const errorMessage = language === 'zh'
? '取消 Star 失败,请检查网络连接或重新登录。'
: 'Failed to unstar repository. Please check your network connection or login again.';
alert(errorMessage);
} finally {
setUnstarring(false);
}
};

return (
<div className="bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 p-6 hover:shadow-lg transition-all duration-200 hover:border-blue-300 dark:hover:border-blue-600 animate-slide-up flex flex-col h-full">
{/* Header - Repository Info */}
Expand Down Expand Up @@ -367,7 +404,7 @@ export const RepositoryCard: React.FC<RepositoryCardProps> = ({
</button>
</div>

{/* Right side: Zread/DeepWiki and GitHub Links */}
{/* Right side: Zread/DeepWiki, GitHub Links, and Unstar */}
<div className="flex items-center space-x-2">
<a
href={language === 'zh' ? getZreadUrl(repository.full_name) : getDeepWikiUrl(repository.html_url)}
Expand All @@ -387,6 +424,14 @@ export const RepositoryCard: React.FC<RepositoryCardProps> = ({
>
<ExternalLink className="w-4 h-4" />
</a>
<button
onClick={handleUnstar}
disabled={unstarring}
className="flex items-center justify-center w-8 h-8 rounded-lg bg-red-100 text-red-600 dark:bg-red-900 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-800 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
title={language === 'zh' ? '取消 Star' : 'Unstar'}
>
<Star className={`w-4 h-4 ${unstarring ? 'animate-pulse' : ''}`} />
</button>
</div>
</div>

Expand Down
10 changes: 8 additions & 2 deletions src/services/githubApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export class GitHubApiService {
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
}

const data = await response.json();
const data = response.status === 204 ? null : await response.json();

// 如果是starred repositories的响应,需要处理特殊格式
if (endpoint.includes('/user/starred') && Array.isArray(data)) {
return data.map((item: any) => {
Expand Down Expand Up @@ -191,6 +191,12 @@ export class GitHubApiService {
}
}

async unstarRepository(owner: string, repo: string): Promise<void> {
await this.makeRequest<void>(`/user/starred/${owner}/${repo}`, {
method: 'DELETE',
});
}

async checkRateLimit(): Promise<{ remaining: number; reset: number }> {
const response = await this.makeRequest<any>('/rate_limit');
return {
Expand Down
5 changes: 5 additions & 0 deletions src/store/useAppStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface AppActions {
updateRepository: (repo: Repository) => void;
setLoading: (loading: boolean) => void;
setLastSync: (timestamp: string) => void;
deleteRepository: (repoId: number) => void;
Comment thread
coderabbitai[bot] marked this conversation as resolved.

// AI actions
addAIConfig: (config: AIConfig) => void;
Expand Down Expand Up @@ -296,6 +297,10 @@ export const useAppStore = create<AppState & AppActions>()(
}),
setLoading: (isLoading) => set({ isLoading }),
setLastSync: (lastSync) => set({ lastSync }),
deleteRepository: (repoId) => set((state) => ({
repositories: state.repositories.filter(r => r.id !== repoId),
searchResults: state.searchResults.filter(r => r.id !== repoId),
})),

// AI actions
addAIConfig: (config) => set((state) => ({
Expand Down