style: 统一代码中单引号为双引号并补全格式

This commit is contained in:
xiaojunnuo
2026-08-02 21:31:30 +08:00
parent 0ddb1f69d2
commit 9d6f7ef0f2
21 changed files with 55 additions and 52 deletions
+1 -1
View File
@@ -50,7 +50,7 @@
"scripts": { "scripts": {
"before-build": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('tsconfig.tsbuildinfo',{force:true});\"", "before-build": "node -e \"const fs=require('fs');fs.rmSync('dist',{recursive:true,force:true});fs.rmSync('tsconfig.tsbuildinfo',{force:true});\"",
"build": "npm run before-build && tsc -p tsconfig.build.json --skipLibCheck", "build": "npm run before-build && tsc -p tsconfig.build.json --skipLibCheck",
"lint": "eslint \"src/**/*.ts\" \"types/**/*.ts\"", "lint": "eslint --fix \"src/**/*.ts\" \"types/**/*.ts\"",
"lint-types": "tsd --files \"types/index.test-d.ts\"", "lint-types": "tsd --files \"types/index.test-d.ts\"",
"prepublishOnly": "npm run build", "prepublishOnly": "npm run build",
"test": "mocha -t 60000 \"test/setup.js\" \"test/**/*.spec.js\"", "test": "mocha -t 60000 \"test/setup.js\" \"test/**/*.spec.js\"",
+1 -1
View File
@@ -17,7 +17,7 @@
"pub": "npm publish", "pub": "npm publish",
"compile": "tsc --skipLibCheck --watch", "compile": "tsc --skipLibCheck --watch",
"format": "prettier --write src", "format": "prettier --write src",
"lint": "eslint --fix" "lint": "eslint --fix --ext .ts src"
}, },
"dependencies": { "dependencies": {
"async-lock": "^1.4.1", "async-lock": "^1.4.1",
+6 -3
View File
@@ -11,9 +11,12 @@ export class LocalCache<V = any> {
cache: Map<string, { value: V; expiresAt: number }>; cache: Map<string, { value: V; expiresAt: number }>;
constructor(opts: { clearInterval?: number } = {}) { constructor(opts: { clearInterval?: number } = {}) {
this.cache = new Map(); this.cache = new Map();
const intervalId = setInterval(() => { const intervalId = setInterval(
this.clearExpires(); () => {
}, opts.clearInterval ?? 5 * 60 * 1000); this.clearExpires();
},
opts.clearInterval ?? 5 * 60 * 1000
);
intervalId.unref?.(); intervalId.unref?.();
} }
+2 -2
View File
@@ -1,4 +1,4 @@
export function isDev() { export function isDev() {
const nodeEnv = process.env.NODE_ENV || 'dev'; const nodeEnv = process.env.NODE_ENV || "dev";
return nodeEnv === 'development' || nodeEnv.includes('local') || nodeEnv.startsWith('dev'); return nodeEnv === "development" || nodeEnv.includes("local") || nodeEnv.startsWith("dev");
} }
+2 -2
View File
@@ -1,8 +1,8 @@
import fs from 'fs'; import fs from "fs";
function getFileRootDir(rootDir?: string) { function getFileRootDir(rootDir?: string) {
if (rootDir == null) { if (rootDir == null) {
const userHome = process.env.HOME || process.env.USERPROFILE; const userHome = process.env.HOME || process.env.USERPROFILE;
rootDir = userHome + '/.certd/storage/'; rootDir = userHome + "/.certd/storage/";
} }
if (!fs.existsSync(rootDir)) { if (!fs.existsSync(rootDir)) {
+1 -1
View File
@@ -1,2 +1,2 @@
import mitt from 'mitt'; import mitt from "mitt";
export const mitter = mitt(); export const mitter = mitt();
+1 -1
View File
@@ -18,7 +18,7 @@
"pub": "npm publish", "pub": "npm publish",
"compile": "tsc --skipLibCheck --watch", "compile": "tsc --skipLibCheck --watch",
"format": "prettier --write src", "format": "prettier --write src",
"lint": "eslint --fix" "lint": "eslint --fix --ext .ts src"
}, },
"dependencies": { "dependencies": {
"@certd/basic": "^1.42.6", "@certd/basic": "^1.42.6",
+1 -1
View File
@@ -15,7 +15,7 @@
"pub": "npm publish", "pub": "npm publish",
"compile": "npm run build", "compile": "npm run build",
"format": "prettier --write src", "format": "prettier --write src",
"lint": "eslint --fix" "lint": "eslint --fix --ext .ts src"
}, },
"dependencies": { "dependencies": {
"axios": "^1.9.0", "axios": "^1.9.0",
+1 -1
View File
@@ -18,7 +18,7 @@
"pub": "npm publish", "pub": "npm publish",
"compile": "npm run build", "compile": "npm run build",
"format": "prettier --write src", "format": "prettier --write src",
"lint": "eslint --fix" "lint": "eslint --fix --ext .ts src"
}, },
"dependencies": { "dependencies": {
"nanoid": "^5.0.7" "nanoid": "^5.0.7"
+1 -1
View File
@@ -1 +1 @@
export * from './lib/iframe.client.js'; export * from "./lib/iframe.client.js";
@@ -1,4 +1,4 @@
import { nanoid } from 'nanoid'; import { nanoid } from "nanoid";
export type IframeMessageData<T> = { export type IframeMessageData<T> = {
action: string; action: string;
@@ -32,7 +32,7 @@ export class IframeClient {
constructor(iframe?: HTMLIFrameElement, onError?: (e: any) => void) { constructor(iframe?: HTMLIFrameElement, onError?: (e: any) => void) {
this.iframe = iframe; this.iframe = iframe;
this.onError = onError; this.onError = onError;
window.addEventListener('message', async (event: MessageEvent<IframeMessageData<any>>) => { window.addEventListener("message", async (event: MessageEvent<IframeMessageData<any>>) => {
const data = event.data; const data = event.data;
if (data.action) { if (data.action) {
console.log(`收到消息[isSub:${this.isInFrame()}]`, data); console.log(`收到消息[isSub:${this.isInFrame()}]`, data);
@@ -40,20 +40,20 @@ export class IframeClient {
const handler = this.handlers[data.action]; const handler = this.handlers[data.action];
if (handler) { if (handler) {
const res = await handler(data); const res = await handler(data);
if (data.id && data.action !== 'reply') { if (data.id && data.action !== "reply") {
await this.send('reply', res, data.id); await this.send("reply", res, data.id);
} }
} else { } else {
throw new Error(`action:${data.action} 未注册处理器,可能版本过低`); throw new Error(`action:${data.action} 未注册处理器,可能版本过低`);
} }
} catch (e: any) { } catch (e: any) {
console.error(e); console.error(e);
await this.send('reply', {}, data.id, 500, e.message); await this.send("reply", {}, data.id, 500, e.message);
} }
} }
}); });
this.register('reply', async data => { this.register("reply", async data => {
const req = this.requestQueue[data.replyId!]; const req = this.requestQueue[data.replyId!];
if (req) { if (req) {
req.onReply(data); req.onReply(data);
@@ -106,12 +106,12 @@ export class IframeClient {
console.log(`send message[isSub:${this.isInFrame()}]:`, reqMessageData); console.log(`send message[isSub:${this.isInFrame()}]:`, reqMessageData);
if (!this.iframe) { if (!this.iframe) {
if (!window.parent) { if (!window.parent) {
reject('当前页面不在 iframe 中'); reject("当前页面不在 iframe 中");
} }
window.parent.postMessage(reqMessageData, '*'); window.parent.postMessage(reqMessageData, "*");
} else { } else {
//子页面 //子页面
this.iframe.contentWindow?.postMessage(reqMessageData, '*'); this.iframe.contentWindow?.postMessage(reqMessageData, "*");
} }
} catch (e) { } catch (e) {
console.error(e); console.error(e);
+1 -1
View File
@@ -13,7 +13,7 @@
"pub": "npm publish", "pub": "npm publish",
"compile": "npm run build", "compile": "npm run build",
"format": "prettier --write src", "format": "prettier --write src",
"lint": "eslint --fix" "lint": "eslint --fix --ext .ts src"
}, },
"author": "", "author": "",
"license": "Apache", "license": "Apache",
+6 -6
View File
@@ -1,11 +1,11 @@
import jdCloud from "./lib/core.js"; import jdCloud from './lib/core.js';
import jdService from './lib/service.js' import jdService from './lib/service.js';
import domainService from './repo/domainservice/v2/domainservice.js' import domainService from './repo/domainservice/v2/domainservice.js';
import cdnService from './repo/cdn/v1/cdn.js' import cdnService from './repo/cdn/v1/cdn.js';
import sslService from './repo/ssl/v1/ssl.js' import sslService from './repo/ssl/v1/ssl.js';
export const JDCloud = jdCloud; export const JDCloud = jdCloud;
export const JDService = jdService; export const JDService = jdService;
export const JDDomainService = domainService; export const JDDomainService = domainService;
export const JDCdnService = cdnService; export const JDCdnService = cdnService;
export const JDSslService = sslService; export const JDSslService = sslService;
+1 -1
View File
@@ -18,7 +18,7 @@
"pub": "npm publish", "pub": "npm publish",
"compile": "tsc --skipLibCheck --watch", "compile": "tsc --skipLibCheck --watch",
"format": "prettier --write src", "format": "prettier --write src",
"lint": "eslint --fix" "lint": "eslint --fix --ext .ts src"
}, },
"dependencies": { "dependencies": {
"@certd/basic": "^1.42.6", "@certd/basic": "^1.42.6",
+1 -1
View File
@@ -19,7 +19,7 @@
"pub": "npm publish", "pub": "npm publish",
"compile": "npm run build", "compile": "npm run build",
"format": "prettier --write src", "format": "prettier --write src",
"lint": "eslint --fix" "lint": "eslint --fix --ext .ts src"
}, },
"keywords": [], "keywords": [],
"author": "greper", "author": "greper",
@@ -1,11 +1,11 @@
import { Config, Configuration, Logger } from '@midwayjs/core'; import { Config, Configuration, Logger } from "@midwayjs/core";
import { Flyway } from './flyway.js'; import { Flyway } from "./flyway.js";
import type { ILogger } from '@midwayjs/logger'; import type { ILogger } from "@midwayjs/logger";
import { TypeORMDataSourceManager } from '@midwayjs/typeorm'; import { TypeORMDataSourceManager } from "@midwayjs/typeorm";
import type { IMidwayContainer } from '@midwayjs/core'; import type { IMidwayContainer } from "@midwayjs/core";
@Configuration({ @Configuration({
namespace: 'flyway', namespace: "flyway",
//importConfigs: [join(__dirname, './config')], //importConfigs: [join(__dirname, './config')],
}) })
export class FlywayConfiguration { export class FlywayConfiguration {
@@ -14,9 +14,9 @@ export class FlywayConfiguration {
@Logger() @Logger()
logger!: ILogger; logger!: ILogger;
async onReady(container: IMidwayContainer) { async onReady(container: IMidwayContainer) {
this.logger.info('flyway start:' + JSON.stringify(this.flyway)); this.logger.info("flyway start:" + JSON.stringify(this.flyway));
const dataSourceManager = await container.getAsync(TypeORMDataSourceManager); const dataSourceManager = await container.getAsync(TypeORMDataSourceManager);
const dataSourceName = this.flyway.dataSourceName || 'default'; const dataSourceName = this.flyway.dataSourceName || "default";
const connection = dataSourceManager.getDataSource(dataSourceName); const connection = dataSourceManager.getDataSource(dataSourceName);
await new Flyway({ ...this.flyway, logger: this.logger, connection }).run(); await new Flyway({ ...this.flyway, logger: this.logger, connection }).run();
} }
+6 -6
View File
@@ -1,23 +1,23 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm'; import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
@Entity('flyway_history') @Entity("flyway_history")
export class FlywayHistory { export class FlywayHistory {
@PrimaryGeneratedColumn() @PrimaryGeneratedColumn()
id?: number; id?: number;
@Column({ comment: '文件名', length: 100 }) @Column({ comment: "文件名", length: 100 })
name?: string; name?: string;
@Column({ comment: 'hash', length: 32 }) @Column({ comment: "hash", length: 32 })
hash?: string; hash?: string;
@Column({ @Column({
comment: '执行时间', comment: "执行时间",
}) })
timestamp?: Date; timestamp?: Date;
@Column({ @Column({
comment: '执行成功', comment: "执行成功",
default: true, default: true,
}) })
success?: boolean; success?: boolean;
+3 -3
View File
@@ -1,3 +1,3 @@
export { FlywayConfiguration as Configuration } from './configuration.js'; export { FlywayConfiguration as Configuration } from "./configuration.js";
export { Flyway, setFlywayLogger } from './flyway.js'; export { Flyway, setFlywayLogger } from "./flyway.js";
export { FlywayHistory } from './entity.js'; export { FlywayHistory } from "./entity.js";
+1 -1
View File
@@ -17,7 +17,7 @@
"pub": "npm publish", "pub": "npm publish",
"compile": "tsc --skipLibCheck --watch", "compile": "tsc --skipLibCheck --watch",
"format": "prettier --write src", "format": "prettier --write src",
"lint": "eslint --fix" "lint": "eslint --fix --ext .ts src"
}, },
"dependencies": { "dependencies": {
"@certd/plugin-lib": "^1.42.6" "@certd/plugin-lib": "^1.42.6"
+1 -1
View File
@@ -14,7 +14,7 @@
"pub": "npm publish", "pub": "npm publish",
"compile": "tsc --skipLibCheck --watch", "compile": "tsc --skipLibCheck --watch",
"format": "prettier --write src", "format": "prettier --write src",
"lint": "eslint --fix" "lint": "eslint --fix --ext .ts src"
}, },
"dependencies": { "dependencies": {
"@certd/acme-client": "^1.42.6", "@certd/acme-client": "^1.42.6",
+1 -1
View File
@@ -1,4 +1,4 @@
export * from "./common/index.js"; export * from "./common/index.js";
export * from "./lib/index.js"; export * from "./lib/index.js";
export * from "./service/index.js"; export * from "./service/index.js";
export * from "./cert/index.js"; export * from "./cert/index.js";