This commit is contained in:
COOL 2025-01-22 19:50:45 +08:00
parent afb82751f1
commit 80cc0ecf6a
8 changed files with 54 additions and 54 deletions

View File

@ -31,6 +31,7 @@
"sharp": "0.33.5",
"sqlite3": "^5.1.7",
"svg-captcha": "^1.4.0",
"tslib": "^2.8.1",
"typeorm": "file:/Users/ap/Documents/src/admin/midway-packages/typeorm",
"uuid": "^11.0.5",
"ws": "^8.18.0"
@ -75,10 +76,11 @@
"assets": [
"public/**/*",
"typings/**/*",
"cool/**/*"
"node_modules/sqlite3/**/*"
],
"targets": [
"node18-macos-x64"
"node18-macos-x64",
"node18-win-x64"
],
"outputPath": "build"
},

73
pnpm-lock.yaml generated
View File

@ -89,6 +89,9 @@ importers:
svg-captcha:
specifier: ^1.4.0
version: 1.4.0
tslib:
specifier: ^2.8.1
version: 2.8.1
typeorm:
specifier: file:/Users/ap/Documents/src/admin/midway-packages/typeorm
version: file:../midway-packages/typeorm(ioredis@5.4.2)(mysql2@3.12.0)(sqlite3@5.1.7)
@ -628,10 +631,6 @@ packages:
resolution: {integrity: sha512-dbEidbEMwbgCGYjbQt+EyFhqRXgOfkj80JrbCSPki33EhAxCcNjg8popJCe25iVKMU4JlKQrLm7mcJyk3R4z2g==}
engines: {node: '>=12'}
'@midwayjs/cache@3.14.0':
resolution: {integrity: sha512-WUDOanpD+vpNnWZ4q91FvlHpNCRSNHKtgVlTZNVmL9VhNt/weqB8VZhDGbGzzg6NM2k9rfwD3TevoolAee4fZw==}
engines: {node: '>=12'}
'@midwayjs/cookies@1.2.0':
resolution: {integrity: sha512-gdfAXk3+uL+9qcNo9lNnUFJCUGXXxCitBjyz9QJR08dcZ11mqTbxVNXhea525e3ZwKREy6f4PHAWofFwlPOZzQ==}
engines: {node: '>=10'}
@ -1157,9 +1156,6 @@ packages:
async@2.6.4:
resolution: {integrity: sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==}
async@3.2.3:
resolution: {integrity: sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==}
async@3.2.6:
resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==}
@ -1287,8 +1283,8 @@ packages:
buffer@6.0.3:
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
bullmq@5.34.10:
resolution: {integrity: sha512-ia6EzpQm1ZPq6GUBSLyfvzJrhdBTd1f3Gn2g9pFtLX4hBOob6QHmcmBzGgPlSCyr/i2Qfe4OdjS21bRd02srbw==}
bullmq@5.35.0:
resolution: {integrity: sha512-4wOFPv5oVkcK5A11cwsk5Zzc7Hz7xFe2rHIQfsg0UmWjtwTj/nc7+vPjcMGML6jdl7WejuHXnMeop4uxxo/3WA==}
bytes@3.1.2:
resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==}
@ -1302,9 +1298,6 @@ packages:
resolution: {integrity: sha512-IKufZ1o4Ut42YUrZSo8+qnMTrFuKkvyoLXUywKz9GJ5BrhOFGhLdkx9sG4KAnVvbY6kEcSFjLQul+DVmBm2bgA==}
engines: {node: '>= 6.0.0'}
cache-manager@3.6.3:
resolution: {integrity: sha512-dS4DnV6c6cQcVH5OxzIU1XZaACXwvVIiUPkFytnRmLOACuBGv3GQgRQ1RJGRRw4/9DF14ZK2RFlZu1TUgDniMg==}
cacheable-request@2.1.4:
resolution: {integrity: sha512-vag0O2LKZ/najSoUwDbVlnlCFvhBE/7mGTY2B5FgCBDcRD+oVV1HYTOwM6JZfMg/hIcM6IwnTZ1uQQL5/X3xIQ==}
@ -1495,8 +1488,8 @@ packages:
resolution: {integrity: sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==}
engines: {node: '>=14'}
commander@13.0.0:
resolution: {integrity: sha512-oPYleIY8wmTVzkvQq10AEok6YcTC4sRUBl8F9gVuwchGVUCTbl/vhLTaQqutuuySYOsu8YTgV+OxKc/8Yvx+mQ==}
commander@13.1.0:
resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==}
engines: {node: '>=18'}
commander@2.15.1:
@ -1782,8 +1775,8 @@ packages:
engines: {node: '>=0.10.0'}
hasBin: true
electron-to-chromium@1.5.83:
resolution: {integrity: sha512-LcUDPqSt+V0QmI47XLzZrz5OqILSMGsPFkDYus22rIbgorSvBYEFqq854ltTmUdHkY92FSdAAvsh4jWEULMdfQ==}
electron-to-chromium@1.5.84:
resolution: {integrity: sha512-I+DQ8xgafao9Ha6y0qjHHvpZ9OfyA1qKlkHkjywxzniORU2awxyz7f/iVJcULmrF2yrM3nHQf+iDjJtbbexd/g==}
emittery@0.13.1:
resolution: {integrity: sha512-DeWwawk6r5yR9jFgnDKYt4sLS0LmHJJi3ZOnb5/JdbYwj3nW+FxQnHIjhBKz8YLC7oRNPVM9NQ47I3CVx34eqQ==}
@ -2020,8 +2013,8 @@ packages:
fast-safe-stringify@2.1.1:
resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==}
fast-uri@3.0.5:
resolution: {integrity: sha512-5JnBCWpFlMo0a3ciDy/JckMzzv1U9coZrIhedq+HXxxUfDTAiS0LA8OKVao4G9BxmCVck/jtA5r3KAtRWEyD8Q==}
fast-uri@3.0.6:
resolution: {integrity: sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==}
fastest-validator@1.19.0:
resolution: {integrity: sha512-wUfJBrXmccVz4kARAiWTkuqsC6EFeqbNxwfysCDk+maExBPP8KxyBwaWtayrWjKIaBIbaz+rqI2kel6ecayxcg==}
@ -3322,6 +3315,9 @@ packages:
napi-build-utils@1.0.2:
resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==}
napi-build-utils@2.0.0:
resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==}
natural-compare-lite@1.4.0:
resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==}
@ -3686,8 +3682,8 @@ packages:
engines: {node: '>=10'}
hasBin: true
prebuild-install@7.1.2:
resolution: {integrity: sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==}
prebuild-install@7.1.3:
resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==}
engines: {node: '>=10'}
hasBin: true
@ -4943,10 +4939,9 @@ snapshots:
'@cool-midway/core@file:../midway-packages/core(debug@4.4.0)':
dependencies:
'@cool-midway/cache-manager-fs-hash': 7.0.0
'@midwayjs/cache': 3.14.0
'@midwayjs/cache-manager': 3.20.0
axios: 1.7.9(debug@4.4.0)
commander: 13.0.0
commander: 13.1.0
download: 8.0.0
glob: 11.0.1
javascript-obfuscator: 4.1.1
@ -4995,7 +4990,7 @@ snapshots:
'@cool-midway/task@file:../midway-packages/task':
dependencies:
bullmq: 5.34.10
bullmq: 5.35.0
ioredis: 5.4.2
transitivePeerDependencies:
- supports-color
@ -5361,10 +5356,6 @@ snapshots:
lodash.clonedeep: 4.5.0
lru-cache: 7.18.3
'@midwayjs/cache@3.14.0':
dependencies:
cache-manager: 3.6.3
'@midwayjs/cookies@1.2.0':
dependencies:
scmp: 2.1.0
@ -5883,7 +5874,7 @@ snapshots:
ajv@8.17.1:
dependencies:
fast-deep-equal: 3.1.3
fast-uri: 3.0.5
fast-uri: 3.0.6
json-schema-traverse: 1.0.0
require-from-string: 2.0.2
@ -5981,8 +5972,6 @@ snapshots:
dependencies:
lodash: 4.17.21
async@3.2.3: {}
async@3.2.6: {}
asynckit@0.4.0: {}
@ -6112,7 +6101,7 @@ snapshots:
browserslist@4.24.4:
dependencies:
caniuse-lite: 1.0.30001695
electron-to-chromium: 1.5.83
electron-to-chromium: 1.5.84
node-releases: 2.0.19
update-browserslist-db: 1.1.2(browserslist@4.24.4)
@ -6149,7 +6138,7 @@ snapshots:
base64-js: 1.5.1
ieee754: 1.2.1
bullmq@5.34.10:
bullmq@5.35.0:
dependencies:
cron-parser: 4.9.0
ioredis: 5.4.2
@ -6192,12 +6181,6 @@ snapshots:
mime-types: 2.1.35
ylru: 1.4.0
cache-manager@3.6.3:
dependencies:
async: 3.2.3
lodash.clonedeep: 4.5.0
lru-cache: 6.0.0
cacheable-request@2.1.4:
dependencies:
clone-response: 1.0.2
@ -6404,7 +6387,7 @@ snapshots:
commander@10.0.0: {}
commander@13.0.0: {}
commander@13.1.0: {}
commander@2.15.1: {}
@ -6674,7 +6657,7 @@ snapshots:
dependencies:
jake: 10.9.2
electron-to-chromium@1.5.83: {}
electron-to-chromium@1.5.84: {}
emittery@0.13.1: {}
@ -6930,7 +6913,7 @@ snapshots:
fast-safe-stringify@2.1.1: {}
fast-uri@3.0.5: {}
fast-uri@3.0.6: {}
fastest-validator@1.19.0: {}
@ -8476,6 +8459,8 @@ snapshots:
napi-build-utils@1.0.2: {}
napi-build-utils@2.0.0: {}
natural-compare-lite@1.4.0: {}
natural-compare@1.4.0: {}
@ -8906,14 +8891,14 @@ snapshots:
tar-fs: 2.1.2
tunnel-agent: 0.6.0
prebuild-install@7.1.2:
prebuild-install@7.1.3:
dependencies:
detect-libc: 2.0.3
expand-template: 2.0.3
github-from-package: 0.0.0
minimist: 1.2.8
mkdirp-classic: 0.5.3
napi-build-utils: 1.0.2
napi-build-utils: 2.0.0
node-abi: 3.73.0
pump: 3.0.2
rc: 1.2.8
@ -9383,7 +9368,7 @@ snapshots:
dependencies:
bindings: 1.5.0
node-addon-api: 7.1.1
prebuild-install: 7.1.2
prebuild-install: 7.1.3
tar: 6.2.1
optionalDependencies:
node-gyp: 8.4.1

