From 7c64f310c98288f3946ebc60a80badfaa1bb5689 Mon Sep 17 00:00:00 2001 From: mcallzbl Date: Sat, 12 Apr 2025 21:14:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=8D=E5=88=B6=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E7=9A=84=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 + lingtropy-client/src/constants/index.ts | 10 +- lingtropy-client/src/main/IPCs.ts | 22 +-- .../renderer/components/FooterComponent.vue | 2 +- .../src/renderer/components/InputSection.vue | 35 +++-- .../src/renderer/components/ResultSection.vue | 55 ++++++- .../renderer/screens/TextRewritingTool.vue | 22 ++- package.json | 7 +- yarn.lock | 134 ++++++++++++++++++ 9 files changed, 234 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 4f1c1af..16bb7df 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # LingTropy +LingTropy 是一个基于 Electron + Vue3 开发的桌面应用,用于文案和标题的智能改写。 + + + 减小包体 yarn global add depcheck depcheck diff --git a/lingtropy-client/src/constants/index.ts b/lingtropy-client/src/constants/index.ts index 4706240..a72b4eb 100644 --- a/lingtropy-client/src/constants/index.ts +++ b/lingtropy-client/src/constants/index.ts @@ -8,7 +8,7 @@ export const API_ENDPOINTS = { export const AI_CONFIG = { DEFAULT_MODEL: 'gpt-4o', CONTENT_MAX_TOKENS: 1800, // 约900字 - TITLE_MAX_TOKENS: 50, // 约20字 + TITLE_MAX_TOKENS: 50, // 约20字 TEMPERATURE: 0.8, MAX_RETRIES: 2, TIMEOUT: 30000 @@ -16,8 +16,10 @@ export const AI_CONFIG = { // 提示词模板 export const PROMPTS = { - CONTENT_REWRITE: '你是一个小红书文案写手,能够熟练地根据用户的输入,改写成内容相近,但表达方式不同的新文案。你的文案中需要具备吸人眼球的钩子,能够牢牢抓住用户的注意力。请直接输出新的文案,不要输出其他任何提示性词语, 以纯文本的形式输出。注意:输出的文案不要超过900字。', - TITLE_REWRITE: '你是一个小红书标题写手,能够熟练地根据用户的输入,改写成内容相近,但表达方式不同的新标题。你的标题中需要具备吸人眼球的钩子,能够牢牢抓住用户的注意力。请直接输出新的标题,不要输出其他任何提示性词语, 以纯文本的形式输出。注意:输出的标题不要超过20字。' + CONTENT_REWRITE: + '你是一个小红书文案写手,能够熟练地根据用户的输入,改写成内容相近,但表达方式不同的新文案。你的文案中需要具备吸人眼球的钩子,能够牢牢抓住用户的注意力。请直接输出新的文案,不要输出其他任何提示性词语, 以纯文本的形式输出。注意:输出的文案不要超过900字。', + TITLE_REWRITE: + '你是一个小红书标题写手,能够熟练地根据用户的输入,改写成内容相近,但表达方式不同的新标题。你的标题中需要具备吸人眼球的钩子,能够牢牢抓住用户的注意力。请直接输出新的标题,不要输出其他任何提示性词语, 以纯文本的形式输出。注意:输出的标题不要超过20字。' } as const // 存储键名 @@ -39,4 +41,4 @@ export const UI_CONFIG = { // export const APP_INFO = { // VERSION: '1.0.0', // NAME: 'LingTropy' -// } as const \ No newline at end of file +// } as const diff --git a/lingtropy-client/src/main/IPCs.ts b/lingtropy-client/src/main/IPCs.ts index 24ae6aa..4e61572 100644 --- a/lingtropy-client/src/main/IPCs.ts +++ b/lingtropy-client/src/main/IPCs.ts @@ -3,13 +3,7 @@ import Constants from './utils/Constants' import Store from 'electron-store' import axios from 'axios' import OpenAI from 'openai' -import { - API_ENDPOINTS, - AI_CONFIG, - PROMPTS, - STORE_KEYS, - APP_INFO -} from '../constants' +import { API_ENDPOINTS, AI_CONFIG, PROMPTS, STORE_KEYS, APP_INFO } from '../constants' const store = new Store() /* @@ -123,7 +117,14 @@ export default class IPCs { ipcMain.handle( 'call-openai-title', - async (event, baseUrl: string, apiKey: string, model: string, count: number, text: string) => { + async ( + event, + baseUrl: string, + apiKey: string, + model: string, + count: number, + text: string + ) => { try { const client = new OpenAI({ baseURL: baseUrl, @@ -139,7 +140,8 @@ export default class IPCs { messages: [ { role: 'system', - content: '你是一个小红书标题写手,能够熟练地根据用户的输入,改写成内容相近,但表达方式不同的新标题。你的标题中需要具备吸人眼球的钩子,能够牢牢抓住用户的注意力。请直接输出新的标题,不要输出其他任何提示性词语, 以纯文本的形式输出。注意:输出的标题不要超过20字。' + content: + '你是一个小红书标题写手,能够熟练地根据用户的输入,改写成内容相近,但表达方式不同的新标题。你的标题中需要具备吸人眼球的钩子,能够牢牢抓住用户的注意力。请直接输出新的标题,不要输出其他任何提示性词语, 以纯文本的形式输出。注意:输出的标题不要超过20字。' }, { role: 'user', content: text } ], @@ -203,7 +205,5 @@ export default class IPCs { }) return dialogResult }) - - } } diff --git a/lingtropy-client/src/renderer/components/FooterComponent.vue b/lingtropy-client/src/renderer/components/FooterComponent.vue index 3b9e54c..0c7f739 100644 --- a/lingtropy-client/src/renderer/components/FooterComponent.vue +++ b/lingtropy-client/src/renderer/components/FooterComponent.vue @@ -49,4 +49,4 @@ font-size: 17px; } } - \ No newline at end of file + diff --git a/lingtropy-client/src/renderer/components/InputSection.vue b/lingtropy-client/src/renderer/components/InputSection.vue index 9267b42..8cc2b59 100644 --- a/lingtropy-client/src/renderer/components/InputSection.vue +++ b/lingtropy-client/src/renderer/components/InputSection.vue @@ -17,11 +17,7 @@ 🔄 单次改写 - @@ -31,11 +27,9 @@
- + + + >+
@@ -67,17 +62,17 @@
- -