From 6785d1ac2b5fe00ab39bd07d9dd1aa8ae8d92ce3 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Sat, 24 Jun 2023 20:17:52 +0800 Subject: [PATCH] :art: Unified code style --- .prettierrc.json | 15 ++++++++++++++ bin/builders/BaseBuilder.ts | 33 +++++++++++++------------------ bin/builders/LinuxBuilder.ts | 7 +++---- bin/builders/MacBuilder.ts | 4 ++-- bin/builders/WinBuilder.ts | 2 +- bin/cli.ts | 5 ++--- bin/helpers/merge.ts | 19 ++++++------------ bin/helpers/rust.ts | 6 +++--- bin/helpers/tauriConfig.ts | 6 +++--- bin/options/icon.ts | 11 +++++++---- bin/options/index.ts | 11 +++++++---- bin/options/logger.ts | 10 +++++----- bin/types.ts | 1 - bin/utils/dir.ts | 5 +---- bin/utils/info.ts | 30 +++++++++++----------------- bin/utils/ip.ts | 5 ++--- bin/utils/shell.ts | 6 +++--- bin/utils/url.ts | 3 +-- src-tauri/src/inject/component.js | 9 ++++----- src-tauri/src/inject/event.js | 22 ++++++++++----------- src-tauri/src/inject/style.js | 2 +- src-tauri/tauri.conf.json | 8 ++------ src-tauri/tauri.linux.conf.json | 4 +++- 23 files changed, 107 insertions(+), 117 deletions(-) create mode 100644 .prettierrc.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 000000000..9b8066cd5 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,15 @@ +{ + "arrowParens": "avoid", + "bracketSpacing": true, + "endOfLine": "lf", + "bracketSameLine": false, + "jsxSingleQuote": false, + "printWidth": 120, + "proseWrap": "preserve", + "quoteProps": "as-needed", + "semi": true, + "singleQuote": true, + "tabWidth": 2, + "trailingComma": "all", + "useTabs": false +} diff --git a/bin/builders/BaseBuilder.ts b/bin/builders/BaseBuilder.ts index 50701957a..66adbbf3a 100644 --- a/bin/builders/BaseBuilder.ts +++ b/bin/builders/BaseBuilder.ts @@ -1,17 +1,17 @@ import path from 'path'; -import fsExtra from "fs-extra"; -import chalk from "chalk"; +import fsExtra from 'fs-extra'; +import chalk from 'chalk'; import prompts from 'prompts'; import { PakeAppOptions } from '@/types'; import { checkRustInstalled, installRust } from '@/helpers/rust'; -import { mergeConfig } from "@/helpers/merge"; +import { mergeConfig } from '@/helpers/merge'; import tauriConfig from '@/helpers/tauriConfig'; import { npmDirectory } from '@/utils/dir'; -import { getSpinner } from "@/utils/info"; +import { getSpinner } from '@/utils/info'; import { shellExec } from '@/utils/shell'; import { isChinaDomain } from '@/utils/ip'; -import { IS_MAC } from "@/utils/platform"; +import { IS_MAC } from '@/utils/platform'; import logger from '@/options/logger'; export default abstract class BaseBuilder { @@ -23,8 +23,8 @@ export default abstract class BaseBuilder { async prepare() { if (!IS_MAC) { - logger.info('⚙︎ The first use requires installing system dependencies.'); - logger.info('⚙︎ See more in https://tauri.app/v1/guides/getting-started/prerequisites.'); + logger.info('✺ The first use requires installing system dependencies.'); + logger.info('✺ See more in https://tauri.app/v1/guides/getting-started/prerequisites.'); } if (!checkRustInstalled()) { @@ -42,14 +42,14 @@ export default abstract class BaseBuilder { } } - const isChina = await isChinaDomain("www.npmjs.com"); + const isChina = await isChinaDomain('www.npmjs.com'); const spinner = getSpinner('Installing package...'); if (isChina) { - logger.info("⚙︎ Located in China, using npm/rsProxy CN mirror."); - const rustProjectDir = path.join(npmDirectory, 'src-tauri', ".cargo"); + logger.info('✺ Located in China, using npm/rsProxy CN mirror.'); + const rustProjectDir = path.join(npmDirectory, 'src-tauri', '.cargo'); await fsExtra.ensureDir(rustProjectDir); - const projectCnConf = path.join(npmDirectory, "src-tauri", "rust_proxy.toml"); - const projectConf = path.join(rustProjectDir, "config"); + const projectCnConf = path.join(npmDirectory, 'src-tauri', 'rust_proxy.toml'); + const projectConf = path.join(rustProjectDir, 'config'); await fsExtra.copy(projectCnConf, projectConf); await shellExec(`cd "${npmDirectory}" && npm install --registry=https://registry.npmmirror.com`); } else { @@ -89,7 +89,7 @@ export default abstract class BaseBuilder { abstract getFileName(): string; protected getBuildCommand(): string { - return "npm run build"; + return 'npm run build'; } protected getBasePath(): string { @@ -97,11 +97,6 @@ export default abstract class BaseBuilder { } protected getBuildAppPath(npmDirectory: string, fileName: string, fileType: string): string { - return path.join( - npmDirectory, - this.getBasePath(), - fileType.toLowerCase(), - `${fileName}.${fileType}` - ); + return path.join(npmDirectory, this.getBasePath(), fileType.toLowerCase(), `${fileName}.${fileType}`); } } diff --git a/bin/builders/LinuxBuilder.ts b/bin/builders/LinuxBuilder.ts index 25737a4b7..93ce82a5f 100644 --- a/bin/builders/LinuxBuilder.ts +++ b/bin/builders/LinuxBuilder.ts @@ -3,22 +3,21 @@ import { PakeAppOptions } from '@/types'; import tauriConfig from '@/helpers/tauriConfig'; export default class LinuxBuilder extends BaseBuilder { - constructor(options: PakeAppOptions) { super(options); } getFileName(): string { const { name } = this.options; - const arch = process.arch === "x64" ? "amd64" : process.arch; + const arch = process.arch === 'x64' ? 'amd64' : process.arch; return `${name}_${tauriConfig.package.version}_${arch}`; } // Customize it, considering that there are all targets. async build(url: string) { - const targetTypes = ["deb", "appimage"]; + const targetTypes = ['deb', 'appimage']; for (const target of targetTypes) { - if (this.options.targets === target || this.options.targets === "all") { + if (this.options.targets === target || this.options.targets === 'all') { await this.buildAndCopy(url, target); } } diff --git a/bin/builders/MacBuilder.ts b/bin/builders/MacBuilder.ts index d0441d813..28d124d73 100644 --- a/bin/builders/MacBuilder.ts +++ b/bin/builders/MacBuilder.ts @@ -5,7 +5,7 @@ import BaseBuilder from './BaseBuilder'; export default class MacBuilder extends BaseBuilder { constructor(options: PakeAppOptions) { super(options); - this.options.targets = "dmg"; + this.options.targets = 'dmg'; } getFileName(): string { @@ -14,7 +14,7 @@ export default class MacBuilder extends BaseBuilder { if (this.options.multiArch) { arch = 'universal'; } else { - arch = process.arch === "arm64" ? "aarch64" : process.arch; + arch = process.arch === 'arm64' ? 'aarch64' : process.arch; } return `${name}_${tauriConfig.package.version}_${arch}`; } diff --git a/bin/builders/WinBuilder.ts b/bin/builders/WinBuilder.ts index c4ca2a144..61c687a67 100644 --- a/bin/builders/WinBuilder.ts +++ b/bin/builders/WinBuilder.ts @@ -5,7 +5,7 @@ import tauriConfig from '@/helpers/tauriConfig'; export default class WinBuilder extends BaseBuilder { constructor(options: PakeAppOptions) { super(options); - this.options.targets = "msi"; + this.options.targets = 'msi'; } getFileName(): string { diff --git a/bin/cli.ts b/bin/cli.ts index 9b7a143a4..d501856df 100644 --- a/bin/cli.ts +++ b/bin/cli.ts @@ -33,14 +33,13 @@ program .option('--debug', 'Debug mode', DEFAULT.debug) .version(packageJson.version, '-v, --version', 'Output the current version') .action(async (url: string, options: PakeCliOptions) => { - await checkUpdateTips(); if (!url) { - program.outputHelp((str) => { + program.outputHelp(str => { return str .split('\n') - .filter((line) => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line)) + .filter(line => !/((-h,|--help)|((-v|-V),|--version))\s+.+$/.test(line)) .join('\n'); }); process.exit(0); diff --git a/bin/helpers/merge.ts b/bin/helpers/merge.ts index 5004fb2c5..d4095a361 100644 --- a/bin/helpers/merge.ts +++ b/bin/helpers/merge.ts @@ -5,11 +5,7 @@ import { npmDirectory } from '@/utils/dir'; import logger from '@/options/logger'; import { PakeAppOptions, PlatformMap } from '@/types'; -export async function mergeConfig( - url: string, - options: PakeAppOptions, - tauriConf: any, -) { +export async function mergeConfig(url: string, options: PakeAppOptions, tauriConf: any) { const { width, height, @@ -61,7 +57,7 @@ export async function mergeConfig( const filesToCopyBack = ['cli.js', 'about_pake.html']; await Promise.all( - filesToCopyBack.map((file) => + filesToCopyBack.map(file => fsExtra.copy(path.join(distBakDir, file), path.join(distDir, file)), ), ); @@ -72,8 +68,7 @@ export async function mergeConfig( } else { tauriConf.pake.windows[0].url_type = 'web'; // Set the secure domain for calling window.__TAURI__ to the application domain that has been set. - tauriConf.tauri.security.dangerousRemoteDomainIpcAccess[0].domain = - new URL(url).hostname; + tauriConf.tauri.security.dangerousRemoteDomainIpcAccess[0].domain = new URL(url).hostname; } const platformMap: PlatformMap = { @@ -95,7 +90,8 @@ export async function mergeConfig( delete tauriConf.tauri.bundle.deb.files; const validTargets = ['all', 'deb', 'appimage']; if (validTargets.includes(options.targets)) { - tauriConf.tauri.bundle.targets = options.targets === 'all' ? ['deb', 'appimage'] : [options.targets]; + tauriConf.tauri.bundle.targets = + options.targets === 'all' ? ['deb', 'appimage'] : [options.targets]; } else { logger.warn( `✼ The target must be one of ${validTargets.join(', ')}, the default 'deb' will be used.`, @@ -165,9 +161,7 @@ export async function mergeConfig( trayIconPath = `png/${name.toLowerCase()}${iconExt}`; await fsExtra.copy(systemTrayIcon, trayIcoPath); } else { - logger.warn( - `✼ System tray icon must be .ico or .png, but you provided ${iconExt}.`, - ); + logger.warn(`✼ System tray icon must be .ico or .png, but you provided ${iconExt}.`); logger.warn(`✼ Default system tray icon will be used.`); } } catch { @@ -192,7 +186,6 @@ export async function mergeConfig( const pakeConfigPath = path.join(npmDirectory, 'src-tauri/pake.json'); await fsExtra.writeJson(pakeConfigPath, tauriConf.pake, { spaces: 4 }); - let tauriConf2 = JSON.parse(JSON.stringify(tauriConf)); delete tauriConf2.pake; delete tauriConf2.tauri.bundle; diff --git a/bin/helpers/rust.ts b/bin/helpers/rust.ts index c15d91f26..bf53087fd 100644 --- a/bin/helpers/rust.ts +++ b/bin/helpers/rust.ts @@ -1,13 +1,13 @@ -import chalk from "chalk"; +import chalk from 'chalk'; import shelljs from 'shelljs'; -import { getSpinner } from "@/utils/info"; +import { getSpinner } from '@/utils/info'; import { IS_WIN } from '@/utils/platform'; import { shellExec } from '@/utils/shell'; import { isChinaDomain } from '@/utils/ip'; export async function installRust() { - const isInChina = await isChinaDomain("sh.rustup.rs"); + const isInChina = await isChinaDomain('sh.rustup.rs'); const rustInstallScriptForMac = isInChina ? 'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh' : "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"; diff --git a/bin/helpers/tauriConfig.ts b/bin/helpers/tauriConfig.ts index 998dff7f6..32c3b83e1 100644 --- a/bin/helpers/tauriConfig.ts +++ b/bin/helpers/tauriConfig.ts @@ -7,10 +7,10 @@ import LinuxConf from '../../src-tauri/tauri.linux.conf.json'; const platformConfigs = { win32: WinConf, darwin: MacConf, - linux: LinuxConf + linux: LinuxConf, }; -const {platform} = process; +const { platform } = process; // @ts-ignore const platformConfig = platformConfigs[platform]; @@ -21,7 +21,7 @@ let tauriConfig = { }, package: CommonConf.package, build: CommonConf.build, - pake: pakeConf + pake: pakeConf, }; export default tauriConfig; diff --git a/bin/options/icon.ts b/bin/options/icon.ts index 0b6951aa0..6ee54e6ba 100644 --- a/bin/options/icon.ts +++ b/bin/options/icon.ts @@ -1,14 +1,13 @@ import path from 'path'; import axios from 'axios'; -import fsExtra from "fs-extra"; +import fsExtra from 'fs-extra'; import chalk from 'chalk'; import { dir } from 'tmp-promise'; - import logger from './logger'; import { npmDirectory } from '@/utils/dir'; import { IS_LINUX, IS_WIN } from '@/utils/platform'; -import { getSpinner } from "@/utils/info"; +import { getSpinner } from '@/utils/info'; import { fileTypeFromBuffer } from 'file-type'; import { PakeAppOptions } from '@/types'; @@ -21,7 +20,11 @@ export async function handleIcon(options: PakeAppOptions) { } } else { logger.warn('✼ No icon given, default in use. For a custom icon, use --icon option.'); - const iconPath = IS_WIN ? 'src-tauri/png/icon_256.ico' : IS_LINUX ? 'src-tauri/png/icon_512.png' : 'src-tauri/icons/icon.icns'; + const iconPath = IS_WIN + ? 'src-tauri/png/icon_256.ico' + : IS_LINUX + ? 'src-tauri/png/icon_512.png' + : 'src-tauri/icons/icon.icns'; return path.join(npmDirectory, iconPath); } } diff --git a/bin/options/index.ts b/bin/options/index.ts index a8adad241..17f41d951 100644 --- a/bin/options/index.ts +++ b/bin/options/index.ts @@ -1,5 +1,5 @@ -import fsExtra from "fs-extra"; -import logger from "@/options/logger"; +import fsExtra from 'fs-extra'; +import logger from '@/options/logger'; import { handleIcon } from './icon'; import { getDomain } from '@/utils/url'; @@ -20,14 +20,17 @@ function isValidName(name: string, platform: NodeJS.Platform): boolean { return !!name && reg.test(name); } -export default async function handleOptions(options: PakeCliOptions, url: string): Promise { +export default async function handleOptions( + options: PakeCliOptions, + url: string, +): Promise { const { platform } = process; const isActions = process.env.GITHUB_ACTIONS; let name = options.name; const pathExists = await fsExtra.pathExists(url); if (!options.name) { - const defaultName = pathExists ? "" : resolveAppName(url, platform); + const defaultName = pathExists ? '' : resolveAppName(url, platform); const promptMessage = 'Enter your application name'; const namePrompt = await promptText(promptMessage, defaultName); name = namePrompt || defaultName; diff --git a/bin/options/logger.ts b/bin/options/logger.ts index 60394882e..0461d4cdb 100644 --- a/bin/options/logger.ts +++ b/bin/options/logger.ts @@ -3,20 +3,20 @@ import log from 'loglevel'; const logger = { info(...msg: any[]) { - log.info(...msg.map((m) => chalk.white(m))); + log.info(...msg.map(m => chalk.white(m))); }, debug(...msg: any[]) { log.debug(...msg); }, error(...msg: any[]) { - log.error(...msg.map((m) => chalk.red(m))); + log.error(...msg.map(m => chalk.red(m))); }, warn(...msg: any[]) { - log.info(...msg.map((m) => chalk.yellow(m))); + log.info(...msg.map(m => chalk.yellow(m))); }, success(...msg: any[]) { - log.info(...msg.map((m) => chalk.green(m))); - } + log.info(...msg.map(m => chalk.green(m))); + }, }; export default logger; diff --git a/bin/types.ts b/bin/types.ts index 02739b944..836d9bb94 100644 --- a/bin/types.ts +++ b/bin/types.ts @@ -1,4 +1,3 @@ - export interface PlatformMap { [key: string]: any; } diff --git a/bin/utils/dir.ts b/bin/utils/dir.ts index bfc4f2984..cb5a697b6 100644 --- a/bin/utils/dir.ts +++ b/bin/utils/dir.ts @@ -5,7 +5,4 @@ import { fileURLToPath } from 'url'; const currentModulePath = fileURLToPath(import.meta.url); // Resolve the parent directory of the current module -export const npmDirectory = path.join( - path.dirname(currentModulePath), - '..' -); +export const npmDirectory = path.join(path.dirname(currentModulePath), '..'); diff --git a/bin/utils/info.ts b/bin/utils/info.ts index 21f7992e8..a08a72621 100644 --- a/bin/utils/info.ts +++ b/bin/utils/info.ts @@ -1,14 +1,11 @@ import crypto from 'crypto'; -import prompts from "prompts"; -import ora from "ora"; +import prompts from 'prompts'; +import ora from 'ora'; import chalk from 'chalk'; // Generates an identifier based on the given URL. export function getIdentifier(url: string) { - const postFixHash = crypto.createHash('md5') - .update(url) - .digest('hex') - .substring(0, 6); + const postFixHash = crypto.createHash('md5').update(url).digest('hex').substring(0, 6); return `pake-${postFixHash}`; } @@ -28,17 +25,12 @@ export function capitalizeFirstLetter(string: string) { export function getSpinner(text: string) { const loadingType = { - "interval": 80, - "frames": [ - "✦", - "✶", - "✺", - "✵", - "✸", - "✴︎", - "✹", - "✺", - ] - } - return ora({ text: `${chalk.blue(text)}\n`, spinner: loadingType, color: 'blue' }).start(); + interval: 80, + frames: ['✦', '✶', '✺', '✵', '✸', '✹', '✺'], + }; + return ora({ + text: `${chalk.cyan(text)}\n`, + spinner: loadingType, + color: 'cyan', + }).start(); } diff --git a/bin/utils/ip.ts b/bin/utils/ip.ts index 588e1e793..c3b64340e 100644 --- a/bin/utils/ip.ts +++ b/bin/utils/ip.ts @@ -13,13 +13,13 @@ const ping = async (host: string) => { // Prevent timeouts from affecting user experience. const requestPromise = new Promise((resolve, reject) => { - const req = http.get(`http://${ip.address}`, (res) => { + const req = http.get(`http://${ip.address}`, res => { const delay = new Date().getTime() - start.getTime(); res.resume(); resolve(delay); }); - req.on('error', (err) => { + req.on('error', err => { reject(err); }); }); @@ -33,7 +33,6 @@ const ping = async (host: string) => { return Promise.race([requestPromise, timeoutPromise]); }; - async function isChinaDomain(domain: string): Promise { try { const [ip] = await resolve(domain); diff --git a/bin/utils/shell.ts b/bin/utils/shell.ts index 684dc1427..54630756b 100644 --- a/bin/utils/shell.ts +++ b/bin/utils/shell.ts @@ -1,9 +1,9 @@ -import shelljs from "shelljs"; -import { npmDirectory } from "./dir"; +import shelljs from 'shelljs'; +import { npmDirectory } from './dir'; export function shellExec(command: string) { return new Promise((resolve, reject) => { - shelljs.exec(command, { async: true, silent: false, cwd: npmDirectory }, (code) => { + shelljs.exec(command, { async: true, silent: false, cwd: npmDirectory }, code => { if (code === 0) { resolve(0); } else { diff --git a/bin/utils/url.ts b/bin/utils/url.ts index 51050dfaf..6c19ff3b4 100644 --- a/bin/utils/url.ts +++ b/bin/utils/url.ts @@ -9,7 +9,7 @@ export function getDomain(inputUrl: string): string | null { const parsed = psl.parse(url.hostname); // If domain is available, split it and return the SLD. - if ("domain" in parsed && parsed.domain) { + if ('domain' in parsed && parsed.domain) { return parsed.domain.split('.')[0]; } else { return null; @@ -19,7 +19,6 @@ export function getDomain(inputUrl: string): string | null { } } - // Appends 'https://' protocol to the URL if not present. export function appendProtocol(inputUrl: string): string { try { diff --git a/src-tauri/src/inject/component.js b/src-tauri/src/inject/component.js index 31ee045ed..f77a9755f 100644 --- a/src-tauri/src/inject/component.js +++ b/src-tauri/src/inject/component.js @@ -136,8 +136,7 @@ document.addEventListener('DOMContentLoaded', () => { document.body.appendChild(m); setTimeout(function () { const d = 0.5; - m.style.transition = - 'transform ' + d + 's ease-in, opacity ' + d + 's ease-in'; + m.style.transition = 'transform ' + d + 's ease-in, opacity ' + d + 's ease-in'; m.style.opacity = '0'; setTimeout(function () { document.body.removeChild(m); @@ -151,14 +150,14 @@ document.addEventListener('DOMContentLoaded', () => { if (window.location.hostname === 'chat.openai.com') { const originFetch = fetch; window.fetch = (url, options) => { - return originFetch(url, options).then(async (response) => { + return originFetch(url, options).then(async response => { if (url.indexOf('/backend-api/models') === -1) { return response; } const responseClone = response.clone(); let res = await responseClone.json(); - res.models = res.models.map((m) => { - m.tags = m.tags.filter((t) => { + res.models = res.models.map(m => { + m.tags = m.tags.filter(t => { return t !== 'mobile'; }); if (m.slug === 'gpt-4-mobile') { diff --git a/src-tauri/src/inject/event.js b/src-tauri/src/inject/event.js index 7a66cc72c..75460a9b5 100644 --- a/src-tauri/src/inject/event.js +++ b/src-tauri/src/inject/event.js @@ -82,14 +82,14 @@ async function invoke(cmd, args) { // Judgment of file download. function isDownloadLink(url) { - const fileExtensions = [ - '3gp', '7z', 'ai', 'apk', 'avi', 'bmp', 'csv', 'dmg', 'doc', 'docx', 'fla', 'flv', 'gif', 'gz', 'gzip', - 'ico', 'iso', 'indd', 'jar', 'jpeg', 'jpg', 'm3u8', 'mov', 'mp3', 'mp4', 'mpa', 'mpg', - 'mpeg', 'msi', 'odt', 'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'rar', 'raw', 'rss', 'svg', - 'swf', 'tar', 'tif', 'tiff', 'ts', 'txt', 'wav', 'webm', 'webp', 'wma', 'wmv', 'xls', 'xlsx', 'xml', 'zip' - ]; - const downloadLinkPattern = new RegExp(`\\.(${fileExtensions.join('|')})$`, 'i'); - return downloadLinkPattern.test(url); + const fileExtensions = [ + '3gp', '7z', 'ai', 'apk', 'avi', 'bmp', 'csv', 'dmg', 'doc', 'docx', 'fla', 'flv', 'gif', 'gz', 'gzip', + 'ico', 'iso', 'indd', 'jar', 'jpeg', 'jpg', 'm3u8', 'mov', 'mp3', 'mp4', 'mpa', 'mpg', + 'mpeg', 'msi', 'odt', 'ogg', 'ogv', 'pdf', 'png', 'ppt', 'pptx', 'psd', 'rar', 'raw', 'rss', 'svg', + 'swf', 'tar', 'tif', 'tiff', 'ts', 'txt', 'wav', 'webm', 'webp', 'wma', 'wmv', 'xls', 'xlsx', 'xml', 'zip', + ]; + const downloadLinkPattern = new RegExp(`\\.(${fileExtensions.join('|')})$`, 'i'); + return downloadLinkPattern.test(url); } // No need to go to the download link. @@ -185,7 +185,7 @@ document.addEventListener('DOMContentLoaded', () => { // Rewrite the window.open function. const originalWindowOpen = window.open; - window.open = function (url, name, specs) { + window.open = function(url, name, specs) { // Apple login and google login if (name === 'AppleAuthentication') { //do nothing @@ -278,7 +278,7 @@ function downloadFromBlobUrl(blobUrl, filename) { function detectDownloadByCreateAnchor() { const createEle = document.createElement; document.createElement = (el) => { - if (el !== "a") return createEle.call(document, el); + if (el !== 'a') return createEle.call(document, el); const anchorEle = createEle.call(document, el); // use addEventListener to avoid overriding the original click event. @@ -290,5 +290,5 @@ function detectDownloadByCreateAnchor() { }); return anchorEle; - } + }; } diff --git a/src-tauri/src/inject/style.js b/src-tauri/src/inject/style.js index a9ecd2d43..03730c3f7 100644 --- a/src-tauri/src/inject/style.js +++ b/src-tauri/src/inject/style.js @@ -1,4 +1,4 @@ -window.addEventListener('DOMContentLoaded', (_event) => { +window.addEventListener('DOMContentLoaded', _event => { const css = ` #page #footer-wrapper, .drawing-board .toolbar .toolbar-action, diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index c3cfd2d0c..2661614d8 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -9,9 +9,7 @@ "dangerousRemoteDomainIpcAccess": [ { "domain": "weread.qq.com", - "windows": [ - "pake" - ], + "windows": ["pake"], "enableTauriAPI": true } ] @@ -27,9 +25,7 @@ "all": true, "fs": { "all": true, - "scope": [ - "$DOWNLOAD/*" - ] + "scope": ["$DOWNLOAD/*"] } } }, diff --git a/src-tauri/tauri.linux.conf.json b/src-tauri/tauri.linux.conf.json index e0993fb26..d9db8eaa7 100644 --- a/src-tauri/tauri.linux.conf.json +++ b/src-tauri/tauri.linux.conf.json @@ -8,7 +8,9 @@ "copyright": "", "deb": { "depends": ["curl", "wget"], - "files": {"/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop"} + "files": { + "/usr/share/applications/com-tw93-weread.desktop": "assets/com-tw93-weread.desktop" + } }, "externalBin": [], "longDescription": "",