Добавил автоопределение страны
This commit is contained in:
parent
576dfd3c5d
commit
8b8c0d64f4
40
popup/src/api/CountryResolver.ts
Normal file
40
popup/src/api/CountryResolver.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { Country } from '@/classes/Enum/Country'
|
||||
|
||||
export class CountryResolver {
|
||||
resolve (): Promise<Country> {
|
||||
const promise = new Promise((resolve) => {
|
||||
if (typeof chrome.tabs === 'undefined') {
|
||||
const country = this.grabCountry(location.href || '')
|
||||
resolve(country)
|
||||
return
|
||||
}
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
||||
for (const tab of tabs) {
|
||||
const country = this.grabCountry(tab.url || '')
|
||||
resolve(country)
|
||||
return
|
||||
}
|
||||
})
|
||||
})
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
||||
// @ts-ignore
|
||||
return promise.then((country) => {
|
||||
console.log('country', country)
|
||||
return country
|
||||
})
|
||||
}
|
||||
|
||||
grabCountry (url: string): Country {
|
||||
const isNordecum = url.indexOf('smspinigai') > -1 ||
|
||||
url.indexOf('paskolos') > -1 ||
|
||||
url.indexOf('nordecum') > -1
|
||||
|
||||
if (isNordecum) {
|
||||
return Country.LITHUANIA
|
||||
}
|
||||
|
||||
return Country.ESTONIA
|
||||
}
|
||||
}
|
||||
|
||||
export default new CountryResolver()
|
@ -10,6 +10,7 @@ import { Target } from '@/classes/Enum/Target'
|
||||
import sender from '@/classes/Service/Browser/Chrome/Sender'
|
||||
import { Action } from '@/classes/Enum/Action'
|
||||
import Mocks from '@/components/mocks/main.vue'
|
||||
import countryResolver from '@/api/CountryResolver'
|
||||
|
||||
Vue.use(VueClipboard)
|
||||
|
||||
@ -23,6 +24,10 @@ export default class PersonTab extends Vue {
|
||||
person = new Person()
|
||||
copyText = ''
|
||||
|
||||
async mounted () {
|
||||
this.person.country = await countryResolver.resolve()
|
||||
}
|
||||
|
||||
get allowedMonths () {
|
||||
const result = []
|
||||
for (let i = 1; i <= 12; i++) {
|
||||
|
@ -17,11 +17,9 @@
|
||||
<div class="form-row">
|
||||
<div class="form-row__item">
|
||||
<label>
|
||||
Country
|
||||
<select v-model="person.country">
|
||||
<option value="ee">Estonia</option>
|
||||
<option value="lt">Lithuania</option>
|
||||
</select>
|
||||
Country:
|
||||
<span v-if="person.country === 'ee'">Estonia</span>
|
||||
<span v-if="person.country === 'lt'">Lithuania</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-row__item">
|
||||
|
Loading…
Reference in New Issue
Block a user