Commit 9e49e6da authored by hangjun83's avatar hangjun83

前端:更新文档

parent d68d2264
##
# 框架架构概览 # 框架架构概览
### - 描述 ### - 描述
...@@ -108,7 +107,7 @@ Repository => state、mutation、getter,具体的数据维护 ...@@ -108,7 +107,7 @@ Repository => state、mutation、getter,具体的数据维护
**Enums**: **Enums**:
这个是 lumen-api-starter 新增的部分,用来定义应用系统中常量的数据。 用来定义应用系统中常量的数据。
**Criteria**[l5-repository criteria](https://github.com/andersao/l5-repository#example-the-criteria) **Criteria**[l5-repository criteria](https://github.com/andersao/l5-repository#example-the-criteria)
...@@ -248,7 +247,7 @@ public function listPage(Request $request) ...@@ -248,7 +247,7 @@ public function listPage(Request $request)
* 使用规范:待补充 * 使用规范:待补充
## 框架依赖包[Packages] ## 框架依赖包 [Packages]
- [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) (可选,需要使用 Laravel 7 新增的 HttpClient 时安装) - [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) (可选,需要使用 Laravel 7 新增的 HttpClient 时安装)
- [jenssegers/mongodb](https://github.com/jenssegers/laravel-mongodb) (可选,需要使用记录日志到 MongoDB 时安装) - [jenssegers/mongodb](https://github.com/jenssegers/laravel-mongodb) (可选,需要使用记录日志到 MongoDB 时安装)
...@@ -266,10 +265,10 @@ public function listPage(Request $request) ...@@ -266,10 +265,10 @@ public function listPage(Request $request)
* [overtrue/laravel-query-logger](https://github.com/overtrue/laravel-query-logger) * [overtrue/laravel-query-logger](https://github.com/overtrue/laravel-query-logger)
* [BenSampo/laravel-enum](https://github.com/BenSampo/laravel-enum) * [BenSampo/laravel-enum](https://github.com/BenSampo/laravel-enum)
* [spatie/laravel-enum](https://github.com/spatie/laravel-enum) * [spatie/laravel-enum](https://github.com/spatie/laravel-enum)
*
- [是时候使用 Lumen 8 + API Resource 开发项目了!](https://learnku.com/articles/45311) * [是时候使用 Lumen 8 + API Resource 开发项目了!](https://learnku.com/articles/45311)
- [一篇 RESTful API 路由设计的最佳实践](https://learnku.com/articles/45526) * [一篇 RESTful API 路由设计的最佳实践](https://learnku.com/articles/45526)
- [教你更优雅地写 API 之「规范响应数据」](https://learnku.com/articles/52784) * [教你更优雅地写 API 之「规范响应数据」](https://learnku.com/articles/52784)
- [教你更优雅地写 API 之「枚举使用」](https://learnku.com/articles/53015) * [教你更优雅地写 API 之「枚举使用」](https://learnku.com/articles/53015)
- [教你更优雅地写 API 之「记录日志」](https://learnku.com/articles/53669) * [教你更优雅地写 API 之「记录日志」](https://learnku.com/articles/53669)
# 框架安装配置
### 前戏 MacOS
**nginx**
- nginx 使用brew安装包管理工具
```
brew install nginx
```
**php**
- php 8.0
```
brew install php@8.0
```
- composer
> [composer安装 传送门](https://www.jianshu.com/p/fd1b53df3f4b)
>
> [composer源配置 传送门](https://learnku.com/articles/15977/composer-accelerate-and-modify-mirror-source-in-china)
```
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
```
```
composer config repo.packagist composer https://packagist.phpcomposer.com
```
查看此页面的相关教程进行配置
[传送门](https://learnku.com/articles/15977/composer-accelerate-and-modify-mirror-source-in-china)
**node js**
> nodejs [安装传送门](https://www.jianshu.com/p/3b30c4c846d1)
>
> npm 包管理工具 [安装传送门](https://www.jianshu.com/p/704c90cae6ba)
### 服务器后端篇
#### - *初始化项目*
```console
git clone git@gitlab.chem-site.com:hangjun/framework.git
```
*进入framework/server目录并执行*
```sh
cd framework/server/ && composer update -vvv
```
安装更新composer.json定义的项目依赖包
> <strong>注意:</strong> 如果composer的更新速度较慢,可以对composer源进行更换。如果更换,请参考上面的连接
```sh
Dependency resolution completed in 0.001 seconds
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
Class App\Http\Resources\UserResource located in ./app/Http/Controllers/Resources/UserResource.php does not comply with psr-4 autoloading standard. Skipping.
Class App\Http\Resources\UserCollection located in ./app/Http/Controllers/Resources/UserCollection.php does not comply with psr-4 autoloading standard. Skipping.
73 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
```
>执行完成,出现以上信息,并没有出现错误提示时,说明composer update成功。
#### - *配置项目*
- 生成.env配置文件
```sh
# 生成.env配置文件
cp -rf .env.example .env
# 编辑.env配置文件
vim .env
# 编辑如下的.env配置项
# 不使用request最高严格验证,将值改为false
API_STRICT=true #改为[false]
# 数据库配置
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=rhawn-test
DB_USERNAME=root
DB_PASSWORD=123456
```
- 系统采用jwt的验证,初始化jwt:secret
```sh
php artisan jwt:secret
```
- 对数据库的数据表及相应的数据进行初始化
```sh
php artisan migrate && php artisan db:seed
```
### 前端篇
#### - *初始化项目*
```sh
npm i
```
- *配置项目*
```js
devServer: {
host: '127.0.0.1', //访问的ip地址或者域名
port: 9999, //访问的端口号
proxy: {
'/adminapi': { //拦截namespace开头的请求
target: 'http://127.0.0.1:8211', //更改为自己的访问地址
ws: true
},
}
},
```
> <strong>注意:</strong> 如果更改了namespace,则要更改对应的base
```js
// 打开lib/aixios.js
let base = '/adminapi'; //修改当前的namespace
```
### 启动运行篇
- 前端开启
```sh
npm run dev #以本地开发者模式进行运行。
########################################
App running at:
- Local: http://127.0.0.1:9999/
- Network: http://127.0.0.1:9999/
# 出现这里说明前端服务已经启动,可以用之上地址进行访问。
```
> <strong>注意:</strong> 如果需要打包进行正式环境的运行要执行:
```sh
npm build #运行结束会在dist文件生成html文件,将该dist文件夹打包上传至服务中。
```
- 服务器后端启动
*nginx配置*
```sh
server {
listen 80; #设置的访问端口号
server_name localhost; #设置的访问地址或域名
set $root_path framework/server/public/; #后端代码目录
root $root_path;
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000; #当前fpm的监听端口号
fastcgi_index /index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
```
> <strong>注意:</strong> 如果环境中有多个php版本,需要制定特定的版本执行当前服务。将监听端口号改成特定版本的php监听号即可。
```sh
nginx -t && nginx -s reload
```
This diff is collapsed.
This diff is collapsed.
<template> <template>
<div> <div>
<Tabs type="card"> <Card id="html2canvas">
<TabPane label="服务器端"> <Layout>
<div class="markdown-body"> <Sider hide-trigger style="background: #fff; max-width: 220px; flex: 0 0 220px">
<md /> <Menu active-name="1-1" theme="primary" width="auto" @on-select="currName = $event">
<MenuItem name="1-1">安装配置</MenuItem>
<MenuItem name="1-2">服务器端</MenuItem>
<MenuItem name="1-3">前端</MenuItem>
</Menu>
</Sider>
<Content :style="{
padding: '0 0 0 24px',
minHeight: '280px',
background: '#f0f0f0',
}">
<div v-show="currName == '1-2'" class="markdown-body">
<serverMd></serverMd>
</div> </div>
</TabPane> <div v-show="currName == '1-1'" class="markdown-body">
</Tabs> <settingMd></settingMd>
</div>
</Content>
</Layout>
</Card>
</div> </div>
</template> </template>
<script> <script>
// 组件内使用 // 组件内使用
import md from '@/assets/doc/server.md' import serverMd from '@/assets/doc/server.md'
import settingMd from '@/assets/doc/setting.md'
import 'highlight.js/styles/github.css' import 'highlight.js/styles/github.css'
import 'github-markdown-css' //import 'highlight.js/styles/monokai.css'
import './github-markdown-light.css'
export default { export default {
name: "framework", name: "serverDoc",
components: { components: {
md serverMd,
settingMd
}, },
data() { data() {
return { return {
content: md currName: "1-1",
}; };
}, },
methods: { methods: {
}, },
mounted() { mounted() {
this.maxHeight = Number(document.documentElement.clientHeight - 160) + "px"; this.maxHeight = Number(document.documentElement.clientHeight - 160) + "px";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment