@@ -8,10 +8,15 @@ export interface AIConfig {
88 apiKey : string ;
99 endpoint : string ;
1010 model : string ;
11+ enableToJson : boolean ;
12+ enableAskAI : boolean ;
13+ enableAICreation : boolean ;
14+ enableAIChat : boolean ;
15+ enableAISnipets : boolean ;
1116 persistChatHistory : boolean ;
1217 enableImage : boolean ;
1318 imageAIEndpoint : string ;
14- imageApiKey :string ;
19+ imageApiKey : string ;
1520 imageModel : string ;
1621 enableWebsearch : boolean ;
1722 tavilyApiKey : string ;
@@ -26,11 +31,25 @@ export interface Snippet {
2631 prompt : string ;
2732}
2833
34+ export interface CommonConfig {
35+ enablePaste : boolean ;
36+ enableCalc : boolean ;
37+ enableEdit : boolean ;
38+ enableToText : boolean ;
39+ }
40+
41+ export interface DetectConfig {
42+ enabled : boolean ;
43+ detectUrl : boolean ;
44+ }
45+
2946export interface Config {
3047 globalShortcut : string ;
3148 ai : AIConfig ;
3249 chatHistory ?: CoreMessage [ ] ;
3350 snippets : Snippet [ ] ;
51+ common : CommonConfig ;
52+ detect : DetectConfig ;
3453}
3554
3655export function useConfig ( ) {
@@ -42,6 +61,11 @@ export function useConfig() {
4261 apiKey : '' ,
4362 endpoint : 'https://api.openai.com/v1' ,
4463 model : 'gpt-4o' ,
64+ enableToJson : true ,
65+ enableAskAI : true ,
66+ enableAICreation : true ,
67+ enableAIChat : true ,
68+ enableAISnipets : true ,
4569 persistChatHistory : false ,
4670 enableImage : false ,
4771 imageAIEndpoint : 'https://api.openai.com/v1' ,
@@ -52,6 +76,16 @@ export function useConfig() {
5276 enableWebCrawl : false ,
5377 jinaApiKey : '' ,
5478 } ,
79+ common : {
80+ enablePaste : true ,
81+ enableCalc : true ,
82+ enableEdit : true ,
83+ enableToText : true ,
84+ } ,
85+ detect : {
86+ enabled : false ,
87+ detectUrl : false ,
88+ } ,
5589 snippets : [ ] ,
5690 chatHistory : [ ]
5791 } ) ;
@@ -67,6 +101,11 @@ export function useConfig() {
67101 apiKey : ( await store . get ( 'ai.apiKey' ) ) || '' ,
68102 endpoint : ( await store . get ( 'ai.endpoint' ) ) || 'https://api.openai.com/v1' ,
69103 model : ( await store . get ( 'ai.model' ) ) || 'gpt-4o' ,
104+ enableToJson : ! ! ( await store . get ( 'ai.enableToJson' ) ?? true ) ,
105+ enableAskAI : ! ! ( await store . get ( 'ai.enableAskAI' ) ?? true ) ,
106+ enableAICreation : ! ! ( await store . get ( 'ai.enableAICreation' ) ?? true ) ,
107+ enableAIChat : ! ! ( await store . get ( 'ai.enableAIChat' ) ?? true ) ,
108+ enableAISnipets : ! ! ( await store . get ( 'ai.enableAISnipets' ) ?? true ) ,
70109 persistChatHistory : ! ! ( await store . get ( 'ai.persistChatHistory' ) ) ,
71110 enableImage : ! ! ( await store . get ( 'ai.enableImage' ) ) ,
72111 imageAIEndpoint : ( await store . get ( 'ai.imageAIEndpoint' ) ) || 'https://api.openai.com/v1' ,
@@ -77,6 +116,16 @@ export function useConfig() {
77116 enableWebCrawl : ! ! ( await store . get ( 'ai.enableWebCrawl' ) ) ,
78117 jinaApiKey : ( await store . get ( 'ai.jinaApiKey' ) ) || '' ,
79118 } ;
119+ config . value . detect = {
120+ enabled : ! ! ( await store . get ( 'detect.enabled' ) ?? true ) ,
121+ detectUrl : ! ! ( await store . get ( 'detect.detectUrl' ) ?? true ) ,
122+ } ;
123+ config . value . common = {
124+ enablePaste : ! ! ( await store . get ( 'common.enablePaste' ) ?? true ) ,
125+ enableCalc : ! ! ( await store . get ( 'common.enableCalc' ) ?? true ) ,
126+ enableEdit : ! ! ( await store . get ( 'common.enableEdit' ) ?? true ) ,
127+ enableToText : ! ! ( await store . get ( 'common.enableToText' ) ?? true ) ,
128+ } ;
80129 config . value . snippets = tryParse ( await store . get ( 'snippets' ) || "[]" , [
81130 {
82131 id : 'intro' ,
@@ -99,6 +148,11 @@ export function useConfig() {
99148 await store . set ( 'ai.apiKey' , config . value . ai . apiKey ) ;
100149 await store . set ( 'ai.endpoint' , config . value . ai . endpoint ) ;
101150 await store . set ( 'ai.model' , config . value . ai . model ) ;
151+ await store . set ( 'ai.enableToJson' , config . value . ai . enableToJson ) ;
152+ await store . set ( 'ai.enableAskAI' , config . value . ai . enableAskAI ) ;
153+ await store . set ( 'ai.enableAICreation' , config . value . ai . enableAICreation ) ;
154+ await store . set ( 'ai.enableAIChat' , config . value . ai . enableAIChat ) ;
155+ await store . set ( 'ai.enableAISnipets' , config . value . ai . enableAISnipets ) ;
102156 await store . set ( 'ai.persistChatHistory' , config . value . ai . persistChatHistory ) ;
103157 await store . set ( 'ai.enableImage' , config . value . ai . enableImage ) ;
104158 await store . set ( 'ai.imageAIEndpoint' , config . value . ai . imageAIEndpoint ) ;
@@ -108,6 +162,12 @@ export function useConfig() {
108162 await store . set ( 'ai.tavilyApiKey' , config . value . ai . tavilyApiKey ) ;
109163 await store . set ( 'ai.enableWebCrawl' , config . value . ai . enableWebCrawl ) ;
110164 await store . set ( 'ai.jinaApiKey' , config . value . ai . jinaApiKey ) ;
165+ await store . set ( 'detect.enabled' , config . value . detect . enabled ) ;
166+ await store . set ( 'detect.detectUrl' , config . value . detect . detectUrl ) ;
167+ await store . set ( 'common.enablePaste' , config . value . common . enablePaste ) ;
168+ await store . set ( 'common.enableCalc' , config . value . common . enableCalc ) ;
169+ await store . set ( 'common.enableEdit' , config . value . common . enableEdit ) ;
170+ await store . set ( 'common.enableToText' , config . value . common . enableToText ) ;
111171 await store . set ( 'snippets' , JSON . stringify ( Array . isArray ( config . value . snippets ) ? config . value . snippets : [ ] ) ) ;
112172 await store . set ( 'chatHistory' , JSON . stringify ( Array . isArray ( config . value . chatHistory ) ? config . value . chatHistory : [ ] ) ) ;
113173 await store . save ( ) ;
0 commit comments