Skip to content

Commit 447702c

Browse files
committed
refactor: 将版本配置字段从version重命名为edition
统一将配置中的版本字段从"version"更名为"edition",以更准确表达产品版本类型概念。修改涉及配置服务、webview组件及多语言文件,保持功能不变但提高代码可读性。
1 parent 7923144 commit 447702c

6 files changed

Lines changed: 31 additions & 31 deletions

File tree

src/configurationService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export const ConfigurationService = {
1717
getBackendUrl(): string | undefined {
1818
return this.config.get("backendUrl"); // 返回值为 string 或 undefined
1919
},
20-
getVersion(): string | undefined {
21-
return this.config.get("version"); // 返回值为 string 或 undefined
20+
getEdition(): string | undefined {
21+
return this.config.get("edition"); // 返回值为 string 或 undefined
2222
},
2323

2424
getUserDefaultWorkspace(): WorkspaceItem | undefined {

src/i18n/en.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
"form.config.email.label": "PawSQL Account",
5252
"form.config.password.label": "Password",
5353
"form.config.backendUrl.label": "PawSQL Server",
54-
"form.config.version.label": "PawSQL Edition",
55-
"form.config.version.cloud": "PawSQL Cloud",
56-
"form.config.version.community": "Community Version",
57-
"form.config.version.enterprise": "Enterprise Version",
54+
"form.config.edition.label": "PawSQL Edition",
55+
"form.config.edition.cloud": "PawSQL Cloud",
56+
"form.config.edition.community": "Community Edition",
57+
"form.config.edition.enterprise": "Enterprise Edition",
5858
"form.config.joinPawSQL": "Join PawSQL",
5959
"form.config.joinPawSQL.community": "Deploy Community Edition in 5 mins",
6060
"form.config.description": "PawSQL VSCode helps you to optimize your SQL quries directly within VSCode enviroment. PawSQL provides sophisticated SQL optimization features including smart index recommendations and query rewrites. More about PawSQL, please visit ",

src/i18n/zh-cn.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
"form.config.email.label": "PawSQL 账号",
5353
"form.config.password.label": "密码",
5454
"form.config.backendUrl.label": "PawSQL 服务器",
55-
"form.config.version.label": "PawSQL 版本",
56-
"form.config.version.cloud": "PawSQL Cloud",
57-
"form.config.version.community": "PawSQL 社区版",
58-
"form.config.version.enterprise": "PawSQL 企业版",
55+
"form.config.edition.label": "PawSQL 版本",
56+
"form.config.edition.cloud": "PawSQL Cloud",
57+
"form.config.edition.community": "PawSQL 社区版",
58+
"form.config.edition.enterprise": "PawSQL 企业版",
5959
"form.config.joinPawSQL": "加入PawSQL",
6060
"form.config.joinPawSQL.community": "5分钟快速部署社区版",
6161
"form.config.description": "PawSQL Client 让开发者能够在VSCode开发环境中直接使用PawSQL优化引擎的强大功能,包括智能索引推荐、查询重写建议、自动化性能验证等。想要了解更多关于PawSQL的优化能力,请参考",

src/webview/components/ConfigForm.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ import LockIcon from "@mui/icons-material/Lock";
1515
import { FormattedMessage, useIntl } from "react-intl";
1616
import PawIconWithText from "./PawIconWithText";
1717

18-
type VersionType = "cloud" | "community" | "enterprise";
18+
type EditionType = "cloud" | "community" | "enterprise";
1919

2020
interface Config {
2121
email: string;
2222
password: string;
2323
backendUrl: string;
24-
version?: VersionType;
24+
edition?: EditionType;
2525
}
2626

2727
interface ConfigFormProps {
@@ -91,8 +91,8 @@ const ConfigForm: React.FC<ConfigFormProps> = ({
9191
let newState = { ...prev, [name]: value };
9292

9393
// 根据版本类型设置默认值和字段状态
94-
if (name === "version") {
95-
switch (value as VersionType) {
94+
if (name === "edition") {
95+
switch (value as EditionType) {
9696
case "cloud":
9797
newState.backendUrl = "https://www.pawsql.com";
9898
newState.email = "";
@@ -164,25 +164,25 @@ const ConfigForm: React.FC<ConfigFormProps> = ({
164164
<TextField
165165
select
166166
fullWidth
167-
name="version"
168-
label={formatMessage({ id: "form.config.version.label" })}
167+
name="edition"
168+
label={formatMessage({ id: "form.config.edition.label" })}
169169
variant="outlined"
170170
margin="normal"
171-
value={formState.version}
171+
value={formState.edition}
172172
onChange={handleInputChange}
173173
SelectProps={{
174174
native: true,
175175
}}
176176
sx={{ mb: 2 }}
177177
>
178178
<option value="cloud">
179-
{formatMessage({ id: "form.config.version.cloud" })}
179+
{formatMessage({ id: "form.config.edition.cloud" })}
180180
</option>
181181
<option value="community">
182-
{formatMessage({ id: "form.config.version.community" })}
182+
{formatMessage({ id: "form.config.edition.community" })}
183183
</option>
184184
<option value="enterprise">
185-
{formatMessage({ id: "form.config.version.enterprise" })}
185+
{formatMessage({ id: "form.config.edition.enterprise" })}
186186
</option>
187187
</TextField>
188188

@@ -194,7 +194,7 @@ const ConfigForm: React.FC<ConfigFormProps> = ({
194194
margin="normal"
195195
value={formState.backendUrl}
196196
onChange={handleInputChange}
197-
disabled={formState.version === "cloud"}
197+
disabled={formState.edition === "cloud"}
198198
InputProps={{
199199
startAdornment: (
200200
<InputAdornment position="start">
@@ -213,7 +213,7 @@ const ConfigForm: React.FC<ConfigFormProps> = ({
213213
margin="normal"
214214
value={formState.email}
215215
onChange={handleInputChange}
216-
disabled={formState.version === "community"}
216+
disabled={formState.edition === "community"}
217217
InputProps={{
218218
startAdornment: (
219219
<InputAdornment position="start">
@@ -232,7 +232,7 @@ const ConfigForm: React.FC<ConfigFormProps> = ({
232232
margin="normal"
233233
value={formState.password}
234234
onChange={handleInputChange}
235-
disabled={formState.version === "community"}
235+
disabled={formState.edition === "community"}
236236
InputProps={{
237237
startAdornment: (
238238
<InputAdornment position="start">
@@ -272,7 +272,7 @@ const ConfigForm: React.FC<ConfigFormProps> = ({
272272
fullWidth
273273
onClick={() =>
274274
openExternalLink(
275-
formState.version === "community"
275+
formState.edition === "community"
276276
? "https://pawsql.com/community"
277277
: "https://www.pawsql.com"
278278
)
@@ -290,7 +290,7 @@ const ConfigForm: React.FC<ConfigFormProps> = ({
290290
transition: "all 0.3s ease",
291291
}}
292292
>
293-
{formState.version === "community" ? (
293+
{formState.edition === "community" ? (
294294
<FormattedMessage id="form.config.joinPawSQL.community" />
295295
) : (
296296
<FormattedMessage id="form.config.joinPawSQL" />

src/webview/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ interface Config {
1919
email: string;
2020
password: string;
2121
backendUrl: string;
22-
version?: "cloud" | "community" | "enterprise";
22+
edition?: "cloud" | "community" | "enterprise";
2323
}
2424

2525
const App: React.FC = () => {
2626
const [config, setConfig] = React.useState<Config>({
2727
email: "",
2828
password: "",
2929
backendUrl: "",
30-
version: undefined,
30+
edition: undefined,
3131
});
3232

3333
const [locale, setLocale] = React.useState<"en" | "zh-cn">("en"); // 使用字面量类型
@@ -60,7 +60,7 @@ const App: React.FC = () => {
6060
email: message.email || "",
6161
password: message.password || "",
6262
backendUrl: message.backendUrl || "",
63-
version: message.version || "enterprise", // 默认为 "enterprise"
63+
edition: message.edition || "enterprise", // 默认为 "enterprise"
6464
};
6565
console.log("Updating config:", newConfig);
6666
setConfig(newConfig);

src/webviewProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class WebviewProvider {
112112
password,
113113
backendUrl:
114114
vscode.workspace.getConfiguration("pawsql").get("backendUrl") || "",
115-
version: vscode.workspace.getConfiguration("pawsql").get("version") || "",
115+
edition: vscode.workspace.getConfiguration("pawsql").get("edition") || "",
116116
};
117117

118118
panel.webview.postMessage({ command: "configResponse", ...config });
@@ -124,7 +124,7 @@ export class WebviewProvider {
124124
email: string;
125125
password: string;
126126
backendUrl: string;
127-
version: string;
127+
edition: string;
128128
}
129129
) {
130130
try {
@@ -137,7 +137,7 @@ export class WebviewProvider {
137137
.update("backendUrl", config.backendUrl, true);
138138
await vscode.workspace
139139
.getConfiguration("pawsql")
140-
.update("version", config.version, true);
140+
.update("edition", config.edition, true);
141141

142142
await this.treeProvider.updateApikey(config);
143143
await this.passwordManager.storePassword(config.password);

0 commit comments

Comments
 (0)