feat: tranbox: mobile support
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
|||||||
URL_BAIDU_WEB,
|
URL_BAIDU_WEB,
|
||||||
URL_BAIDU_TRANSAPI_V2,
|
URL_BAIDU_TRANSAPI_V2,
|
||||||
URL_BAIDU_TRANSAPI,
|
URL_BAIDU_TRANSAPI,
|
||||||
|
DEFAULT_USER_AGENT,
|
||||||
} from "../config";
|
} from "../config";
|
||||||
import { fetchApi } from "../libs/fetch";
|
import { fetchApi } from "../libs/fetch";
|
||||||
|
|
||||||
@@ -248,7 +249,9 @@ export const genBaidu = async ({ text, from, to }) => {
|
|||||||
|
|
||||||
const init = {
|
const init = {
|
||||||
headers: {
|
headers: {
|
||||||
|
// Origin: "https://fanyi.baidu.com",
|
||||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
"User-Agent": DEFAULT_USER_AGENT,
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: queryString.stringify(data),
|
body: queryString.stringify(data),
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ export const URL_BAIDU_TRANSAPI_V2 = "https://fanyi.baidu.com/v2transapi";
|
|||||||
export const URL_DEEPLFREE_TRAN = "https://www2.deepl.com/jsonrpc";
|
export const URL_DEEPLFREE_TRAN = "https://www2.deepl.com/jsonrpc";
|
||||||
export const URL_TENCENT_TRANSMART = "https://transmart.qq.com/api/imt";
|
export const URL_TENCENT_TRANSMART = "https://transmart.qq.com/api/imt";
|
||||||
|
|
||||||
|
export const DEFAULT_USER_AGENT =
|
||||||
|
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36";
|
||||||
|
|
||||||
export const OPT_TRANS_GOOGLE = "Google";
|
export const OPT_TRANS_GOOGLE = "Google";
|
||||||
export const OPT_TRANS_MICROSOFT = "Microsoft";
|
export const OPT_TRANS_MICROSOFT = "Microsoft";
|
||||||
export const OPT_TRANS_DEEPL = "DeepL";
|
export const OPT_TRANS_DEEPL = "DeepL";
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ export default function TranBtn({ onClick, position, tranboxSetting }) {
|
|||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="20"
|
width={isMobile ? "32" : "20"}
|
||||||
height="20"
|
height={isMobile ? "32" : "20"}
|
||||||
viewBox="0 0 32 32"
|
viewBox="0 0 32 32"
|
||||||
version="1.1"
|
version="1.1"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ export default function Slection({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: mobile support
|
// todo: mobile support
|
||||||
window.addEventListener("mouseup", handleMouseup);
|
// window.addEventListener("mouseup", handleMouseup);
|
||||||
// window.addEventListener(isMobile ? "touchend" : "mouseup", handleMouseup);
|
window.addEventListener(isMobile ? "touchend" : "mouseup", handleMouseup);
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener(
|
window.removeEventListener(
|
||||||
isMobile ? "touchend" : "mouseup",
|
isMobile ? "touchend" : "mouseup",
|
||||||
|
|||||||
Reference in New Issue
Block a user