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:
@@ -1,6 +1,9 @@
|
||||
import type {
|
||||
AdminAiReindexResponse,
|
||||
AdminAiProviderTestResponse,
|
||||
AdminDashboardResponse,
|
||||
AdminPostMetadataResponse,
|
||||
AdminPostPolishResponse,
|
||||
AdminSessionResponse,
|
||||
AdminSiteSettingsResponse,
|
||||
CommentListQuery,
|
||||
@@ -12,6 +15,7 @@ import type {
|
||||
FriendLinkRecord,
|
||||
MarkdownDeleteResponse,
|
||||
MarkdownDocumentResponse,
|
||||
MarkdownImportResponse,
|
||||
PostListQuery,
|
||||
PostRecord,
|
||||
ReviewRecord,
|
||||
@@ -37,7 +41,7 @@ async function readErrorMessage(response: Response) {
|
||||
const text = await response.text().catch(() => '')
|
||||
|
||||
if (!text) {
|
||||
return `Request failed with status ${response.status}.`
|
||||
return `请求失败,状态码 ${response.status}。`
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -123,6 +127,28 @@ export const adminApi = {
|
||||
request<AdminAiReindexResponse>('/api/admin/ai/reindex', {
|
||||
method: 'POST',
|
||||
}),
|
||||
testAiProvider: (provider: {
|
||||
id: string
|
||||
name: string
|
||||
provider: string
|
||||
api_base: string | null
|
||||
api_key: string | null
|
||||
chat_model: string | null
|
||||
}) =>
|
||||
request<AdminAiProviderTestResponse>('/api/admin/ai/test-provider', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ provider }),
|
||||
}),
|
||||
generatePostMetadata: (markdown: string) =>
|
||||
request<AdminPostMetadataResponse>('/api/admin/ai/post-metadata', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ markdown }),
|
||||
}),
|
||||
polishPostMarkdown: (markdown: string) =>
|
||||
request<AdminPostPolishResponse>('/api/admin/ai/polish-post', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ markdown }),
|
||||
}),
|
||||
listPosts: (query?: PostListQuery) =>
|
||||
request<PostRecord[]>(
|
||||
appendQueryParams('/api/posts', {
|
||||
@@ -147,6 +173,7 @@ export const adminApi = {
|
||||
tags: payload.tags,
|
||||
post_type: payload.postType,
|
||||
image: payload.image,
|
||||
images: payload.images,
|
||||
pinned: payload.pinned,
|
||||
published: payload.published,
|
||||
}),
|
||||
@@ -163,11 +190,24 @@ export const adminApi = {
|
||||
tags: payload.tags,
|
||||
post_type: payload.postType,
|
||||
image: payload.image,
|
||||
images: payload.images,
|
||||
pinned: payload.pinned,
|
||||
}),
|
||||
}),
|
||||
getPostMarkdown: (slug: string) =>
|
||||
request<MarkdownDocumentResponse>(`/api/posts/slug/${encodeURIComponent(slug)}/markdown`),
|
||||
importPosts: async (files: File[]) => {
|
||||
const formData = new FormData()
|
||||
|
||||
files.forEach((file) => {
|
||||
formData.append('files', file, file.webkitRelativePath || file.name)
|
||||
})
|
||||
|
||||
return request<MarkdownImportResponse>('/api/posts/markdown/import', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
},
|
||||
updatePostMarkdown: (slug: string, markdown: string) =>
|
||||
request<MarkdownDocumentResponse>(`/api/posts/slug/${encodeURIComponent(slug)}/markdown`, {
|
||||
method: 'PATCH',
|
||||
|
||||
Reference in New Issue
Block a user