feat: add category order rules and read-only sent mail history
This commit is contained in:
1 parent
388805a8a6
commit
efa982a8a1
41 files changed
+1828
-28
No files matched your search
+10
-5
@@ -21,6 +21,8 @@ const { StorageStore } = require('../modules/storage/store.cjs');
|
||||
const { StorageService } = require('../modules/storage/service.cjs');
|
||||
const { NotificationStore } = require('../modules/notifications/store.cjs');
|
||||
const { NotificationService } = require('../modules/notifications/service.cjs');
|
||||
const { RuleStore } = require('../modules/order-rules/store.cjs');
|
||||
const { OrderRuleDispatcher } = require('../modules/order-rules/dispatcher.cjs');
|
||||
|
||||
async function closeServer(server){
|
||||
if(!server)return;
|
||||
@@ -51,7 +53,7 @@ async function main(options = {}) {
|
||||
if(errors.length)throw new AggregateError(errors,'关闭服务时部分资源清理失败。');
|
||||
})();
|
||||
let server,dashboard,store,workspace,bpmSessions,custodian;
|
||||
let mailStore,mail,scanStore,scanner,storageStore,storage,notificationStore,notifications,assistantStore,assistant,health;
|
||||
let mailStore,mail,scanStore,scanner,storageStore,storage,notificationStore,notifications,orderRules,orderDispatcher,assistantStore,assistant,health;
|
||||
try {
|
||||
const tokenPath = path.join(stateDir,'pairing.key');
|
||||
let token;
|
||||
@@ -69,9 +71,9 @@ async function main(options = {}) {
|
||||
workspace=new WorkspaceStore(path.join(stateDir,'workspace'));
|
||||
// Register conditional closures before constructing later resources; partial startup follows the same path.
|
||||
cleanup.push(()=>closeServer(server));
|
||||
cleanup.push(()=>health?.close(),()=>assistant?.stop(),()=>notifications?.stop(),()=>storage?.stop(),()=>scanner?.stop(),()=>mail?.stop(),()=>custodian?.stop(),()=>bpmSessions?.shutdown());
|
||||
cleanup.push(()=>health?.close(),()=>assistant?.stop(),()=>orderDispatcher?.stop(),()=>notifications?.stop(),()=>storage?.stop(),()=>scanner?.stop(),()=>mail?.stop(),()=>custodian?.stop(),()=>bpmSessions?.shutdown());
|
||||
cleanup.push(()=>closeServer(dashboard),()=>workspace.close());
|
||||
cleanup.push(()=>mailStore?.close(),()=>scanStore?.close(),()=>storageStore?.close(),()=>notificationStore?.close(),()=>assistantStore?.close());
|
||||
cleanup.push(()=>mailStore?.close(),()=>scanStore?.close(),()=>storageStore?.close(),()=>notificationStore?.close(),()=>orderRules?.close(),()=>assistantStore?.close());
|
||||
bpmSessions=new BpmSessionManager({stateDir:path.join(stateDir,'bpm-sessions')});
|
||||
custodian=new BpmCustodian({workspace,manager:bpmSessions});
|
||||
mailStore=new MailStore(path.join(stateDir,'mail'));mail=new MailService({store:mailStore});
|
||||
@@ -79,21 +81,24 @@ async function main(options = {}) {
|
||||
scanStore=new BpmScanStore(path.join(stateDir,'bpm-scan'));scanner=new BpmScanner({store:scanStore,workspace,manager:bpmSessions,settings:()=>store.settings()});
|
||||
storageStore=new StorageStore(path.join(stateDir,'storage'));storage=new StorageService({store:storageStore,jobs:store,outputDir});
|
||||
notificationStore=new NotificationStore(path.join(stateDir,'notifications'));notificationStore.recover();notifications=new NotificationService({store:notificationStore,mail,settings:()=>store.settings(),calendar:()=>workspace.meta('calendar').overrides});
|
||||
orderRules=new RuleStore(path.join(stateDir,'order-rules'),{schedule:()=>store.settings().schedule,calendar:()=>workspace.meta('calendar').overrides});
|
||||
orderDispatcher=new OrderRuleDispatcher({store:orderRules,mail,settings:()=>store.settings(),calendar:()=>workspace.meta('calendar').overrides});
|
||||
assistantStore=new AssistantStore(path.join(stateDir,'assistant'));assistantStore.recover();assistant=new AssistantService({store:assistantStore,runtime:new ZcodeRuntime({stateDir:path.join(stateDir,'assistant','runtime')}),dashboard:store,workspace,scanner,storage});
|
||||
health=new RuntimeHealth({stateDir,startedAt,instanceId:watchdog.instanceId,workspace,scanner,storage,mail});
|
||||
await bpmSessions.migrateAccounts(workspace.snapshot().connections);
|
||||
workspace.markSessionChecksPending();
|
||||
server=await startService({token,port,outputDir,scale:config.scale,installedExtension,extensionSourceDir:path.join(root,'extension'),store,storage,watchdog,renderSnapshot:options.renderSnapshot});
|
||||
dashboard=createDashboard({store,workspace,outputDir,bpmSessions,mail,scanner,storage,notifications,assistant,health,watchdog,trustedProxy:dashboardConfig.trustedProxy===true});
|
||||
dashboard=createDashboard({store,workspace,outputDir,bpmSessions,mail,scanner,storage,notifications,orderRules,assistant,health,watchdog,trustedProxy:dashboardConfig.trustedProxy===true});
|
||||
await new Promise((resolve,reject)=>{dashboard.once('error',reject);dashboard.listen(dashboardPort,dashboardHost,resolve);});store.recoverJobs();mailStore.recoverSends();custodian.start();mail.start();scanner.start();notifications.start();
|
||||
health.start();
|
||||
orderDispatcher.start();
|
||||
if(!options.quiet){
|
||||
console.log('订单通知中心已启动。\nWeb 工作台支持业务日历、异常待办与转交、BPM 连接管理。\n在 Chrome 订单页仍可点击扩展中的“导出当前订单”。');
|
||||
console.log(`首次使用:Chrome 扩展管理 → 开发者模式 → 加载已解压的扩展程序\n选择目录:${installedExtension}\n输出目录:${outputDir}\n本地服务:http://127.0.0.1:${port}`);
|
||||
console.log(`Web 看板:http://127.0.0.1:${dashboardPort}\n${store.users().length?'使用已创建的工作台账号登录。':'首次请在部署机创建管理员。'}`);
|
||||
if(dashboardHost==='0.0.0.0')for(const list of Object.values(os.networkInterfaces()))for(const address of list || [])if(address.family==='IPv4' && !address.internal)console.log(`局域网地址:http://${address.address}:${dashboardPort}`);
|
||||
}
|
||||
return {server,dashboard,workspace,bpmSessions,custodian,mail,scanner,storage,notifications,assistant,health,stop};
|
||||
return {server,dashboard,workspace,bpmSessions,custodian,mail,scanner,storage,notifications,orderRules,orderDispatcher,assistant,health,stop};
|
||||
}catch(error){try{await stop();}catch(cleanupError){error.cleanupError=cleanupError;}throw error;}
|
||||
}
|
||||
module.exports={main};
|
||||
Reference in new issue
Block a user