Skip to content

Commit

Permalink
Merge pull request #1272 from chat2db/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
shanhexi committed Apr 8, 2024
2 parents 093c9ed + adabb89 commit d1d9ad5
Show file tree
Hide file tree
Showing 18 changed files with 180 additions and 170 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ jobs:
- name: Enable tls1
if: ${{ runner.os == 'Windows' }}
run: |
sed -i '' "s/\(^jdk.tls.disabledAlgorithms=\)\(.*\)\( TLSv1, TLSv1.1,\)\(.*\)/\1\2\4/" "${{ env.JAVA_HOME }}/conf/security/java.security"
# sed -i '' "s/\(^jdk.tls.disabledAlgorithms=\)\(.*\)\( TLSv1, TLSv1.1,\)\(.*\)/\1\2\4/" "${{ env.JAVA_HOME }}/conf/security/java.security"
$filePath = "${{ env.JAVA_HOME }}\conf\security\java.security"
$content = Get-Content $filePath -Raw
$updatedContent = $content -replace '^(jdk.tls.disabledAlgorithms=)(.*)( TLSv1, TLSv1.1,)(.*)', '$1$2$4'
$updatedContent | Set-Content $filePath
shell: pwsh

# java.security open tls1 macOS
- name: Enable tls1
Expand Down
1 change: 1 addition & 0 deletions chat2db-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"event-source-polyfill": "^1.0.31",
"highlight.js": "^11.9.0",
"lodash": "^4.17.21",
"lucide-react": "^0.365.0",
"markdown-it-link-attributes": "^4.0.1",
"monaco-editor": "^0.44.0",
"monaco-editor-esm-webpack-plugin": "^2.1.0",
Expand Down
95 changes: 59 additions & 36 deletions chat2db-client/src/blocks/Setting/AiSetting/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React, { useEffect, useState } from 'react';
import configService from '@/service/config';
import { AIType } from '@/typings/ai';
import { Alert, Button, Form, Input, Radio, RadioChangeEvent } from 'antd';
import { Alert, Button, Flex, Form, Input, Radio, RadioChangeEvent } from 'antd';
import i18n from '@/i18n';
import { IAiConfig } from '@/typings/setting';
import { IRole } from '@/typings/user';
import { AIFormConfig, AITypeName } from './aiTypeConfig';
import styles from './index.less';
import { useUserStore } from '@/store/user'
import { useUserStore } from '@/store/user';
import { getLinkBasedOnTimezone } from '@/utils/timezone';

