mirror of
https://github.com/movie-web/extension.git
synced 2025-09-13 07:03:24 +00:00
Unify version gathering
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { PlasmoMessaging } from '@plasmohq/messaging';
|
||||
|
||||
import { getVersion } from '~hooks/useVersion';
|
||||
import type { BaseRequest } from '~types/request';
|
||||
import type { BaseResponse } from '~types/response';
|
||||
import { assertDomainWhitelist } from '~utils/storage';
|
||||
@@ -11,8 +12,7 @@ type Response = BaseResponse<{
|
||||
const handler: PlasmoMessaging.MessageHandler<BaseRequest, Response> = async (req, res) => {
|
||||
try {
|
||||
await assertDomainWhitelist(req.body.requestDomain);
|
||||
|
||||
const version = chrome.runtime.getManifest().version;
|
||||
const version = getVersion();
|
||||
|
||||
res.send({
|
||||
success: true,
|
||||
|
@@ -1,4 +1,8 @@
|
||||
export function useVersion(ops?: { prefixed?: boolean }) {
|
||||
export function getVersion(ops?: { prefixed?: boolean }) {
|
||||
const prefix = ops?.prefixed ? 'v' : '';
|
||||
return `${prefix}${chrome.runtime.getManifest().version}`;
|
||||
}
|
||||
|
||||
export function useVersion(ops?: { prefixed?: boolean }) {
|
||||
return getVersion(ops);
|
||||
}
|
||||
|
Reference in New Issue
Block a user