-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support brief report page (#477)
- Loading branch information
Showing
16 changed files
with
389 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ export default defineConfig({ | |
}, | ||
}, | ||
port: 9988, | ||
mode: 'Brief', | ||
mode: 'brief', | ||
}, | ||
]); | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
interface Window { | ||
[key: string]: any; | ||
__RSDOCTOR__: any; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Manifest, SDK } from '@rsdoctor/types'; | ||
import { Algorithm } from '@rsdoctor/utils/common'; | ||
import { BaseDataLoader } from './base'; | ||
import { Constants } from '@rsdoctor/types'; | ||
|
||
export class BriefDataLoader extends BaseDataLoader { | ||
public isLocal() { | ||
return false; | ||
} | ||
|
||
public async loadData<T extends Manifest.RsdoctorManifestMappingKeys>( | ||
key: T, | ||
): Promise<Manifest.InferManifestDataValue<T>>; | ||
|
||
public async loadData(key: string): Promise<unknown> { | ||
console.log(`[loadData]-[key]: ${key}`); | ||
const [scope] = this.getKeys(key); | ||
|
||
console.log(`[loadData]-[scope]: ${scope}`); | ||
const data = this.getData(scope); | ||
console.log(`[loadData]-[data]: ${data}`); | ||
|
||
if (!data) return; | ||
|
||
let res = data; | ||
|
||
// only cache by the root key in data | ||
if (!this.shardingDataMap.has(scope)) { | ||
const scopeData = | ||
typeof res === 'object' | ||
? res | ||
: JSON.parse(Algorithm.decompressText(res)); | ||
console.log(`[loadData]-[scopeData]: ${scopeData}`); | ||
this.shardingDataMap.set(scope, scopeData); | ||
} | ||
|
||
res = await this.shardingDataMap.get(scope); | ||
return res; | ||
} | ||
|
||
public getData(scope: keyof Manifest.RsdoctorManifestData) { | ||
console.log(`[getData]-[scope]: ${scope}`); | ||
return window[Constants.WINDOW_RSDOCTOR_TAG][scope]; | ||
} | ||
|
||
public async loadAPI< | ||
T extends SDK.ServerAPI.API, | ||
B extends | ||
SDK.ServerAPI.InferRequestBodyType<T> = SDK.ServerAPI.InferRequestBodyType<T>, | ||
R extends | ||
SDK.ServerAPI.InferResponseType<T> = SDK.ServerAPI.InferResponseType<T>, | ||
>(...args: B extends void ? [api: T] : [api: T, body: B]): Promise<R> { | ||
return this.loader.loadAPI(...args) as R; | ||
} | ||
|
||
public dispose() { | ||
super.dispose(); | ||
} | ||
|
||
public onDataUpdate() {} | ||
|
||
public removeOnDataUpdate() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.