Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Refactor get version function #3898

Merged
merged 4 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ public Result<SaTokenInfo> getTokenInfo() {

@GetMapping("/version")
@ApiOperation(value = "Query Service Version", notes = "Query Dinky Service Version Number")
@ApiImplicitParam(name = "isExternalCall", value = "isExternalCall", dataTypeClass = Boolean.class)
@SaCheckLogin
public Result<Object> getVersionInfo() {
public Result<Object> getVersionInfo(
@RequestParam(required = false, defaultValue = "true") boolean isExternalCall) {
if (isExternalCall) {
return Result.succeed((Object) DinkyVersion.getShortVersion());
}
return Result.succeed((Object) DinkyVersion.getVersion());
}
}
17 changes: 17 additions & 0 deletions dinky-common/src/main/java/org/dinky/DinkyVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,21 @@ public static String getVersion() {
return "${revision}";
}
}

/**
* Return the short version string of the present Dinky codebase.
* @return the short version of Dinky
*/
public static String getShortVersion() {
try {
String version = getVersion();
int idx = version.indexOf('-');
if (idx > 0) {
return version.substring(0, idx);
}
return version;
} catch (Exception e) {
return "${revision}";
}
}
}
18 changes: 10 additions & 8 deletions dinky-web/src/pages/Other/Login/function.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ export const redirectToLogin = (tipMsg: string) => {
export const initSomeThing = () => {
// initialize setting theme
setLocalThemeToStorage();
queryDataByParams<string>(API_CONSTANTS.GET_SERVICE_VERSION).then((result) => {
if (result && result != getValueFromLocalStorage(SERVER_VERSION)) {
console.log('current version:', getValueFromLocalStorage(SERVER_VERSION));
console.log('update server version:', result);
setKeyToLocalStorage(SERVER_VERSION, result);
console.log('clean dva cache');
window.localStorage.removeItem('persist:root');
queryDataByParams<string>(API_CONSTANTS.GET_SERVICE_VERSION, { isExternalCall: false }).then(
(result) => {
if (result && result != getValueFromLocalStorage(SERVER_VERSION)) {
console.log('current version:', getValueFromLocalStorage(SERVER_VERSION));
console.log('update server version:', result);
setKeyToLocalStorage(SERVER_VERSION, result);
console.log('clean dva cache');
window.localStorage.removeItem('persist:root');
}
}
});
);

// Retrieve the key for enabling message prompts from the local storage, and if not, set it accordingly
if (hasKeyofLocalStorage(ENABLE_MODEL_TIP)) {
Expand Down
Loading