interface IProps {
handleApplyAiConfig: (aiConfig: IAiConfig) => void;
Expand All @@ -21,11 +22,11 @@ function capitalizeFirstLetter(string) {
// openAI 的设置项
export default function SettingAI(props: IProps) {
const [aiConfig, setAiConfig] = useState<IAiConfig>();
const { userInfo } = useUserStore(state => {
const { userInfo } = useUserStore((state) => {
return {
userInfo: state.curUser
}
})
userInfo: state.curUser,
};
});

useEffect(() => {
setAiConfig(props.aiConfig);
Expand Down Expand Up @@ -65,6 +66,57 @@ export default function SettingAI(props: IProps) {
}
};

const renderAIConfig = () => {
if (aiConfig?.aiSqlSource === AIType.CHAT2DBAI) {
return (
<Flex justify="center">
<Button
type="primary"
onClick={() => {
const link = getLinkBasedOnTimezone();
window.open(link, '_blank');
}}
>
{i18n('setting.chat2db.ai.button')}
</Button>
</Flex>
);
}
return (
<>
<Form layout="vertical">
{Object.keys(AIFormConfig[aiConfig?.aiSqlSource]).map((key: string) => (
<Form.Item
key={key}
required={key === 'apiKey' || key === 'secretKey'}
label={capitalizeFirstLetter(key)}
className={styles.title}
>
<Input
autoComplete="off"
value={aiConfig[key]}
placeholder={AIFormConfig[aiConfig?.aiSqlSource]?.[key]}
onChange={(e) => {
setAiConfig({ ...aiConfig, [key]: e.target.value });
}}
/>
</Form.Item>
))}
</Form>
{aiConfig.aiSqlSource === AIType.RESTAI && (
<div style={{ margin: '32px 0 ', fontSize: '12px', opacity: '0.5' }}>{`Tips: ${i18n(
'setting.tab.aiType.custom.tips',
)}`}</div>
)}
<div className={styles.bottomButton}>
<Button type="primary" onClick={handleApplyAiConfig}>
{i18n('setting.button.apply')}
</Button>
</div>
</>
);
};

return (
<>
<div className={styles.aiSqlSource}>
Expand All @@ -78,36 +130,7 @@ export default function SettingAI(props: IProps) {
</Radio.Group>
</div>

<Form layout="vertical">
{Object.keys(AIFormConfig[aiConfig?.aiSqlSource]).map((key: string) => (
<Form.Item
key={key}
required={key === 'apiKey' || key === 'secretKey'}
label={capitalizeFirstLetter(key)}
className={styles.title}
>
<Input
autoComplete="off"
value={aiConfig[key]}
placeholder={AIFormConfig[aiConfig?.aiSqlSource]?.[key]}
onChange={(e) => {
setAiConfig({ ...aiConfig, [key]: e.target.value });
}}
/>
</Form.Item>
))}
</Form>

{aiConfig.aiSqlSource === AIType.RESTAI && (
<div style={{ margin: '32px 0 ', fontSize: '12px', opacity: '0.5' }}>{`Tips: ${i18n(
'setting.tab.aiType.custom.tips',
)}`}</div>
)}
<div className={styles.bottomButton}>
<Button type="primary" onClick={handleApplyAiConfig}>
{i18n('setting.button.apply')}
</Button>
</div>
{renderAIConfig()}

{/* {aiConfig?.aiSqlSource === AIType.CHAT2DBAI && !aiConfig.apiKey && <Popularize source="setting" />} */}
</>
Expand Down
2 changes: 1 addition & 1 deletion chat2db-client/src/blocks/Tree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ const TreeNode = memo((props: TreeNodeIProps) => {
zIndex: 1080,
}}
>
<Tooltip placement="right" color={window._AppThemePack.colorPrimary} title={treeNodeData.comment}>
<Tooltip placement="right" color={window._AppThemePack?.colorPrimary} title={treeNodeData.comment}>
<div
className={classnames(styles.treeNode, { [styles.treeNodeFocus]: isFocus })}
onClick={handelClickTreeNode}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function useMonacoTheme() {
const [appTheme] = useTheme();
// 监听主题色变化切换编辑器主题色
useEffect(() => {
const { colorPrimary, colorBgBase, colorTextBase } = window._AppThemePack;
const { colorPrimary, colorBgBase, colorTextBase } = window._AppThemePack || {};

const colors = {
'editor.lineHighlightBackground': colorPrimary + '14', // 当前行背景色
Expand Down
48 changes: 0 additions & 48 deletions chat2db-client/src/components/OpenScreenAnimation/index.less

This file was deleted.

20 changes: 0 additions & 20 deletions chat2db-client/src/components/OpenScreenAnimation/index.tsx

This file was deleted.

7 changes: 5 additions & 2 deletions chat2db-client/src/i18n/en-us/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
'setting.tab.aiType.baichuan': 'BaiChuan AI',
'setting.tab.aiType.wenxin': 'WenXin AI',
'setting.tab.aiType.tongyiqianwen': 'TongYiQianWen AI',
'setting.tab.aiType.custom.tips': "The API format is consistent with the OpenAI API format",
'setting.tab.aiType.custom.tips': 'The API format is consistent with the OpenAI API format',
'setting.label.serviceAddress': 'Service Address',
'setting.button.apply': 'Apply',
'setting.text.currentEnv': 'Current Env',
Expand Down Expand Up @@ -51,9 +51,12 @@ export default {
'setting.text.autoUpdate': 'The new version automatically downloads and installs updates',
'setting.text.manualUpdate': 'Only alert me when a new version is released',
'setting.button.iSee': 'I see',
'setting.text.newEditionIsReady': 'New version to download completed, restart the software will install the new version',
'setting.text.newEditionIsReady':
'New version to download completed, restart the software will install the new version',
'setting.button.goToUpdate': 'Go to update',
'setting.text.UpdatedLatestVersion': 'Updated to the latest version {1}',
'setting.title.holdingService': 'Holding Service',
'setting.text.holdingService': 'Keep the service when exiting the application to speed up startup',
'setting.chat2db.ai.button': 'Please visit Chat2DB Pro for more powerful AI features',
'setting.title.goto.chat2db.pro': 'Go to Chat2DB Pro',
};
16 changes: 11 additions & 5 deletions chat2db-client/src/i18n/ja-jp/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ export default {
'setting.tab.aiType.baichuan': '百川',
'setting.tab.aiType.wenxin': '文心一言',
'setting.tab.aiType.tongyiqianwen': '通義千問',
'setting.tab.aiType.custom.tips': "インターフェース形式はOpenAIのものと互換性があります",
'setting.tab.aiType.custom.tips': 'インターフェース形式はOpenAIのものと互換性があります',
'setting.label.serviceAddress': 'サービスアドレス',
'setting.button.apply': '適用',
'setting.text.currentEnv': '現在の環境',
'setting.text.currentVersion': '現在のバージョン',
'setting.text.viewingUpdateLogs': '更新ログを見る',
'setting.label.isStreamOutput': 'ストリーム出力を行うか',
'setting.label.customAiUrl': 'カスタムAIのURL',
'setting.placeholder.httpsProxy': '任意項目、OpenAIインターフェースをリクエストする際のHTTPプロキシを設定するためのもの{1}',
'setting.placeholder.apiKey': 'OpenAIインターフェースを使用する場合は必須です。APIキーはOpenAI公式サイトで確認できます',
'setting.placeholder.httpsProxy':
'任意項目、OpenAIインターフェースをリクエストする際のHTTPプロキシを設定するためのもの{1}',
'setting.placeholder.apiKey':
'OpenAIインターフェースを使用する場合は必須です。APIキーはOpenAI公式サイトで確認できます',
'setting.placeholder.chat2dbApiKey': 'Chat2DBが提供するAPIキーを使用します',
'setting.placeholder.customUrl': 'カスタムAIを選択する場合は必須で、カスタムAIのRESTインターフェースのURLを設定します',
'setting.placeholder.customUrl':
'カスタムAIを選択する場合は必須で、カスタムAIのRESTインターフェースのURLを設定します',
'setting.placeholder.apiHost': '任意項目、デフォルト値はhttps://api.openai.com/',
'setting.message.urlTestError': 'インターフェースのテストに合格しません',
'setting.placeholder.azureOpenAIKey': 'AzureポータルからAzure OpenAIキーを取得します',
Expand All @@ -51,9 +54,12 @@ export default {
'setting.text.autoUpdate': '新しいバージョンを自動でダウンロードしてインストールする',
'setting.text.manualUpdate': '新しいバージョンがリリースされたときにのみ通知する',
'setting.button.iSee': '了解しました',
'setting.text.newEditionIsReady': '新しいバージョンがダウンロードされました。ソフトウェアを再起動すると新しいバージョンがインストールされます',
'setting.text.newEditionIsReady':
'新しいバージョンがダウンロードされました。ソフトウェアを再起動すると新しいバージョンがインストールされます',
'setting.button.goToUpdate': '更新に進む',
'setting.text.UpdatedLatestVersion': '最新バージョン {1} に更新しました',
'setting.title.holdingService': 'サービスを維持',
'setting.text.holdingService': 'アプリケーションを終了してもサービスを維持し、起動速度を向上させます',
'setting.chat2db.ai.button': 'より強力なAI機能を体験するために、Chat2DB Proをご利用ください',
'setting.title.goto.chat2db.pro': 'Chat2DB Proへ行く',
};
19 changes: 11 additions & 8 deletions chat2db-client/src/i18n/tr-tr/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ export default {
'setting.tab.aiType.baichuan': 'BaiChuan AI',
'setting.tab.aiType.wenxin': 'WenXin AI',
'setting.tab.aiType.tongyiqianwen': 'TongYiQianWen AI',
'setting.tab.aiType.custom.tips': "API formatı OpenAI API formatıyla uyumludur",
'setting.tab.aiType.custom.tips': 'API formatı OpenAI API formatıyla uyumludur',
'setting.label.serviceAddress': 'Hizmet Adresi',
'setting.button.apply': 'Uygula',
'setting.text.currentEnv': 'Geçerli Ortam',
'setting.text.currentVersion': 'Geçerli Sürüm',
'setting.text.viewingUpdateLogs': 'Güncelleme Günlüklerini Görüntüleme',
'setting.label.isStreamOutput': 'Arayüzün çıktıyı akıtıp akıtmadığı',
'setting.label.customAiUrl': 'Kullanıcı tanımlı arayüz URL\'si',
'setting.label.customAiUrl': "Kullanıcı tanımlı arayüz URL'si",
'setting.placeholder.httpsProxy': 'Gerekli değil. OPENAI arayüzünü istemek için HTTP proxy {1} ayarlayın.',
'setting.placeholder.apiKey': 'APIKEY\'i görüntülemek için OpenAI resmi web sitesine gidin',
'setting.placeholder.chat2dbApiKey': 'Chat2DB tarafından sağlanan APIKEY\'i kullanın',
'setting.placeholder.customUrl': 'AI REST arayüzünün URL\'si',
'setting.placeholder.apiKey': "APIKEY'i görüntülemek için OpenAI resmi web sitesine gidin",
'setting.placeholder.chat2dbApiKey': "Chat2DB tarafından sağlanan APIKEY'i kullanın",
'setting.placeholder.customUrl': "AI REST arayüzünün URL'si",
'setting.placeholder.apiHost': 'Bu parametre zorunludur. Varsayılan değer https://api.openai.com/',
'setting.message.urlTestError': 'Arayüz testi başarısız oldu. İşlem',
'setting.placeholder.azureOpenAIKey': 'Azure Portal\'dan Azure OpenAI anahtar kimlik bilgilerini alın',
'setting.placeholder.azureEndpoint': 'Azure Portal\'dan Azure OpenAI uç noktasını alın',
'setting.placeholder.azureOpenAIKey': "Azure Portal'dan Azure OpenAI anahtar kimlik bilgilerini alın",
'setting.placeholder.azureEndpoint': "Azure Portal'dan Azure OpenAI uç noktasını alın",
'setting.placeholder.azureDeployment': 'Dağıtılan modelin dağıtım kimliği',
'setting.ai.tips': 'Lütfen oturum açın ve AI yapılandırmasını seçin',
'setting.ai.user.hidden': '"Ayarlar -> Özel AI" içinde ApiKey\'i ayarlamak için lütfen yönetici ile iletişime geçin',
Expand All @@ -51,9 +51,12 @@ export default {
'setting.text.autoUpdate': 'Yeni sürüm otomatik olarak indirilir ve yükler',
'setting.text.manualUpdate': 'Yalnızca yeni bir sürüm yayınlandığında beni uyar',
'setting.button.iSee': 'Görüyorum',
'setting.text.newEditionIsReady': 'Yeni sürüm indirme tamamlandı, yazılımı yeniden başlatarak yeni sürümü kurabilirsiniz',
'setting.text.newEditionIsReady':
'Yeni sürüm indirme tamamlandı, yazılımı yeniden başlatarak yeni sürümü kurabilirsiniz',
'setting.button.goToUpdate': 'Güncellemeye Git',
'setting.text.UpdatedLatestVersion': 'En son sürüme güncellendi {1}',
'setting.title.holdingService': 'Hizmeti Tutma',
'setting.text.holdingService': 'Uygulamadan çıkarken hizmeti tutarak başlangıcı hızlandırın',
'setting.chat2db.ai.button': `Daha güçlü AI özellikleri için lütfen Chat2DB Pro'yu ziyaret edin`,
'setting.title.goto.chat2db.pro': `Chat2DB Pro'ya Git`,
};
5 changes: 3 additions & 2 deletions chat2db-client/src/i18n/zh-cn/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
'setting.tab.aiType.baichuan': '百川',
'setting.tab.aiType.wenxin': '文心一言',
'setting.tab.aiType.tongyiqianwen': '通义千问',
'setting.tab.aiType.custom.tips': "接口格式与OpenAI接口格式一致",
'setting.tab.aiType.custom.tips': '接口格式与OpenAI接口格式一致',
'setting.label.serviceAddress': '服务地址',
'setting.button.apply': '应用',
'setting.text.currentEnv': '当前环境',
Expand Down Expand Up @@ -56,5 +56,6 @@ export default {
'setting.text.UpdatedLatestVersion': '已更新到最新版本 {1}',
'setting.title.holdingService': '保持服务',
'setting.text.holdingService': '退出应用时保持服务,加快启动速度',

'setting.chat2db.ai.button': '请前往 Chat2DB Pro 体验更为强大的AI功能',
'setting.title.goto.chat2db.pro': '前往Chat2DB Pro',
};

0 comments on commit d1d9ad5

Please sign in to comment.