Nextcloud Cospend 项目教程
cospend-nc💰 💲hared budget manager Nextcloud app项目地址:https://gitcode.com/gh_mirrors/co/cospend-nc
1. 项目的目录结构及介绍
Nextcloud Cospend 项目的目录结构如下:
cospend-nc/
├── appinfo/
│ ├── app.php
│ ├── info.xml
│ └── routes.php
├── css/
├── docs/
│ └── dev.md
├── js/
├── l10n/
├── lib/
├── templates/
├── tests/
└── webpack.config.js
appinfo/
: 包含应用程序的基本信息和路由配置。app.php
: 应用程序的入口文件。info.xml
: 应用程序的元数据信息。routes.php
: 定义应用程序的路由。
css/
: 存放样式文件。docs/
: 包含开发文档。dev.md
: 开发相关的文档。
js/
: 存放 JavaScript 文件。l10n/
: 存放本地化文件。lib/
: 存放库文件和业务逻辑代码。templates/
: 存放模板文件。tests/
: 存放测试文件。webpack.config.js
: Webpack 配置文件。
2. 项目的启动文件介绍
Nextcloud Cospend 项目的启动文件是 appinfo/app.php
。这个文件是应用程序的入口点,负责初始化应用程序并加载必要的组件和服务。
<?php
namespace OCA\Cospend\AppInfo;
use OCP\AppFramework\App;
use OCA\Cospend\Db\BillMapper;
use OCA\Cospend\Db\ProjectMapper;
use OCA\Cospend\Db\CategoryMapper;
use OCA\Cospend\Db\MemberMapper;
use OCA\Cospend\Service\ProjectService;
use OCA\Cospend\Service\BillService;
use OCA\Cospend\Service\MemberService;
use OCA\Cospend\Service\CategoryService;
class Application extends App {
public function __construct(array $urlParams = []) {
parent::__construct('cospend', $urlParams);
$container = $this->getContainer();
$container->registerService('BillMapper', function($c) {
return new BillMapper($c->query('CoreServiceContainer')->getDatabaseConnection());
});
$container->registerService('ProjectMapper', function($c) {
return new ProjectMapper($c->query('CoreServiceContainer')->getDatabaseConnection());
});
$container->registerService('CategoryMapper', function($c) {
return new CategoryMapper($c->query('CoreServiceContainer')->getDatabaseConnection());
});
$container->registerService('MemberMapper', function($c) {
return new MemberMapper($c->query('CoreServiceContainer')->getDatabaseConnection());
});
$container->registerService('ProjectService', function($c) {
return new ProjectService(
$c->query('ProjectMapper'),
$c->query('MemberMapper'),
$c->query('CategoryMapper'),
$c->query('BillMapper')
);
});
$container->registerService('BillService', function($c) {
return new BillService(
$c->query('BillMapper'),
$c->query('ProjectMapper'),
$c->query('MemberMapper'),
$c->query('CategoryMapper')
);
});
$container->registerService('MemberService', function($c) {
return new MemberService(
$c->query('MemberMapper'),
$c->query('ProjectMapper')
);
});
$container->registerService('CategoryService', function($c) {
return new CategoryService(
$c->query('CategoryMapper'),
$c->query('ProjectMapper')
);
});
}
}
3. 项目的配置文件介绍
Nextcloud Cospend 项目的配置文件主要位于 appinfo/
目录下。以下是一些关键的配置文件:
appinfo/app.php
: 应用程序的入口文件,负责初始化应用程序并加载必要的组件和服务。appinfo/info.xml
: 应用程序的元数据信息,包括应用程序的名称、版本、依赖等。- `appinfo/routes.php
cospend-nc💰 💲hared budget manager Nextcloud app项目地址:https://gitcode.com/gh_mirrors/co/cospend-nc