chore: revert declaring optional permissions

This commit is contained in:
EnixCoda 2020-04-04 17:07:54 +08:00
parent 05d002e470
commit cfe313f1d9
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD
3 changed files with 12 additions and 13 deletions

View file

@ -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": [
{

View file

@ -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',

View file

@ -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()
})