优化配置文件
This commit is contained in:
@@ -88,7 +88,7 @@ export function buildChromiumLaunchOptions(
|
||||
return options
|
||||
}
|
||||
|
||||
export function resolveDefaultViewport(rawValue = process.env.TENCENT_BROWSER_VNC_RESOLUTION): ViewportSize {
|
||||
export function resolveDefaultViewport(rawValue?: unknown): ViewportSize {
|
||||
const fromVncResolution = parseViewportSpec(rawValue)
|
||||
if (fromVncResolution) {
|
||||
return fromVncResolution
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { runtimeConfig } from '../../config/runtime.js'
|
||||
import { resolveDefaultViewport } from './session-browser-config.js'
|
||||
|
||||
const CURRENT_DIR = path.dirname(fileURLToPath(import.meta.url))
|
||||
const PROJECT_ROOT = path.resolve(CURRENT_DIR, '../../..')
|
||||
|
||||
export const DATA_ROOT = path.resolve(PROJECT_ROOT, 'data/browser-sessions')
|
||||
export const BROWSER_SESSION_DATA_ROOT = path.join(runtimeConfig.data.root, 'browser-sessions')
|
||||
export const ACTIVITY_URL = 'https://df.qq.com/cp/a20240812cdk/index.html'
|
||||
export const CHROME_PATH = String(runtimeConfig.browser.chromePath || '').trim()
|
||||
export const REDEEM_SUCCESS_AUTO_CLOSE_MS = 3 * 60 * 1000
|
||||
export const DEFAULT_VIEWPORT = resolveDefaultViewport()
|
||||
export const DEFAULT_VIEWPORT = resolveDefaultViewport(runtimeConfig.browser.vncResolution)
|
||||
export const SESSION_DEBUG_ENABLED = Boolean(runtimeConfig.session.debug)
|
||||
|
||||
@@ -3,7 +3,7 @@ import fs from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
|
||||
import {
|
||||
DATA_ROOT,
|
||||
BROWSER_SESSION_DATA_ROOT,
|
||||
REDEEM_SUCCESS_AUTO_CLOSE_MS,
|
||||
} from './session-service-config.js'
|
||||
import { SessionServiceError } from './session-service-runtime.js'
|
||||
@@ -61,7 +61,7 @@ export async function registerTencentBrowserSession({
|
||||
page,
|
||||
}: RegisterSessionInput): Promise<TencentBrowserSession> {
|
||||
const sessionId = createSessionId()
|
||||
const sessionDir = path.join(DATA_ROOT, sessionId)
|
||||
const sessionDir = path.join(BROWSER_SESSION_DATA_ROOT, sessionId)
|
||||
await fs.mkdir(sessionDir, { recursive: true })
|
||||
|
||||
const now = new Date().toISOString()
|
||||
|
||||
Reference in New Issue
Block a user