Skip to content

Commit

Permalink
[Refactor] Refactor get version function (DataLinkDC#3898)
Browse files Browse the repository at this point in the history
Signed-off-by: Zzm0809 <[email protected]>
Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
2 people authored and donotcoffee committed Nov 12, 2024
1 parent 664b7ff commit 34c8611
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
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

0 comments on commit 34c8611

Please sign in to comment.