feat: Refactor service management scripts to use a unified dev script
- Added package.json to manage development scripts. - Updated restart-services.ps1 to call the new dev script for starting services. - Refactored start-admin.ps1, start-backend.ps1, start-frontend.ps1, and start-mcp.ps1 to utilize the dev script for starting respective services. - Enhanced stop-services.ps1 to improve process termination logic by matching command patterns.
This commit is contained in:
@@ -6,7 +6,14 @@ import type {
|
||||
Tag as UiTag,
|
||||
} from '../types';
|
||||
|
||||
export const API_BASE_URL = 'http://localhost:5150/api';
|
||||
const envApiBaseUrl = import.meta.env.PUBLIC_API_BASE_URL?.trim();
|
||||
|
||||
export const API_BASE_URL =
|
||||
envApiBaseUrl && envApiBaseUrl.length > 0
|
||||
? envApiBaseUrl.replace(/\/$/, '')
|
||||
: import.meta.env.DEV
|
||||
? 'http://127.0.0.1:5150/api'
|
||||
: 'https://init.cool/api';
|
||||
|
||||
export interface ApiPost {
|
||||
id: number;
|
||||
@@ -18,6 +25,7 @@ export interface ApiPost {
|
||||
tags: string[];
|
||||
post_type: 'article' | 'tweet';
|
||||
image: string | null;
|
||||
images: string[] | null;
|
||||
pinned: boolean;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
@@ -111,11 +119,22 @@ export interface ApiSiteSettings {
|
||||
social_email: string | null;
|
||||
location: string | null;
|
||||
tech_stack: string[] | null;
|
||||
music_playlist: Array<{
|
||||
title: string;
|
||||
artist?: string | null;
|
||||
album?: string | null;
|
||||
url: string;
|
||||
cover_image_url?: string | null;
|
||||
accent_color?: string | null;
|
||||
description?: string | null;
|
||||
}> | null;
|
||||
ai_enabled: boolean;
|
||||
paragraph_comments_enabled: boolean;
|
||||
}
|
||||
|
||||
export interface AiSource {
|
||||
slug: string;
|
||||
href: string;
|
||||
title: string;
|
||||
excerpt: string;
|
||||
score: number;
|
||||
@@ -152,10 +171,11 @@ export interface Review {
|
||||
review_type: 'game' | 'anime' | 'music' | 'book' | 'movie';
|
||||
rating: number;
|
||||
review_date: string;
|
||||
status: 'completed' | 'in-progress' | 'dropped';
|
||||
status: 'published' | 'draft' | 'completed' | 'in-progress' | 'dropped';
|
||||
description: string;
|
||||
tags: string;
|
||||
cover: string;
|
||||
link_url: string | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
@@ -168,24 +188,59 @@ export const DEFAULT_SITE_SETTINGS: SiteSettings = {
|
||||
id: '1',
|
||||
siteName: 'InitCool',
|
||||
siteShortName: 'Termi',
|
||||
siteUrl: 'https://termi.dev',
|
||||
siteUrl: 'https://init.cool',
|
||||
siteTitle: 'InitCool - 终端风格的内容平台',
|
||||
siteDescription: '一个基于终端美学的个人内容站,记录代码、设计和生活。',
|
||||
heroTitle: '欢迎来到我的极客终端博客',
|
||||
heroSubtitle: '这里记录技术、代码和生活点滴',
|
||||
ownerName: 'InitCool',
|
||||
ownerTitle: '前端开发者 / 技术博主',
|
||||
ownerBio: '一名热爱技术的前端开发者,专注于构建高性能、优雅的用户界面。相信代码不仅是工具,更是一种艺术表达。',
|
||||
ownerTitle: 'Rust / Go / Python Developer · Builder @ init.cool',
|
||||
ownerBio: 'InitCool,GitHub 用户名 limitcool。坚持不要重复造轮子,当前在维护 starter,平时主要写 Rust、Go、Python 相关项目,也在持续学习 AI 与 Web3。',
|
||||
location: 'Hong Kong',
|
||||
social: {
|
||||
github: 'https://github.com',
|
||||
twitter: 'https://twitter.com',
|
||||
email: 'mailto:hello@termi.dev',
|
||||
github: 'https://github.com/limitcool',
|
||||
twitter: '',
|
||||
email: 'mailto:initcoool@gmail.com',
|
||||
},
|
||||
techStack: ['Astro', 'Svelte', 'Tailwind CSS', 'TypeScript'],
|
||||
techStack: ['Rust', 'Go', 'Python', 'Svelte', 'Astro', 'Loco.rs'],
|
||||
musicPlaylist: [
|
||||
{
|
||||
title: '山中来信',
|
||||
artist: 'InitCool Radio',
|
||||
album: '站点默认歌单',
|
||||
url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3',
|
||||
coverImageUrl:
|
||||
'https://images.unsplash.com/photo-1510915228340-29c85a43dcfe?auto=format&fit=crop&w=600&q=80',
|
||||
accentColor: '#2f6b5f',
|
||||
description: '适合文章阅读时循环播放的轻氛围曲。',
|
||||
},
|
||||
{
|
||||
title: '风吹松声',
|
||||
artist: 'InitCool Radio',
|
||||
album: '站点默认歌单',
|
||||
url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-2.mp3',
|
||||
coverImageUrl:
|
||||
'https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=600&q=80',
|
||||
accentColor: '#8a5b35',
|
||||
description: '偏木质感的器乐氛围,适合深夜浏览。',
|
||||
},
|
||||
{
|
||||
title: '夜航小记',
|
||||
artist: 'InitCool Radio',
|
||||
album: '站点默认歌单',
|
||||
url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-3.mp3',
|
||||
coverImageUrl:
|
||||
'https://images.unsplash.com/photo-1493225457124-a3eb161ffa5f?auto=format&fit=crop&w=600&q=80',
|
||||
accentColor: '#375a7f',
|
||||
description: '节奏更明显一点,适合切换阅读状态。',
|
||||
},
|
||||
],
|
||||
ai: {
|
||||
enabled: false,
|
||||
},
|
||||
comments: {
|
||||
paragraphsEnabled: true,
|
||||
},
|
||||
};
|
||||
|
||||
const formatPostDate = (dateString: string) => dateString.slice(0, 10);
|
||||
@@ -208,6 +263,7 @@ const normalizePost = (post: ApiPost): UiPost => ({
|
||||
tags: post.tags ?? [],
|
||||
category: post.category,
|
||||
image: post.image ?? undefined,
|
||||
images: post.images ?? undefined,
|
||||
pinned: post.pinned,
|
||||
});
|
||||
|
||||
@@ -277,9 +333,26 @@ const normalizeSiteSettings = (settings: ApiSiteSettings): SiteSettings => ({
|
||||
email: settings.social_email || DEFAULT_SITE_SETTINGS.social.email,
|
||||
},
|
||||
techStack: settings.tech_stack?.length ? settings.tech_stack : DEFAULT_SITE_SETTINGS.techStack,
|
||||
musicPlaylist:
|
||||
settings.music_playlist?.filter((item) => item?.title?.trim() && item?.url?.trim())?.length
|
||||
? settings.music_playlist
|
||||
.filter((item) => item.title.trim() && item.url.trim())
|
||||
.map((item) => ({
|
||||
title: item.title,
|
||||
artist: item.artist ?? undefined,
|
||||
album: item.album ?? undefined,
|
||||
url: item.url,
|
||||
coverImageUrl: item.cover_image_url ?? undefined,
|
||||
accentColor: item.accent_color ?? undefined,
|
||||
description: item.description ?? undefined,
|
||||
}))
|
||||
: DEFAULT_SITE_SETTINGS.musicPlaylist,
|
||||
ai: {
|
||||
enabled: Boolean(settings.ai_enabled),
|
||||
},
|
||||
comments: {
|
||||
paragraphsEnabled: settings.paragraph_comments_enabled ?? true,
|
||||
},
|
||||
});
|
||||
|
||||
class ApiClient {
|
||||
@@ -450,6 +523,7 @@ class ApiClient {
|
||||
tags: result.tags ?? [],
|
||||
post_type: result.post_type || 'article',
|
||||
image: result.image,
|
||||
images: null,
|
||||
pinned: result.pinned ?? false,
|
||||
created_at: result.created_at,
|
||||
updated_at: result.updated_at,
|
||||
|
||||
Reference in New Issue
Block a user