From 4bbfa0cc2d8f387d14ccbc8df96a2f2cf4b7956b Mon Sep 17 00:00:00 2001 From: tikkhun Date: Tue, 2 Dec 2025 22:29:08 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0.gitignore=E5=B9=B6?= =?UTF-8?q?=E6=B8=85=E7=90=86=E8=84=9A=E6=9C=AC=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除不再使用的脚本文件test_db_count.ts和replace_punctuation.js 更新config.local.ts中的数据库配置和wpSite配置 --- .gitignore | 4 ++ replace_punctuation.js | 83 -------------------------------------- src/config/config.local.ts | 46 ++++++++++++--------- test_db_count.ts | 35 ---------------- 4 files changed, 30 insertions(+), 138 deletions(-) delete mode 100644 replace_punctuation.js delete mode 100644 test_db_count.ts diff --git a/.gitignore b/.gitignore index d3b97ca..49015ee 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ yarn.lock **/config.local.ts container ai/products-20251202 (1).csv +scripts/replace_punctuation.js +scripts/test_db_count.d.ts +scripts/test_db_count.js +scripts/test_db_count.ts diff --git a/replace_punctuation.js b/replace_punctuation.js deleted file mode 100644 index 5149513..0000000 --- a/replace_punctuation.js +++ /dev/null @@ -1,83 +0,0 @@ -const fs = require('fs'); -const path = require('path'); - -const map = { - ',': ',', - '.': '.', - ':': ':', - '?': '?', - '!': '!', - '"': '"', - '"': '"', - ''': "'", - ''': "'", - '(': '(', - ')': ')', - '[': '[', - ']': ']', - ',': ',', - ';': ';' -}; - -function getAllFiles(dirPath, arrayOfFiles) { - const files = fs.readdirSync(dirPath); - - arrayOfFiles = arrayOfFiles || []; - - files.forEach(function(file) { - if (fs.statSync(dirPath + "/" + file).isDirectory()) { - arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles); - } else { - if (extensions.some(ext => file.endsWith(ext))) { - arrayOfFiles.push(path.join(dirPath, "/", file)); - } - } - }); - - return arrayOfFiles; -} - -const srcDirAPI = path.join(__dirname); -const srcDirWEB = path.join(__dirname, '../WEB'); - -const targetDirs = [srcDirAPI, srcDirWEB]; - -const extensions = ['.ts', '.js', '.tsx', '.jsx', '.vue', '.html', '.css', '.scss', '.less', '.json', '.md']; - -let count = 0; - -targetDirs.forEach(dir => { - if (fs.existsSync(dir)) { - const files = getAllFiles(dir); - files.forEach(file => { - // Skip node_modules, .git, dist, build, .idea, .vscode - if (file.includes('/node_modules/') || - file.includes('/.git/') || - file.includes('/dist/') || - file.includes('/build/') || - file.includes('/.idea/') || - file.includes('/.vscode/') || - file.includes('/coverage/')) { - return; - } - - let content = fs.readFileSync(file, 'utf8'); - let originalContent = content; - - for (const [cn, en] of Object.entries(map)) { - const regex = new RegExp(cn, 'g'); - content = content.replace(regex, en); - } - - if (content !== originalContent) { - fs.writeFileSync(file, content, 'utf8'); - console.log(`Updated: ${file}`); - count++; - } - }); - } else { - console.warn(`Directory not found: ${dir}`); - } -}); - -console.log(`Total files updated: ${count}`); diff --git a/src/config/config.local.ts b/src/config/config.local.ts index a05235b..e839182 100644 --- a/src/config/config.local.ts +++ b/src/config/config.local.ts @@ -16,8 +16,10 @@ export default { dataSource: { default: { host: 'localhost', + port: "23306", username: 'root', password: '12345678', + database: 'inventory', }, }, }, @@ -25,7 +27,7 @@ export default { origin: '*', // 允许所有来源跨域请求 allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], // 允许的 HTTP 方法 allowHeaders: ['Content-Type', 'Authorization'], // 允许的自定义请求头 - credentials: true, // 允许携带凭据(cookies等) + credentials: true, // 允许携带凭据(cookies等) }, jwt: { secret: 'YOONE2024!@abc', @@ -33,30 +35,34 @@ export default { }, wpSite: [ { - id: '-1', - siteName: 'Admin', - email: '2469687281@qq.com', - }, - { - id: '2', - wpApiUrl: 'http://t2-shop.local/', - consumerKey: 'ck_a369473a6451dbaec63d19cbfd74a074b2c5f742', - consumerSecret: 'cs_0946bbbeea1bfefff08a69e817ac62a48412df8c', - siteName: 'Local', - email: '2469687281@qq.com', - emailPswd: 'lulin91.', - }, - { - id: '3', - wpApiUrl: 'http://t1-shop.local/', - consumerKey: 'ck_a369473a6451dbaec63d19cbfd74a074b2c5f742', - consumerSecret: 'cs_0946bbbeea1bfefff08a69e817ac62a48412df8c', - siteName: 'Local-test-2', + id: '200', + wpApiUrl: "http://simple.local", + consumerKey: 'ck_11b446d0dfd221853830b782049cf9a17553f886', + consumerSecret: 'cs_2b06729269f659dcef675b8cdff542bf3c1da7e8', + siteName: 'LocalSimple', email: '2469687281@qq.com', emailPswd: 'lulin91.', }, // { // id: '2', + // wpApiUrl: 'http://t2-shop.local/', + // consumerKey: 'ck_a369473a6451dbaec63d19cbfd74a074b2c5f742', + // consumerSecret: 'cs_0946bbbeea1bfefff08a69e817ac62a48412df8c', + // siteName: 'Local', + // email: '2469687281@qq.com', + // emailPswd: 'lulin91.', + // }, + // { + // id: '3', + // wpApiUrl: 'http://t1-shop.local/', + // consumerKey: 'ck_a369473a6451dbaec63d19cbfd74a074b2c5f742', + // consumerSecret: 'cs_0946bbbeea1bfefff08a69e817ac62a48412df8c', + // siteName: 'Local-test-2', + // email: '2469687281@qq.com', + // emailPswd: 'lulin91.', + // }, + // { + // id: '2', // wpApiUrl: 'http://localhost:10004', // consumerKey: 'ck_dc9e151e9048c8ed3e27f35ac79d2bf7d6840652', // consumerSecret: 'cs_d05d625d7b0ac05c6d765671d8417f41d9477e38', diff --git a/test_db_count.ts b/test_db_count.ts deleted file mode 100644 index 25ec183..0000000 --- a/test_db_count.ts +++ /dev/null @@ -1,35 +0,0 @@ - -import { App, IMidwayApplication, Inject } from '@midwayjs/core'; -import { Framework } from '@midwayjs/koa'; -import { Bootstrap } from '@midwayjs/bootstrap'; -import { Product } from './src/entity/product.entity'; -import { WpProduct } from './src/entity/wp_product.entity'; -import { Repository } from 'typeorm'; -import { InjectEntityModel } from '@midwayjs/typeorm'; - -@App() -class TestApp { - @InjectEntityModel(Product) - productModel: Repository; - - @InjectEntityModel(WpProduct) - wpProductModel: Repository; - - async run() { - if (!this.productModel || !this.wpProductModel) { - console.log('Models not injected'); - return; - } - const productCount = await this.productModel.count(); - const wpProductCount = await this.wpProductModel.count(); - console.log(`Product Count: ${productCount}`); - console.log(`WpProduct Count: ${wpProductCount}`); - } -} - -Bootstrap.run().then(async () => { - const app = await Bootstrap.getApplication() as IMidwayApplication; - const testApp = await app.getApplicationContext().getAsync(TestApp); - await testApp.run(); - process.exit(0); -});