mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
chore: minor adjustments
This commit is contained in:
parent
f379d0ebe6
commit
4f5d0cc995
3 changed files with 26 additions and 12 deletions
|
|
@ -199,6 +199,9 @@ $minimal-z-index: max($github-header-z-index, $github-pull-request-float-header-
|
|||
|
||||
.#{$name}-side-bar {
|
||||
@import '~@primer/css/base/index.scss';
|
||||
button {
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.#{$name}-position-wrapper {
|
||||
position: fixed;
|
||||
|
|
|
|||
|
|
@ -2,16 +2,17 @@ export const dummyPlatformForTypeSafety: Platform = {
|
|||
resolveMeta() {
|
||||
return null
|
||||
},
|
||||
getMetaData: callingDummyPlatformMethods,
|
||||
getTreeData: callingDummyPlatformMethods,
|
||||
getMetaData: dummyPlatformMethod,
|
||||
getTreeData: dummyPlatformMethod,
|
||||
shouldShow() {
|
||||
return false
|
||||
},
|
||||
getCurrentPath: callingDummyPlatformMethods,
|
||||
setOAuth: callingDummyPlatformMethods,
|
||||
useResizeStylesheets: callingDummyPlatformMethods,
|
||||
getCurrentPath: dummyPlatformMethod,
|
||||
setOAuth: dummyPlatformMethod,
|
||||
useResizeStylesheets: dummyPlatformMethod,
|
||||
getOAuthLink: dummyPlatformMethod,
|
||||
}
|
||||
|
||||
function callingDummyPlatformMethods(): any {
|
||||
function dummyPlatformMethod(): any {
|
||||
throw new Error(`Do not call dummy platform methods`)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,13 +14,14 @@ const platformsMap: Record<
|
|||
|
||||
const CustomDomainsStorageKey = 'CUSTOM_DOMAINS'
|
||||
async function loadCustomDomains() {
|
||||
const c = await storageHelper.get([CustomDomainsStorageKey])
|
||||
if (c) {
|
||||
const { [CustomDomainsStorageKey]: customDomains } = c
|
||||
const config = await storageHelper.get([CustomDomainsStorageKey])
|
||||
if (config) {
|
||||
const { [CustomDomainsStorageKey]: customDomains } = config
|
||||
type CustomDomains = Record<string, string> // domain -> Platform
|
||||
if (customDomains) {
|
||||
Object.keys(customDomains).forEach(domain => {
|
||||
if (domain in platformsMap) {
|
||||
platformsMap[domain as keyof typeof platformsMap].hosts.push(...customDomains[domain])
|
||||
Object.keys(customDomains as CustomDomains).forEach(domain => {
|
||||
if (customDomains[domain] in platformsMap) {
|
||||
platformsMap[customDomains[domain] as keyof typeof platformsMap].hosts.push(domain)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -42,6 +43,15 @@ let $platform: Platform = dummyPlatformForTypeSafety
|
|||
export const resolvePlatformP = resolvePlatform()
|
||||
resolvePlatformP.then(platform => ($platform = platform))
|
||||
|
||||
export async function getPlatformName() {
|
||||
await resolvePlatformP
|
||||
const keys = Object.keys(platformsMap) as (keyof typeof platformsMap)[]
|
||||
for (const key of keys) {
|
||||
const { platform } = platformsMap[key]
|
||||
if (platform === $platform) return key
|
||||
}
|
||||
}
|
||||
|
||||
export const platform: Platform = new Proxy<Platform>(dummyPlatformForTypeSafety, {
|
||||
get(target, key: keyof Platform) {
|
||||
return $platform[key]
|
||||
|
|
|
|||
Loading…
Reference in a new issue