Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit 793788c

Browse files
authored
feat: add version in global settings (#558)
1 parent 3dd396b commit 793788c

File tree

7 files changed

+38
-3
lines changed

7 files changed

+38
-3
lines changed

src/assets/lang/zh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ const m = {
250250
addTraceID: '请输入一个Trace ID',
251251
addKeywordsOfContent: '请输入一个内容关键词',
252252
addExcludingKeywordsOfContent: '请输入一个内容不包含的关键词',
253-
NoticeTag: '请输入一个标签之后回车',
253+
noticeTag: '请输入一个标签之后回车',
254254
conditionNotice: '请输入一个标签、内容关键词或者内容不包含的关键词之后回车',
255255
cacheModalTitle: '清除缓存提醒',
256256
yes: '是的',

src/graph/fragments/option.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ export const OAPTimeInfo = {
7979
}
8080
`,
8181
};
82+
83+
export const OAPVersion = {
84+
query: `version { version }`,
85+
};

src/graph/query/option.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { Services, BrowserServices, Endpoints, Instances, Database, OAPTimeInfo } from '../fragments/option';
18+
import {
19+
Services,
20+
BrowserServices,
21+
Endpoints,
22+
Instances,
23+
Database,
24+
OAPTimeInfo,
25+
OAPVersion,
26+
} from '../fragments/option';
1927

2028
export const queryServices = `query queryServices(${Services.variable}) {${Services.query}}`;
2129

@@ -29,3 +37,5 @@ export const queryEndpoints = `query queryEndpoints(${Endpoints.variable}) {${En
2937
export const queryInstances = `query queryInstances(${Instances.variable}) {${Instances.query}}`;
3038

3139
export const queryOAPTimeInfo = `query queryOAPTimeInfo {${OAPTimeInfo.query}}`;
40+
41+
export const queryOAPVersion = `query ${OAPVersion.query}`;

src/store/modules/global/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import getDurationRow from '@/utils/datetime';
2121
import getLocalTime from '@/utils/localtime';
2222
import dateFormatStep, { dateFormatTime } from '@/utils/dateFormat';
2323
import { ActionTree, Commit, MutationTree } from 'vuex';
24+
import graph from '@/graph';
25+
import { AxiosResponse } from 'axios';
2426

2527
let timer: any = null;
2628
export interface State {
@@ -30,6 +32,7 @@ export interface State {
3032
edit: boolean;
3133
lock: boolean;
3234
utc: string;
35+
version: string;
3336
}
3437
const initState: State = {
3538
durationRow: getDurationRow(),
@@ -38,6 +41,7 @@ const initState: State = {
3841
edit: false,
3942
lock: true,
4043
utc: '',
44+
version: '',
4145
};
4246

4347
// getters
@@ -124,6 +128,9 @@ const mutations: MutationTree<State> = {
124128
[types.SET_EDIT](state: State, status: boolean): void {
125129
state.edit = status;
126130
},
131+
[types.SET_VERSION](state: State, version: string): void {
132+
state.version = version;
133+
},
127134
};
128135

129136
// actions
@@ -167,6 +174,13 @@ const actions: ActionTree<State, any> = {
167174
SET_LOCK(context: { commit: Commit }, status: boolean): void {
168175
context.commit(types.SET_LOCK, status);
169176
},
177+
async FETCH_VERSION(context: { commit: Commit }): Promise<void> {
178+
const res: AxiosResponse = await graph.query('queryOAPVersion').params({});
179+
if (!res.data.data) {
180+
return;
181+
}
182+
context.commit(types.SET_VERSION, res.data.data.version);
183+
},
170184
};
171185

172186
export default {

src/store/mutation-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const CLEAR_CHARTS = 'CLEAR_CHARTS';
3939
export const SET_LOCK = 'SET_LOCK';
4040
export const SET_EDIT = 'SET_EDIT';
4141
export const SET_UTC = 'SET_UTC';
42+
export const SET_VERSION = 'SET_VERSION';
4243

4344
// dashboard
4445
export const SET_GLOBAL = 'SET_GLOBAL';

src/views/components/common/page-tool-bar.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ limitations under the License. -->
2323
<rk-icon icon="keyboard_arrow_down" class="xll" id="settings" />
2424
</span>
2525
<div class="tool-bar-setting " v-show="showSetting" @click="markSettings">
26+
<div class="flex-h item">
27+
<span class="label">{{ $t('version') }}</span>
28+
<span>{{ rocketbotGlobal.version }}</span>
29+
</div>
2630
<div class="flex-h item">
2731
<span class="label">{{ $t('language') }}</span>
2832
<span>Zh</span>
@@ -65,6 +69,7 @@ limitations under the License. -->
6569
@State('rocketbot') private rocketbotGlobal: any;
6670
@Action('SET_DURATION') private SET_DURATION: any;
6771
@Action('SET_UTC') private SET_UTC: any;
72+
@Action('FETCH_VERSION') private FETCH_VERSION: any;
6873
private lang: string | null = '';
6974
private utcHour: number = 0;
7075
private utcMin: number = 0;
@@ -84,6 +89,7 @@ limitations under the License. -->
8489
this.utcMin = isNaN(Number(utcArr[1])) ? 0 : Number(utcArr[1]);
8590
this.SET_UTC(`${this.utcHour}:${this.utcMin}`);
8691
this.lang = window.localStorage.getItem('lang');
92+
this.FETCH_VERSION();
8793
}
8894
8995
private mounted() {

src/views/components/common/rk-header.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ limitations under the License. -->
8484
margin-right: 50px;
8585
}
8686
.nav-link {
87-
padding: 4px 10px;
87+
padding: 5px;
8888
border-radius: 4px;
8989
opacity: 0.8;
9090
color: #efeff1;

0 commit comments

Comments
 (0)