mirror of
https://github.com/lzh-1625/go_process_manager.git
synced 2025-09-26 20:11:20 +08:00
Compare commits
3 Commits
f723c12d42
...
c22384fbc0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c22384fbc0 | ||
![]() |
d42b89cc8b | ||
![]() |
c32db8c8f6 |
@@ -27,7 +27,6 @@ func (u *userApi) LoginHandler(ctx *gin.Context, req model.LoginHandlerReq) any
|
||||
return err
|
||||
}
|
||||
return gin.H{
|
||||
"code": 0,
|
||||
"token": token,
|
||||
"username": req.Account,
|
||||
"role": repository.UserRepository.GetUserByName(req.Account).Role,
|
||||
|
@@ -7,25 +7,28 @@ import (
|
||||
"github.com/lzh-1625/go_process_manager/internal/app/model"
|
||||
"github.com/lzh-1625/go_process_manager/internal/app/repository"
|
||||
"github.com/lzh-1625/go_process_manager/log"
|
||||
"github.com/lzh-1625/go_process_manager/utils"
|
||||
)
|
||||
|
||||
type eventLogic struct{}
|
||||
|
||||
var EventLogic = new(eventLogic)
|
||||
|
||||
func (e *eventLogic) Create(name string, eventType eum.EventType, additionalKv ...any) {
|
||||
func (e *eventLogic) Create(name string, eventType eum.EventType, additionalKv ...string) {
|
||||
if len(additionalKv)%2 != 0 {
|
||||
log.Logger.Errorw("参数长度错误", "args", additionalKv)
|
||||
return
|
||||
}
|
||||
data := model.Event{
|
||||
Name: name,
|
||||
CreatedTime: time.Now(),
|
||||
Type: eventType,
|
||||
}
|
||||
m := map[any]any{}
|
||||
m := map[string]string{}
|
||||
for i := range len(additionalKv) / 2 {
|
||||
m[additionalKv[2*i]] = additionalKv[2*i+1]
|
||||
}
|
||||
data.Additional = utils.StructToJsonStr(m)
|
||||
if err := repository.EventRepository.Create(data); err != nil {
|
||||
log.Logger.Errorw("事件创建失败", "err", err)
|
||||
}
|
||||
|
@@ -158,12 +158,14 @@ func (p *ProcessBase) SetState(state eum.ProcessState, fn ...func() bool) bool {
|
||||
func (p *ProcessBase) createEvent(state eum.ProcessState) {
|
||||
var eventType eum.EventType
|
||||
switch state {
|
||||
case eum.ProcessStateStart:
|
||||
case eum.ProcessStateRunning:
|
||||
eventType = eum.EventProcessStart
|
||||
case eum.ProcessStateStop:
|
||||
eventType = eum.EventProcessStop
|
||||
case eum.ProcessStateWarnning:
|
||||
eventType = eum.EventProcessWarning
|
||||
default:
|
||||
return
|
||||
}
|
||||
EventLogic.Create(p.Name, eventType)
|
||||
}
|
||||
|
@@ -39,7 +39,8 @@ func (t *TaskJob) Run(ctx context.Context) {
|
||||
if ctx.Value(eum.CtxTaskTraceId{}) == nil {
|
||||
ctx = context.WithValue(ctx, eum.CtxTaskTraceId{}, uuid.NewString())
|
||||
}
|
||||
EventLogic.Create(t.TaskConfig.Name, eum.EventTaskStart, "traceId", ctx.Value(eum.CtxTaskTraceId{}))
|
||||
EventLogic.Create(t.TaskConfig.Name, eum.EventTaskStart, "traceId", ctx.Value(eum.CtxTaskTraceId{}).(string))
|
||||
defer EventLogic.Create(t.TaskConfig.Name, eum.EventTaskStop, "traceId", ctx.Value(eum.CtxTaskTraceId{}).(string))
|
||||
t.Running = true
|
||||
middle.TaskWaitCond.Trigger()
|
||||
defer func() {
|
||||
@@ -71,7 +72,7 @@ func (t *TaskJob) Run(ctx context.Context) {
|
||||
// 执行操作
|
||||
log.Logger.Infow("任务开始执行")
|
||||
if !OperationHandle[t.TaskConfig.Operation](t.TaskConfig, proc) {
|
||||
log.Logger.Errorw("任务执行失败")
|
||||
log.Logger.Warnw("任务执行失败")
|
||||
return
|
||||
}
|
||||
log.Logger.Infow("任务执行成功", "target", t.TaskConfig.OperationTarget)
|
||||
@@ -96,7 +97,6 @@ func (t *TaskJob) Run(ctx context.Context) {
|
||||
} else {
|
||||
log.Logger.Infow("任务流结束")
|
||||
}
|
||||
EventLogic.Create(t.TaskConfig.Name, eum.EventProcessStop, "traceId", ctx.Value(eum.CtxTaskTraceId{}))
|
||||
}
|
||||
|
||||
func (t *TaskJob) InitCronHandle() error {
|
||||
|
@@ -1,5 +1,12 @@
|
||||
import api from "./api";
|
||||
|
||||
interface LoginRes {
|
||||
code: number;
|
||||
token: string;
|
||||
username: string;
|
||||
role: number;
|
||||
}
|
||||
|
||||
export const login = (query: any) => {
|
||||
return api.post("/user/login", query).then((res) => res);
|
||||
return api.post<LoginRes>("/user/login", query).then((res) => res);
|
||||
};
|
||||
|
@@ -1,4 +1,9 @@
|
||||
export default {
|
||||
login: {
|
||||
account: "Account",
|
||||
password: "Password",
|
||||
button: "Login",
|
||||
},
|
||||
common: {
|
||||
add: "Add",
|
||||
cancel: "Cancel",
|
||||
@@ -11,17 +16,6 @@ export default {
|
||||
tos: "Terms of Service",
|
||||
policy: "Privacy Policy",
|
||||
},
|
||||
login: {
|
||||
title: "Sign In",
|
||||
email: "Email",
|
||||
password: "Password",
|
||||
button: "Sign In",
|
||||
orsign: "Or sign in with",
|
||||
forgot: "Forgot password?",
|
||||
noaccount: "Don't have an account?",
|
||||
create: "Create one here",
|
||||
error: "The email / password combination is invalid",
|
||||
},
|
||||
register: {
|
||||
title: "Create Account",
|
||||
username: "Username",
|
||||
@@ -34,7 +28,7 @@ export default {
|
||||
signin: "Sign In",
|
||||
},
|
||||
menu: {
|
||||
process: 'ProcessManager',
|
||||
process: "ProcessManager",
|
||||
search: 'Search (press "ctrl + /" to focus)',
|
||||
dashboard: "Dashboard",
|
||||
logout: "Logout",
|
||||
|
@@ -1,4 +1,9 @@
|
||||
export default {
|
||||
login: {
|
||||
account: "账号",
|
||||
password: "密码",
|
||||
button: "登入",
|
||||
},
|
||||
common: {
|
||||
add: "新增",
|
||||
cancel: "取消",
|
||||
@@ -11,17 +16,6 @@ export default {
|
||||
tos: "服务条款",
|
||||
policy: "隐私政策",
|
||||
},
|
||||
login: {
|
||||
title: "登录",
|
||||
email: "电子邮件",
|
||||
password: "密码",
|
||||
button: "登录",
|
||||
orsign: "或使用",
|
||||
forgot: "忘记密码?",
|
||||
noaccount: "还没有帐号?",
|
||||
create: "在此处创建一个",
|
||||
error: "电子邮件/密码组合无效",
|
||||
},
|
||||
register: {
|
||||
title: "创建帐号",
|
||||
username: "全名",
|
||||
@@ -34,7 +28,7 @@ export default {
|
||||
signin: "登录",
|
||||
},
|
||||
menu: {
|
||||
process: '进程管理',
|
||||
process: "进程管理",
|
||||
search: "搜索(按“ Ctrl + /”进行聚焦)",
|
||||
dashboard: "仪表板",
|
||||
logout: "登出",
|
||||
@@ -246,4 +240,5 @@ export default {
|
||||
},
|
||||
},
|
||||
},
|
||||
}; ``
|
||||
};
|
||||
``;
|
||||
|
@@ -6,7 +6,7 @@ const isLoading = ref(false);
|
||||
const isSignInDisabled = ref(false);
|
||||
|
||||
const refLoginForm = ref();
|
||||
const username = ref("");
|
||||
const account = ref("");
|
||||
const password = ref("");
|
||||
const isFormValid = ref(true);
|
||||
|
||||
@@ -18,16 +18,16 @@ const handleLogin = async () => {
|
||||
isLoading.value = true;
|
||||
isSignInDisabled.value = true;
|
||||
login({
|
||||
username: username.value,
|
||||
account: account.value,
|
||||
password: password.value,
|
||||
}).then((e) => {
|
||||
isLoading.value = false;
|
||||
isSignInDisabled.value = false;
|
||||
|
||||
if (e.code === 0) {
|
||||
localStorage.setItem("token", e.data.token);
|
||||
localStorage.setItem("permission", e.data.permission);
|
||||
localStorage.setItem("name", username.value);
|
||||
localStorage.setItem("token", e.data?.token!);
|
||||
localStorage.setItem("role", e.data?.role.toString()!);
|
||||
localStorage.setItem("name", e.data?.username!);
|
||||
router.push("/");
|
||||
}
|
||||
});
|
||||
@@ -62,7 +62,7 @@ const resetErrors = () => {
|
||||
>
|
||||
<v-text-field
|
||||
ref="refAccount"
|
||||
v-model="username"
|
||||
v-model="account"
|
||||
required
|
||||
:error="error"
|
||||
:label="$t('login.account')"
|
||||
@@ -90,7 +90,6 @@ const resetErrors = () => {
|
||||
variant="underlined"
|
||||
color="primary"
|
||||
bg-color="#fff"
|
||||
:rules="passwordRules"
|
||||
name="password"
|
||||
outlined
|
||||
validateOn="blur"
|
||||
|
@@ -39,7 +39,7 @@ export default defineConfig({
|
||||
},
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: "http://xcon.top:8797",
|
||||
target: "http://127.0.0.1:8797",
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/sdApi/, ""),
|
||||
},
|
||||
|
Reference in New Issue
Block a user