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