Skip to content

Commit

Permalink
Merge pull request #79 from tolerious/feat/refactor-app
Browse files Browse the repository at this point in the history
🚧 Register logic.
  • Loading branch information
tolerious authored Oct 6, 2024
2 parents e377f01 + d6edb5c commit 22fb776
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/views/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ async function getGroupList() {
url: '/wordgroup',
});
const g = info.data.list.find(group => group.wordCount > 0);
defaultGroupID.value = g._id;
if (g) {
defaultGroupID.value = g._id;
} else {
defaultGroupID.value = '';
}
}
async function getUserSettings() {
Expand Down
26 changes: 23 additions & 3 deletions src/views/UserLogin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
</template>
<script setup lang="ts">
import { request } from '@/utils/service';
import { ElNotification } from 'element-plus';
import { ElMessage, ElNotification } from 'element-plus';
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
Expand All @@ -96,8 +96,28 @@ onMounted(() => {
localStorage.setItem('token', '');
});
function register() {
router.push('/register');
async function register() {
const r = await request({
url: '/user/create',
method: 'post',
data: {
username: userInfo.value.username,
password: userInfo.value.password,
ignore: true,
source: 'app',
},
});
console.log(r);
if (r.code === 200) {
ElNotification({
message: '注册成功,请登录',
type: 'success',
duration: 1200,
});
isLogin.value = true;
} else {
ElMessage({ message: r.msg, duration: 1200, type: 'error' });
}
}
async function login() {
Expand Down

0 comments on commit 22fb776

Please sign in to comment.