View File

@ -56,3 +56,11 @@ export const pPluginPath = () => {
export const pSqlitePath = () => {
return path.join(pDataPath(), 'cool.sqlite');
};
/**
*
* @returns
*/
export const pCachePath = () => {
return path.join(pDataPath(), 'cache');
};

View File

@ -2,7 +2,7 @@ import { CoolConfig } from '@cool-midway/core';
import { MidwayConfig } from '@midwayjs/core';
import { CoolCacheStore } from '@cool-midway/core';
import * as path from 'path';
import { pUploadPath } from '../comm/path';
import { pCachePath, pUploadPath } from '../comm/path';
// redis缓存
// import { redisStore } from 'cache-manager-ioredis-yet';
@ -42,7 +42,7 @@ export default {
default: {
store: CoolCacheStore,
options: {
path: 'cache',
path: pCachePath(),
ttl: 0,
},
},
@ -68,14 +68,14 @@ export default {
// 是否开启多租户
tenant: {
// 是否开启多租户
enable: true,
enable: false,
// 需要过滤多租户的url, 支持通配符, 如/admin/**/* 表示admin模块下的所有接口都进行多租户过滤
urls: [],
},
// 国际化配置
i18n: {
// 是否开启
enable: true,
enable: false,
// 语言
languages: ['zh-cn', 'zh-tw', 'en'],
},

View File

@ -19,7 +19,8 @@ export default {
// 打印日志
logging: true,
// 实体路径
entities,
entities: ['**/modules/*/entity'],
// 订阅者
subscribers: [TenantSubscriber],
},
// default: {

View File

@ -2,6 +2,7 @@ import { CoolConfig } from '@cool-midway/core';
import { MidwayConfig } from '@midwayjs/core';
import { entities } from '../entities';
import { pSqlitePath } from '../comm/path';
import { TenantSubscriber } from '../modules/base/db/tenant';
/**
* npm run prod
*/
@ -13,11 +14,13 @@ export default {
// 数据库文件地址
database: pSqlitePath(),
// 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失
synchronize: false,
synchronize: true,
// 打印日志
logging: false,
logging: true,
// 实体路径
entities,
// 订阅者
subscribers: [TenantSubscriber],
},
},
},

View File

@ -94,7 +94,7 @@ export class TenantSubscriber implements EntitySubscriberInterface<any> {
getTenantId(): number | undefined {
let ctx, url, tenantId;
ctx = this.getCtx();
if (!ctx || this.checkHandler()) return undefined;
if (!ctx || !this.checkHandler()) return undefined;
url = ctx?.url;
if (_.startsWith(url, '/admin/')) {

View File

@ -56,6 +56,7 @@ export class DictInfoService extends BaseService {
const value = e.value ? Number(e.value) : e.value;
return {
...e,
// @ts-ignore
value: isNaN(value) ? e.value : value,
};
});