@@ -143,8 +143,9 @@ import locale from "./locale";
143143import I18nMixins from " ./mixins/i18n-mixins" ;
144144import ThemeSwitchMixins from " ./mixins/theme-switch-mixins.js" ;
145145import clickoutside from " ./directives/clickoutside.js" ;
146- import { version } from " ../../../package.json" ;
146+ import { version as latestVersion } from " ../../../package.json" ;
147147
148+ const RESOURCE_PATH = " /vue-easytable/" ;
148149export default {
149150 directives: {
150151 " click-outside" : clickoutside,
@@ -161,16 +162,20 @@ export default {
161162 // switch version option
162163 switchVersionOptions: [
163164 {
164- value: " https://happy-coding-clans.github.io/vue-easytable/2.11.0" ,
165+ value: ` ${ RESOURCE_PATH } 2.12.0/` ,
166+ label: " 2.12.0" ,
167+ },
168+ {
169+ value: ` ${ RESOURCE_PATH } 2.11.0/` ,
165170 label: " 2.11.0" ,
166171 },
167172 {
168- value: " https://happy-coding-clans.github.io/vue-easytable/ 1.7.2/app.html" ,
173+ value: ` ${ RESOURCE_PATH } 1.7.2/app.html` ,
169174 label: " 1.x" ,
175+ isVersion1: true ,
170176 },
171177 ],
172178 showVersionDropdown: false ,
173- currentDocVersion: version,
174179 };
175180 },
176181 computed: {
@@ -183,6 +188,19 @@ export default {
183188 showLogo () {
184189 return window .env !== " dev" ;
185190 },
191+
192+ // current doc version
193+ currentDocVersion () {
194+ const { switchVersionOptions } = this ;
195+
196+ const { pathname } = window .location ;
197+
198+ const versionItem = switchVersionOptions .find (
199+ (x ) => x .value === pathname,
200+ );
201+
202+ return versionItem ? versionItem .label : latestVersion;
203+ },
186204 },
187205 watch: {
188206 currentDocLang () {
@@ -210,14 +228,16 @@ export default {
210228 },
211229 // version change
212230 versionChange (item ) {
213- if (this .currentDocVersion !== item .label ) {
214- window .location .href = item .value ;
231+ const { protocol , host , pathname , hash } = window .location ;
232+ // version 1.0
233+ if (item .isVersion1 ) {
234+ const newUrl = protocol + " //" + host + item .value ;
235+ window .open (newUrl, " _blank" );
236+ } else {
237+ const newUrl = protocol + " //" + host + item .value + hash;
238+ alert (newUrl);
239+ window .open (item .value , " _self" );
215240 }
216- this .currentDocVersion = item .label ;
217-
218- setTimeout (() => {
219- this .showVersionDropdown = false ;
220- }, 150 );
221241 },
222242 // go ro router path
223243 gotoRouter (item ) {
0 commit comments