Skip to content

Commit

Permalink
changed version to 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TyCoding committed Aug 10, 2024
1 parent bf07695 commit cb5c4b5
Show file tree
Hide file tree
Showing 18 changed files with 181 additions and 361 deletions.
18 changes: 0 additions & 18 deletions docs/README.md

This file was deleted.

396 changes: 146 additions & 250 deletions docs/langchat.sql

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ public class AuthConfiguration {
private final AuthProps authProps;
private final String[] skipUrl = new String[]{
"/auth/login",
"/aigc/auth/**",
"/auth/logout",
"/auth/register",
"/auth/info",
"/client/auth/**",
};

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public R login(@RequestBody UserInfo user) {
if (userInfo == null) {
throw new ServiceException("用户名或密码错误");
}
if (!userInfo.getStatus()) {
if (!AuthUtil.ADMINISTRATOR.equals(userInfo.getUsername()) && !userInfo.getStatus()) {
throw new ServiceException("该用户已经禁用,请联系管理员");
}

Expand Down Expand Up @@ -125,7 +125,7 @@ public R emailRegister(@RequestBody SysUser data) {
.setStatus(true)
.setCreateTime(new Date());
userService.add(user);
SysLogUtil.publish(1, "服务端注册", AuthUtil.getUsername());
SysLogUtil.publish(1, "服务端注册", user.getUsername());
return R.ok();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ public R login(@RequestBody AigcUser user) {

@GetMapping("/info")
public R info() {
return R.ok(ClientAuthUtil.getUserInfo());
AigcUser userInfo = ClientAuthUtil.getUserInfo();
userInfo.setPassword(null);
return R.ok(userInfo);
}

@DeleteMapping("/logout")
Expand Down Expand Up @@ -132,7 +134,7 @@ public R emailRegister(@RequestBody AigcUser data) {
.setStatus(true)
.setCreateTime(new Date());
userService.save(user);
SysLogUtil.publish(1, "客户端注册", ClientAuthUtil.getUsername());
SysLogUtil.publish(1, "客户端注册", user.getUsername());
return R.ok();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class AuthProps {
private List<String> skipUrl = new ArrayList();

private Integer chatLimit = 10;
private Boolean aigcRegUserIsPerms = false;
private Boolean aigcRegUserIsPerms = true;

private EmailProps email = new EmailProps();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.lang.Dict;
import cn.hutool.core.util.StrUtil;
import cn.tycoding.langchat.biz.entity.AigcUser;
import cn.tycoding.langchat.biz.service.AigcUserService;
import cn.tycoding.langchat.biz.utils.ClientStpUtil;
import cn.tycoding.langchat.common.annotation.ApiLog;
import cn.tycoding.langchat.common.constant.CacheConst;
import cn.tycoding.langchat.common.properties.AuthProps;
import cn.tycoding.langchat.common.utils.MybatisUtil;
import cn.tycoding.langchat.common.utils.QueryPage;
Expand Down Expand Up @@ -92,8 +95,12 @@ public R<AigcUser> add(@RequestBody AigcUser data) {
@ApiLog("修改客户端用户")
@SaCheckPermission("aigc:user:update")
public R update(@RequestBody AigcUser data) {
data.setPassword(AuthUtil.encode(authProps.getSaltKey(), data.getPassword()));
if (StrUtil.isNotBlank(data.getPassword())) {
data.setPassword(AuthUtil.encode(authProps.getSaltKey(), data.getPassword()));
}
userService.updateById(data);
ClientStpUtil.getSessionByLoginId(data.getId()).set(CacheConst.AUTH_USER_INFO_KEY, data);
ClientStpUtil.getSessionByLoginId(data.getId()).update();
return R.ok();
}

Expand Down
Binary file added langchat-ui-client/src/assets/login/chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion langchat-ui-client/src/router/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export function setupPageGuard(router: Router) {
router.beforeEach(async (to, from, next) => {
const userStore = useUserStore();
if (userStore.token != null) {
await info();
const data = await info();
userStore.setUser(data);
}
next();
});
Expand Down
2 changes: 1 addition & 1 deletion langchat-ui-client/src/views/login/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

const form = reactive({
username: 'langchat@outlook.com',
password: '123456',
password: 'langchat',
});

const handleSubmit = (e: any) => {
Expand Down
2 changes: 1 addition & 1 deletion langchat-ui-client/src/views/modules/chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
if (inputRef.value && !isMobile.value) {
inputRef.value?.focus();
}
await chatStore.loadData();
if (chatStore.conversations.length == 0) {
await chatStore.addConversation({ title: 'New Chat' });
}
await chatStore.loadData();
});
onUnmounted(() => {
if (loading.value) {
Expand Down
6 changes: 3 additions & 3 deletions langchat-ui-client/src/views/modules/chat/message/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { isString } from '@/utils/is';
import { useUserStore } from '@/store/modules/user';
import defaultAvatar from '@/assets/avatar.jpg';
import logoAvatar from '@/assets/login/logo.png';
import chatAvatar from '@/assets/login/chat.png';

interface Props {
image?: boolean;
Expand All @@ -46,8 +46,8 @@
/>
<NAvatar v-else :src="defaultAvatar" round />
</template>
<span v-else class="">
<n-avatar :src="logoAvatar" object-fit="contain" />
<span v-else class="flex justify-center items-center">
<n-avatar :src="chatAvatar" object-fit="contain" />
</span>
</template>

Expand Down
2 changes: 1 addition & 1 deletion langchat-ui-client/src/views/modules/chat/sider/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<span>{{ t('chat.newChatButton') }}</span>
</n-button>
</div>
<div class="flex-1 min-h-0 pb-4 overflow-hidden flex flex-col gap-2">
<div class="flex-1 min-h-0 pb-6 overflow-hidden flex flex-col gap-2">
<List />
<div class="pb-2 px-4">
<n-select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
<n-icon color="#e4e4e7" size="70">
<SvgIcon icon="et:chat" />
</n-icon>
<n-button secondary size="small" type="success">Chat starting</n-button>
<n-button secondary size="small" type="success">开始聊天</n-button>
</div>
</div>
<div v-else class="flex-1 overflow-y-auto mb-1">
Expand Down
Binary file added langchat-ui/src/assets/chat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 0 additions & 60 deletions langchat-ui/src/assets/icons/logo.svg

This file was deleted.

1 change: 0 additions & 1 deletion langchat-ui/src/views/aigc/user/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export const formSchemas: FormSchema[] = [
type: 'password',
placeholder: '请输入密码',
},
rules: [{ required: true, message: '请输入密码', trigger: ['blur'] }],
},
{
field: 'nickname',
Expand Down
24 changes: 7 additions & 17 deletions langchat-ui/src/views/chat/message/Avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
- limitations under the License.
-->

<script setup lang="ts">
<script lang="ts" setup>
import { computed } from 'vue';
import { NAvatar } from 'naive-ui';
import { isString } from '@/utils/is';
import { useUserStore } from '@/store/modules/user';
import defaultAvatar from '@/assets/avatar.jpg';
import chatAvatar from '@/assets/chat.png';

interface Props {
image?: boolean;
Expand All @@ -35,25 +36,14 @@
<template v-if="image">
<NAvatar
v-if="isString(avatar) && avatar.length > 0"
:src="avatar"
:fallback-src="defaultAvatar"
:src="avatar"
/>
<NAvatar v-else round :src="defaultAvatar" />
<NAvatar v-else :src="defaultAvatar" round />
</template>
<span v-else class="text-[28px]">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 32 32"
aria-hidden="true"
width="1em"
height="1em"
>
<path
d="M29.71,13.09A8.09,8.09,0,0,0,20.34,2.68a8.08,8.08,0,0,0-13.7,2.9A8.08,8.08,0,0,0,2.3,18.9,8,8,0,0,0,3,25.45a8.08,8.08,0,0,0,8.69,3.87,8,8,0,0,0,6,2.68,8.09,8.09,0,0,0,7.7-5.61,8,8,0,0,0,5.33-3.86A8.09,8.09,0,0,0,29.71,13.09Zm-12,16.82a6,6,0,0,1-3.84-1.39l.19-.11,6.37-3.68a1,1,0,0,0,.53-.91v-9l2.69,1.56a.08.08,0,0,1,.05.07v7.44A6,6,0,0,1,17.68,29.91ZM4.8,24.41a6,6,0,0,1-.71-4l.19.11,6.37,3.68a1,1,0,0,0,1,0l7.79-4.49V22.8a.09.09,0,0,1,0,.08L13,26.6A6,6,0,0,1,4.8,24.41ZM3.12,10.53A6,6,0,0,1,6.28,7.9v7.57a1,1,0,0,0,.51.9l7.75,4.47L11.85,22.4a.14.14,0,0,1-.09,0L5.32,18.68a6,6,0,0,1-2.2-8.18Zm22.13,5.14-7.78-4.52L20.16,9.6a.08.08,0,0,1,.09,0l6.44,3.72a6,6,0,0,1-.9,10.81V16.56A1.06,1.06,0,0,0,25.25,15.67Zm2.68-4-.19-.12-6.36-3.7a1,1,0,0,0-1.05,0l-7.78,4.49V9.2a.09.09,0,0,1,0-.09L19,5.4a6,6,0,0,1,8.91,6.21ZM11.08,17.15,8.38,15.6a.14.14,0,0,1-.05-.08V8.1a6,6,0,0,1,9.84-4.61L18,3.6,11.61,7.28a1,1,0,0,0-.53.91ZM12.54,14,16,12l3.47,2v4L16,20l-3.47-2Z"
fill="currentColor"
/>
</svg>
<span v-else class="text-[28px] flex justify-center items-center">
<NAvatar :src="chatAvatar" round />
</span>
</template>

<style scoped lang="less"></style>
<style lang="less" scoped></style>

0 comments on commit cb5c4b5

Please sign in to comment.