# Angular 6 SPA 集成企业微信 Demo
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 6.0.3.
## 安装
首次运行需要执行一次 `npm install`
## 配置
修改 `auth.service.ts` 下的 `env` 配置信息
## 说明
虽说这个是支持企业微信,但做一定修改后是可以用在微信上的,换掉 WxauthComponent 请求code的跳转便可
### 路由
本Demo的路由主要有三个
```ts
const routes: Routes = [
{ path: '', component: IndexComponent, pathMatch: 'full' },
{ path: 'wxauth', component: WxauthComponent },
{ path: 'table', component: JbtableComponent, canActivate: [AuthGuard] }
];
```
其中,wxauth为企业微信callback的路由
一个可匿名访问的全局路由
和一个需要企业微信登录才可以访问的路由 table ,通过 AuthGuard 守卫 , 其他需要登录的页面只需要添加守卫在路由处即可
### 后端
这里的callback得到的 code 再换取 user_ticket 的动作是通过一个 Asp.net Core Web Api 完成的,获得 user_ticket 后写入 localStorage 备用。
后端的代码好简单,如果后端和前端不是同一个域名注意开启 Cors
```c#
[HttpGet]
[Route("api/Home/UserTicket/{code}")]
[EnableCors]
public GetUserInfoResult GetUserTicket(string code)
{
return OAuth2Api.GetUserId(_options.WorkAccessToken, code);
}
```
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
PS:由于企业微信应用开发的特殊性,不要用localhost进行测试,callback不了的
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
没有合适的资源?快使用搜索试试~ 我知道了~
Angular6SPA集成企业微信Demo
共118个文件
ts:63个
css:13个
html:13个
需积分: 36 7 下载量 51 浏览量
2019-08-10
15:53:17
上传
评论
收藏 208KB ZIP 举报
温馨提示
Angular 6 SPA 集成企业微信 Demo
资源推荐
资源详情
资源评论
收起资源包目录
Angular6SPA集成企业微信Demo (118个子文件)
browserslist 375B
styles.css 3KB
jb-nav.component.css 110B
jbtable.component.css 103B
timeline.component.css 94B
dispatch.component.css 59B
bus-event-list.component.css 50B
bus-map.component.css 32B
index.component.css 0B
wxauth.component.css 0B
add-event-item.component.css 0B
add-bus-event.component.css 0B
chat.component.css 0B
app.component.css 0B
.editorconfig 245B
.gitignore 503B
.gitkeep 0B
index.html 4KB
dispatch.component.html 2KB
jbtable.component.html 1KB
timeline.component.html 1KB
add-bus-event.component.html 1KB
bus-map.component.html 1KB
add-event-item.component.html 1KB
jb-nav.component.html 1KB
chat.component.html 492B
bus-event-list.component.html 476B
app.component.html 136B
wxauth.component.html 28B
index.component.html 24B
favicon.ico 5KB
ngsw-worker-polyfill.js 132KB
karma.conf.js 964B
protractor.conf.js 752B
package-lock.json 408KB
angular.json 4KB
tslint.json 3KB
package.json 2KB
manifest.json 1KB
ngsw-config.json 392B
tsconfig.json 384B
tslint.json 314B
tsconfig.spec.json 282B
tsconfig.e2e.json 213B
tsconfig.app.json 194B
README.md 2KB
icon-512x512.png 5KB
icon-384x384.png 3KB
bus_r.png 3KB
icon-192x192.png 2KB
icon-152x152.png 1KB
icon-144x144.png 1KB
icon-128x128.png 1KB
icon-96x96.png 958B
icon-72x72.png 792B
models.d.ts 4KB
uploader.service.ts 3KB
polyfills.ts 3KB
app.module.ts 3KB
bus-map.component.ts 3KB
wxauth.component.ts 2KB
add-event-item.component.ts 2KB
timeline.component.ts 2KB
add-bus-event.component.ts 2KB
auth.service.ts 2KB
bus-map.service.ts 2KB
jbtable.component.ts 2KB
app-routing.module.ts 2KB
dispatch.component.ts 2KB
rest-data-source.ts 2KB
signal-r.service.ts 2KB
chat.component.ts 1KB
bus-event.service.ts 1KB
app.component.spec.ts 989B
auth.guard.ts 854B
app.component.ts 809B
bus-info.service.ts 756B
add-event-item.component.spec.ts 672B
bus-event-list.component.spec.ts 672B
bus-event-list.component.ts 671B
add-bus-event.component.spec.ts 665B
test.ts 642B
timeline.component.spec.ts 642B
environment.ts 631B
bus-map.component.spec.ts 629B
wxauth.component.spec.ts 628B
dispatch.component.spec.ts 625B
index.component.spec.ts 621B
jbtable.component.spec.ts 618B
chat.component.spec.ts 614B
jb-nav.component.ts 607B
jb-nav.component.spec.ts 605B
index.component.ts 514B
main.ts 503B
preloader.ts 482B
dispatch.service.ts 405B
core.module.ts 394B
bus-event.service.spec.ts 387B
dispatch.service.spec.ts 386B
uploader.service.spec.ts 386B
共 118 条
- 1
- 2
资源评论
weixin_39841856
- 粉丝: 487
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功