feat: 调整脚本功能
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import { chromium } from 'playwright';
|
||||
import { preparePage, safeDisconnectBrowser } from './common/tabs.js';
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.connectOverCDP('http://127.0.0.1:9222');
|
||||
const { page } = await preparePage(browser, {
|
||||
targetUrl: 'about:blank',
|
||||
});
|
||||
|
||||
// Example: navigate and click an element
|
||||
// await page.goto('https://example.com');
|
||||
// await page.click('text=Change Model');
|
||||
|
||||
console.log('Change model script executed');
|
||||
|
||||
await safeDisconnectBrowser(browser);
|
||||
process.exit(0);
|
||||
})();
|
||||
@@ -1,18 +0,0 @@
|
||||
import { chromium } from 'playwright';
|
||||
import { preparePage, safeDisconnectBrowser } from './common/tabs.js';
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.connectOverCDP('http://127.0.0.1:9222');
|
||||
const { page } = await preparePage(browser, {
|
||||
targetUrl: 'about:blank',
|
||||
});
|
||||
|
||||
// Example: fill a form and submit
|
||||
// await page.fill('input[name="username"]', 'test');
|
||||
// await page.click('button[type="submit"]');
|
||||
|
||||
console.log('Pause resume script executed');
|
||||
|
||||
await safeDisconnectBrowser(browser);
|
||||
process.exit(0);
|
||||
})();
|
||||
@@ -1,18 +0,0 @@
|
||||
import { chromium } from 'playwright';
|
||||
import { preparePage, safeDisconnectBrowser } from './common/tabs.js';
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.connectOverCDP('http://127.0.0.1:9222');
|
||||
const { page } = await preparePage(browser, {
|
||||
targetUrl: 'about:blank',
|
||||
});
|
||||
|
||||
// Example: wait for a specific element or timeout
|
||||
// await page.waitForSelector('[data-testid="status-paused"]');
|
||||
// await page.waitForTimeout(2000);
|
||||
|
||||
console.log('Pause script executed');
|
||||
|
||||
await safeDisconnectBrowser(browser);
|
||||
process.exit(0);
|
||||
})();
|
||||
@@ -1,34 +1,54 @@
|
||||
{
|
||||
"scripts": [
|
||||
{
|
||||
"id": "seed-change-model",
|
||||
"name": "change-model",
|
||||
"description": "",
|
||||
"filename": "change-model.mjs",
|
||||
"id": "script-dy-hot-spring-trace",
|
||||
"name": "抖音温泉房态追踪",
|
||||
"description": "抖音生活服务平台温泉房型房态自动化追踪脚本",
|
||||
"filename": "dy_hot_spring_trace.js",
|
||||
"enabled": true,
|
||||
"channel": "common",
|
||||
"createdAt": "2026-04-12T05:27:08.543Z",
|
||||
"updatedAt": "2026-04-12T05:27:08.543Z"
|
||||
"channel": "douyin",
|
||||
"createdAt": "2026-04-09T19:29:52.000Z",
|
||||
"updatedAt": "2026-04-09T19:29:52.000Z"
|
||||
},
|
||||
{
|
||||
"id": "seed-pause-resume",
|
||||
"name": "pause-resume",
|
||||
"description": "",
|
||||
"filename": "pause-resume.mjs",
|
||||
"id": "script-dy-hotel-trace",
|
||||
"name": "抖音酒店房态追踪",
|
||||
"description": "抖音生活服务平台酒店房型房态自动化追踪脚本",
|
||||
"filename": "dy_hotel_trace.js",
|
||||
"enabled": true,
|
||||
"channel": "common",
|
||||
"createdAt": "2026-04-12T05:27:08.544Z",
|
||||
"updatedAt": "2026-04-12T05:27:08.544Z"
|
||||
"channel": "douyin",
|
||||
"createdAt": "2026-04-09T19:29:52.000Z",
|
||||
"updatedAt": "2026-04-09T19:29:52.000Z"
|
||||
},
|
||||
{
|
||||
"id": "seed-pause",
|
||||
"name": "pause",
|
||||
"description": "",
|
||||
"filename": "pause.mjs",
|
||||
"id": "script-fg-trace",
|
||||
"name": "飞猪房态追踪",
|
||||
"description": "飞猪平台房型房态自动化追踪脚本",
|
||||
"filename": "fg_trace.js",
|
||||
"enabled": true,
|
||||
"channel": "common",
|
||||
"createdAt": "2026-04-12T05:27:08.544Z",
|
||||
"updatedAt": "2026-04-12T05:27:08.544Z"
|
||||
"channel": "fliggy",
|
||||
"createdAt": "2026-04-09T19:35:34.000Z",
|
||||
"updatedAt": "2026-04-09T19:35:34.000Z"
|
||||
},
|
||||
{
|
||||
"id": "script-mt-trace",
|
||||
"name": "美团房态追踪",
|
||||
"description": "美团平台房型房态自动化追踪脚本",
|
||||
"filename": "mt_trace.js",
|
||||
"enabled": true,
|
||||
"channel": "meituan",
|
||||
"createdAt": "2026-04-09T19:29:52.000Z",
|
||||
"updatedAt": "2026-04-09T19:29:52.000Z"
|
||||
},
|
||||
{
|
||||
"id": "script-open-all-channel",
|
||||
"name": "打开所有渠道",
|
||||
"description": "一键打开所有配置渠道页面的通用脚本",
|
||||
"filename": "open_all_channel.js",
|
||||
"enabled": true,
|
||||
"channel": "",
|
||||
"createdAt": "2026-04-09T19:29:52.000Z",
|
||||
"updatedAt": "2026-04-09T19:29:52.000Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { chromium } from 'playwright';
|
||||
import { preparePage, safeDisconnectBrowser } from './common/tabs.js';
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.connectOverCDP('http://127.0.0.1:9222');
|
||||
const { page } = await preparePage(browser, {
|
||||
targetUrl: 'about:blank',
|
||||
});
|
||||
|
||||
// Example: navigate and click an element
|
||||
// await page.goto('https://example.com');
|
||||
// await page.click('text=Change Model');
|
||||
|
||||
console.log('Change model script executed');
|
||||
|
||||
await safeDisconnectBrowser(browser);
|
||||
process.exit(0);
|
||||
})();
|
||||
@@ -1,18 +0,0 @@
|
||||
import { chromium } from 'playwright';
|
||||
import { preparePage, safeDisconnectBrowser } from './common/tabs.js';
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.connectOverCDP('http://127.0.0.1:9222');
|
||||
const { page } = await preparePage(browser, {
|
||||
targetUrl: 'about:blank',
|
||||
});
|
||||
|
||||
// Example: fill a form and submit
|
||||
// await page.fill('input[name="username"]', 'test');
|
||||
// await page.click('button[type="submit"]');
|
||||
|
||||
console.log('Pause resume script executed');
|
||||
|
||||
await safeDisconnectBrowser(browser);
|
||||
process.exit(0);
|
||||
})();
|
||||
@@ -1,18 +0,0 @@
|
||||
import { chromium } from 'playwright';
|
||||
import { preparePage, safeDisconnectBrowser } from './common/tabs.js';
|
||||
|
||||
(async () => {
|
||||
const browser = await chromium.connectOverCDP('http://127.0.0.1:9222');
|
||||
const { page } = await preparePage(browser, {
|
||||
targetUrl: 'about:blank',
|
||||
});
|
||||
|
||||
// Example: wait for a specific element or timeout
|
||||
// await page.waitForSelector('[data-testid="status-paused"]');
|
||||
// await page.waitForTimeout(2000);
|
||||
|
||||
console.log('Pause script executed');
|
||||
|
||||
await safeDisconnectBrowser(browser);
|
||||
process.exit(0);
|
||||
})();
|
||||
@@ -10,7 +10,6 @@ import type {
|
||||
} from '@lib/script-types';
|
||||
|
||||
const META_FILENAME = 'scripts.meta.json';
|
||||
const SEED_DIR = 'seed';
|
||||
|
||||
function getScriptsDir(): string {
|
||||
return app.isPackaged
|
||||
@@ -79,20 +78,16 @@ function seedScripts(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
const seedDir = path.join(scriptsDir, SEED_DIR);
|
||||
if (!fs.existsSync(seedDir)) {
|
||||
log.info('[script-store-service] Seed directory does not exist, skipping seed.');
|
||||
if (!fs.existsSync(scriptsDir)) {
|
||||
log.info('[script-store-service] Scripts directory does not exist, skipping seed.');
|
||||
return;
|
||||
}
|
||||
|
||||
const meta: ScriptsMeta = { scripts: [] };
|
||||
const seedFiles = fs.readdirSync(seedDir).filter((f) => f.endsWith('.mjs'));
|
||||
const scriptFiles = fs.readdirSync(scriptsDir).filter((f) => f.endsWith('.mjs'));
|
||||
|
||||
for (const file of seedFiles) {
|
||||
const seedPath = path.join(seedDir, file);
|
||||
const destPath = path.join(scriptsDir, file);
|
||||
for (const file of scriptFiles) {
|
||||
try {
|
||||
fs.copyFileSync(seedPath, destPath);
|
||||
const name = file.replace(/\.mjs$/, '');
|
||||
const now = new Date().toISOString();
|
||||
meta.scripts.push({
|
||||
@@ -106,7 +101,7 @@ function seedScripts(): void {
|
||||
updatedAt: now,
|
||||
});
|
||||
} catch (err) {
|
||||
log.warn('[script-store-service] Failed to copy seed file', file, err);
|
||||
log.warn('[script-store-service] Failed to seed script', file, err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user