mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
chore: revert declaring optional permissions
This commit is contained in:
parent
05d002e470
commit
cfe313f1d9
3 changed files with 12 additions and 13 deletions
|
|
@ -7,7 +7,6 @@
|
|||
"256": "icons/Gitako-256.png"
|
||||
},
|
||||
"permissions": ["storage", "*://*.github.com/*", "*://*.sentry.io/*"],
|
||||
"optional_permissions": ["<all_urls>"],
|
||||
"web_accessible_resources": ["icons/vscode/*", "content.css"],
|
||||
"content_scripts": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,28 +2,29 @@ import { dummyPlatformForTypeSafety } from './dummyPlatformForTypeSafety'
|
|||
import { Gitee } from './Gitee'
|
||||
import { GitHub } from './GitHub'
|
||||
|
||||
const platformsMap: Record<'GitHub' | 'Gitee', { platform: Platform; hosts: string[] }> = {
|
||||
GitHub: { platform: GitHub, hosts: ['github.com'] },
|
||||
Gitee: { platform: Gitee, hosts: ['gitee.com'] },
|
||||
const platforms: {
|
||||
[name: string]: Platform
|
||||
} = {
|
||||
GitHub: GitHub,
|
||||
Gitee: Gitee,
|
||||
}
|
||||
|
||||
function resolvePlatform() {
|
||||
for (const { hosts, platform } of Object.values(platformsMap)) {
|
||||
if (hosts.some(host => host === window.location.host || platform.resolveMeta())) {
|
||||
return platform
|
||||
}
|
||||
for (const platform of Object.values(platforms)) {
|
||||
if (platform.resolveMeta()) return platform
|
||||
}
|
||||
return dummyPlatformForTypeSafety
|
||||
}
|
||||
|
||||
export function getPlatformName() {
|
||||
const keys = Object.keys(platformsMap) as (keyof typeof platformsMap)[]
|
||||
function getPlatformName() {
|
||||
const keys = Object.keys(platforms) as (keyof typeof platforms)[]
|
||||
for (const key of keys) {
|
||||
if (platform === platformsMap[key].platform) return key
|
||||
if (platform === platforms[key]) return key
|
||||
}
|
||||
}
|
||||
|
||||
export const platform = resolvePlatform()
|
||||
export const platformName = getPlatformName()
|
||||
|
||||
export const errors = {
|
||||
SERVER_FAULT: 'Server Fault',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { getPlatformName } from 'platforms'
|
||||
import * as storageHelper from 'utils/storageHelper'
|
||||
|
||||
export type Config = {
|
||||
|
|
@ -74,7 +73,7 @@ async function migrateConfig() {
|
|||
let platformName: string
|
||||
const prepareConfig = new Promise(async resolve => {
|
||||
await migrateConfig()
|
||||
platformName = `platform_` + (await getPlatformName())
|
||||
platformName = `platform_` + platformName
|
||||
resolve()
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue