Skip to content

Commit

Permalink
version for two clients
Browse files Browse the repository at this point in the history
  • Loading branch information
mentalisit committed May 7, 2024
1 parent f47c413 commit d259609
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 5 deletions.
13 changes: 11 additions & 2 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@vitejs/plugin-vue": "^5.0.4",
"@vueuse/head": "^2.0.0",
"bot_client": "github:mcgoldric/compendium-client",
"bot_client2": "github:mentalisit/compendium-client-new",
"jsoncrush": "^1.1.8",
"lodash.debounce": "^4.0.8",
"parse-markdown-table": "^0.0.6",
Expand Down
36 changes: 35 additions & 1 deletion src/components/CompendiumPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@
</div>
<p />
</div>
<!--suppress TypeScriptUnresolvedReference -->
<!-- <div v-if="user.alts" class="select">-->
<div
v-if="user?.alts && user?.alts?.length!==0"
class="select"
>
<select @change="(e) => selectUserAlts(e.target.value)">
<option
:value="user?.username"
:selected="ReadCurrentAlt() === user?.username"
>{{ user?.username }}</option>
<option
v-for="(alt, index) in user?.alts"
:key="index"
:value="alt"
:selected="ReadCurrentAlt() === alt"
>
{{ alt }}
</option>
</select>
</div>
<div
v-if="user"
class="logged"
Expand Down Expand Up @@ -187,6 +208,18 @@ async function applyReqCode() {
isFetching.value = false;
}
}
function selectUserAlts(name: string) {
const u = client.getUser();
if (u?.username === name) {
localStorage.setItem('currentAlt', '' );
} else {
localStorage.setItem('currentAlt', name);
}
window.location.reload();
}
function ReadCurrentAlt():string {
return localStorage.getItem('currentAlt') || '';
}
function userProfileClick() {
store.dispatch(types.OPEN_CONFIRM, t('TID_SETTINGS_DLG_SIGN_OUT'))
.then(() => {
Expand All @@ -212,7 +245,8 @@ function userProfileClick() {
.content {
margin: 0 5%;
display: flex;
justify-content: end;
justify-content: space-between;
align-items: center;
@media screen and (max-width: 1000px){
margin: 0 1%;
Expand Down
11 changes: 9 additions & 2 deletions src/utils/compendium.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { Compendium } from 'bot_client';
import { Compendium as Client1 } from 'bot_client';
import { Compendium as Client2 } from 'bot_client2';
import store from '../../src/store/index';

const client = new Compendium();
function getClient() {
const useClient2 = store.state.userSettings.disableFilters; // нужно где то что то придумать вместо фильтра
return useClient2 ? new Client2() : new Client1();
}

const client = getClient();
let initialized = false;

export default client;
Expand Down

0 comments on commit d259609

Please sign in to comment.