Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwplvx
Aurora
提交
497f8f76
Aurora
项目概览
lwplvx
/
Aurora
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Aurora
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
497f8f76
编写于
10月 08, 2021
作者:
lwplvx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
初步测试
上级
28736b79
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
104 addition
and
19 deletion
+104
-19
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/Controllers/TranslateController.cs
...a.Core/Aurora.Core.Api/Controllers/TranslateController.cs
+19
-2
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/ModuleCoreApi.cs
...icroservices/Aurora.Core/Aurora.Core.Api/ModuleCoreApi.cs
+1
-0
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/Startup.cs
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/Startup.cs
+17
-8
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/TranslateRocketHub.cs
...ervices/Aurora.Core/Aurora.Core.Api/TranslateRocketHub.cs
+37
-0
Aurora.Microservices/Aurora.Core/Aurora.Core.Domain/Entities/Rocket.cs
...ervices/Aurora.Core/Aurora.Core.Domain/Entities/Rocket.cs
+2
-2
Aurora.Microservices/Aurora.Core/Aurora.Core.EntityFramework/ApplicationReadonlyDbContext.cs
...rora.Core.EntityFramework/ApplicationReadonlyDbContext.cs
+1
-0
Aurora.Microservices/Aurora.Core/Aurora.Core.IService/IRocketService.cs
...rvices/Aurora.Core/Aurora.Core.IService/IRocketService.cs
+1
-1
Aurora.Microservices/Aurora.Core/Aurora.Core.Service/RocketService.cs
...services/Aurora.Core/Aurora.Core.Service/RocketService.cs
+12
-1
Samples/chrome-plugins/translation-rocket/js/background.js
Samples/chrome-plugins/translation-rocket/js/background.js
+14
-5
未找到文件。
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/Controllers/TranslateController.cs
浏览文件 @
497f8f76
...
...
@@ -6,6 +6,7 @@ using Aurora.Core.IService;
using
Aurora.Core.IService.Dto
;
using
Aurora.Infrastructure.Response
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.SignalR
;
using
Microsoft.Extensions.Logging
;
namespace
Aurora.Core.Api.Controllers
...
...
@@ -16,12 +17,15 @@ namespace Aurora.Core.Api.Controllers
{
private
readonly
ILogger
<
TranslateController
>
_logger
;
private
readonly
IRocketService
_rocketService
;
private
readonly
IHubContext
<
TranslateRocketHub
>
_hubContext
;
public
TranslateController
(
ILogger
<
TranslateController
>
logger
,
IRocketService
rocketService
)
IRocketService
rocketService
,
IHubContext
<
TranslateRocketHub
>
hubContext
)
{
_logger
=
logger
;
_rocketService
=
rocketService
;
_hubContext
=
hubContext
;
}
[
HttpGet
]
...
...
@@ -42,8 +46,21 @@ namespace Aurora.Core.Api.Controllers
/// <returns></returns>
public
async
Task
<
ResponseModel
<
RocketDto
>>
Rocket
(
RocketDto
model
)
{
var
res
=
await
_rocketService
.
Add
(
model
);
var
res
=
await
_rocketService
.
Rocket
(
model
);
await
_hubContext
.
Clients
.
All
.
SendAsync
(
"rocketWord"
,
model
);
return
res
;
}
[
HttpGet
]
/// <summary>
/// biu word
/// </summary>
/// <returns></returns>
public
async
Task
<
ResponseModel
<
RocketDto
>>
Test
()
{
await
_hubContext
.
Clients
.
All
.
SendAsync
(
"rocketWord"
,
"model"
);
return
new
ResponseModel
<
RocketDto
>(
new
RocketDto
());
}
}
}
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/ModuleCoreApi.cs
浏览文件 @
497f8f76
...
...
@@ -28,6 +28,7 @@ namespace Aurora.Core.Api
option
.
UseMySQL
(
configuration
[
"ReadonlyConnectionStrings:MySql"
]));
services
.
AddTransient
<
ICategoryService
,
CategoryService
>();
services
.
AddTransient
<
IRocketService
,
RocketService
>();
return
services
;
}
...
...
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/Startup.cs
浏览文件 @
497f8f76
...
...
@@ -41,6 +41,7 @@ namespace Aurora.Core.Api
services
.
AddCommonService
();
services
.
AddModuleCoreApi
(
Configuration
);
services
.
AddSignalR
();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
...
...
@@ -65,15 +66,23 @@ namespace Aurora.Core.Api
endpoints
.
MapControllers
();
});
// register this service
ServiceEntity
serviceEntity
=
new
ServiceEntity
// ServiceEntity serviceEntity = new ServiceEntity
// {
// // IP = NetworkHelper.LocalIPAddress,
// Port = Convert.ToInt32(Configuration["Service:Port"]),
// ServiceName = Configuration["Service:Name"],
// ConsulIP = Configuration["Consul:IP"],
// ConsulPort = Convert.ToInt32(Configuration["Consul:Port"])
// };
// app.RegisterConsul(lifetime, serviceEntity);
app
.
UseEndpoints
(
endpoints
=>
{
// IP = NetworkHelper.LocalIPAddress,
Port
=
Convert
.
ToInt32
(
Configuration
[
"Service:Port"
]),
ServiceName
=
Configuration
[
"Service:Name"
],
ConsulIP
=
Configuration
[
"Consul:IP"
],
ConsulPort
=
Convert
.
ToInt32
(
Configuration
[
"Consul:Port"
])
};
app
.
RegisterConsul
(
lifetime
,
serviceEntity
);
endpoints
.
MapControllers
();
endpoints
.
MapHub
<
TranslateRocketHub
>(
"/hub/TranslateRocketHub"
);
});
}
}
}
Aurora.Microservices/Aurora.Core/Aurora.Core.Api/TranslateRocketHub.cs
0 → 100644
浏览文件 @
497f8f76
using
System
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.SignalR
;
using
Microsoft.Extensions.Logging
;
namespace
Aurora.Core.Api
{
public
class
TranslateRocketHub
:
Hub
{
private
readonly
ILogger
<
TranslateRocketHub
>
_logger
;
public
TranslateRocketHub
(
ILogger
<
TranslateRocketHub
>
logger
)
{
_logger
=
logger
;
}
/// <summary>
/// 客户端连接
/// </summary>
/// <returns></returns>
public
override
async
Task
OnConnectedAsync
()
{
await
Groups
.
AddToGroupAsync
(
Context
.
ConnectionId
,
"SignalR Users"
);
await
base
.
OnConnectedAsync
();
}
public
override
async
Task
OnDisconnectedAsync
(
Exception
exception
)
{
await
Groups
.
RemoveFromGroupAsync
(
Context
.
ConnectionId
,
"SignalR Users"
);
await
base
.
OnDisconnectedAsync
(
exception
);
}
public
async
Task
SendMessage
(
string
word
)
{
await
Clients
.
All
.
SendAsync
(
"rocketWord"
,
word
);
}
}
}
\ No newline at end of file
Aurora.Microservices/Aurora.Core/Aurora.Core.Domain/Entities/Rocket.cs
浏览文件 @
497f8f76
...
...
@@ -4,9 +4,9 @@ using System.Collections.Generic;
namespace
Aurora.Core.Domain.Entities
{
/// <summary>
/// 单词,我就用 Rocket
老
表示单词
/// 单词,我就用 Rocket 表示单词
/// </summary>
public
class
Rocket
:
TenantEntityBase
public
class
Rocket
Word
:
TenantEntityBase
{
public
int
CategoryId
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
...
...
Aurora.Microservices/Aurora.Core/Aurora.Core.EntityFramework/ApplicationReadonlyDbContext.cs
浏览文件 @
497f8f76
...
...
@@ -34,6 +34,7 @@ namespace Aurora.Core.EntityFramework
}
public
DbSet
<
Category
>
Categories
{
get
;
set
;
}
public
DbSet
<
RocketWord
>
RocketWords
{
get
;
set
;
}
public
DbSet
<
Subject
>
Subjects
{
get
;
set
;
}
public
DbSet
<
Exampaper
>
Exampapers
{
get
;
set
;
}
public
DbSet
<
Question
>
Question
{
get
;
set
;
}
...
...
Aurora.Microservices/Aurora.Core/Aurora.Core.IService/IRocketService.cs
浏览文件 @
497f8f76
Aurora.Microservices/Aurora.Core/Aurora.Core.Service/RocketService.cs
浏览文件 @
497f8f76
...
...
@@ -50,12 +50,23 @@ namespace Aurora.Core.Service
public
async
Task
<
ResponseModel
<
RocketDto
>>
Rocket
(
RocketDto
model
)
{
#
region
保存到数据库
var
entity
=
_mapper
.
Map
<
RocketWord
>(
model
);
_dbContext
.
Categorie
s
.
Add
(
entity
);
_dbContext
.
RocketWord
s
.
Add
(
entity
);
var
num
=
await
_dbContext
.
SaveChangesAsync
();
#
endregion
#
region
发送到移动端
// 按照用户发送
// 广播发送
#
endregion
var
dto
=
_mapper
.
Map
<
RocketDto
>(
entity
);
var
res
=
new
ResponseModel
<
RocketDto
>(
dto
);
...
...
Samples/chrome-plugins/translation-rocket/js/background.js
浏览文件 @
497f8f76
...
...
@@ -34,7 +34,6 @@ chrome.contextMenus.create({
title
:
'
发射选择的单词:%s
'
,
// %s表示选中的文字
contexts
:
[
'
selection
'
],
// 只有当选中文字时才会出现此右键菜单
onclick
:
function
(
params
)
{
chrome
.
browserAction
.
setBadgeText
({
text
:
'
new
'
})
chrome
.
browserAction
.
setBadgeBackgroundColor
({
color
:
[
255
,
0
,
0
,
255
]
})
...
...
@@ -43,9 +42,19 @@ chrome.contextMenus.create({
xhr
.
open
(
'
GET
'
,
// chrome.extension.getURL('/config_resources/config.json'),
'
http://www.luoboit.cn/api/blog/post/query?Page=1&Limit=10
'
,
// 'http://www.luoboit.cn/api/blog/post/query?Page=1&Limit=10',
'
http://localhost:8000/Translate/Test
'
,
true
,
)
// prepare form data
// let data = new FormData(form)
let
data
=
new
FormData
()
// set headers
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
// xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
// send request
// xhr.send(data)
//访问内部位于config_resources目录下的config.json文件
xhr
.
send
()
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录