Skip to content

Commit

Permalink
feat: 实现回车登录和注册 (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lansongxx authored Apr 8, 2024
1 parent 2c26cfa commit 454777a
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@

## 2024-04-08

### ✨ Features | 新功能

* 实现回车登录和注册

## 2024-04-07

### ✨ Features | 新功能
Expand Down
8 changes: 4 additions & 4 deletions src/components/navigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@
>
<i class="iconfont icon-shopping-cart-solid"></i>
</router-link> -->
<router-link
<!-- <router-link
to="/manage"
class="router-nav"
active-class="router-active"
>
<i class="iconfont icon-guanlizhongxin-shezhi-01"></i>
</router-link>
<router-link
</router-link> -->
<!-- <router-link
to="/test"
class="router-nav"
active-class="router-active"
>
测试
</router-link>
</router-link> -->
</div>
</div>
</template>
Expand Down
9 changes: 8 additions & 1 deletion src/components/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
<input
type="text"
placeholder="搜索"
v-model="keyword"
>
<i class="iconfont icon-sistrix"></i>
<i @click="router.push(`/search/${keyword}`)" class="iconfont icon-sistrix"></i>
</div>
</template>

<script setup lang="ts">
import router from '@/router'
import { onMounted, ref } from 'vue'
const keyword = ref('')
onMounted(() => {
})
</script>

<style scoped lang="css">
Expand Down
20 changes: 10 additions & 10 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,23 @@ const routes: RouteRecordRaw[] = [
component: () => import('../views/manage/post.vue'),
},
{
path: '/test',
component: () => import('../views/test-posts/posts.vue'),
},
path: '/posts',
component: () => import('../views/posts/posts.vue'),
},
{
path: '/test/editor',
component: () => import('../views/test-posts/text-editor.vue'),
path: '/editor',
component: () => import('../views/posts/text-editor.vue'),
},
{
path: '/test/write',
component: () => import('../views/test-posts/write.vue'),
path: '/write',
component: () => import('../views/posts/write.vue'),
},
{
path: '/test/post/:postId',
component: () => import('../views/test-posts/post.vue'),
path: '/post/:postId',
component: () => import('../views/posts/post.vue'),
},
{
path: '/search',
path: '/search/:keyword?',
component: () => import('../views/search/search.vue'),
}
]
Expand Down
17 changes: 14 additions & 3 deletions src/views/login/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
import Captcha from '@/components/captcha.vue'
import Third from './third-login.vue'
import router from '@/router'
import { ref, onMounted } from 'vue'
import { ref, onMounted, onUnmounted } from 'vue'
import { post, get } from '@/utils/request';
import { useStore } from '@/store/index';
import { errorMsg, successMsg } from '@/utils/message';
Expand All @@ -108,14 +108,25 @@ const isEmail = ref(false)
const isCaptcha = ref(false)
const isPassword = ref(false)
const errorEmail = ref(false)
const agreements = ref(false)
const isAutoLogin = ref(false)
const agreements = ref(true)
const isAutoLogin = ref(true)
const errorPassword = ref(false)
onMounted(() => {
thirdLogin()
document.addEventListener('keydown', handleEnterKey);
})
onUnmounted(() => {
document.removeEventListener('keydown', handleEnterKey);
})
const handleEnterKey = (event: KeyboardEvent) => {
if (event.key === 'Enter') {
login();
}
};
const thirdLogin = () => {
const code = location.href.split('=')[1]
if (code) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/views/test-posts/post.vue → src/views/posts/post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ import CHeader from '@/components/header.vue'
import {onMounted, ref} from "vue";
import {getPostDetail, getPostRecommendByPostId, turnTime} from "@/utils/utils";
import {useStore} from "@/store";
import {enterPost} from "@/views/test-posts/utils";
import {enterPost} from "@/views/posts/utils";
import {CreateRelation} from "@/utils/api";
import {RelationType, TargetType} from "@/utils/consts";
Expand Down
3 changes: 2 additions & 1 deletion src/views/test-posts/posts.vue → src/views/posts/posts.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
</div>
<div class="rank-create">
<div class="create-post">
<button @click="router.push('/test/write')">创建帖子</button>
<button @click="router.push('/write')">创建帖子</button>
<button @click="router.push('/manage/post')">管理帖子</button>
</div>
<div class="post-rank">
<div class="post-rank-title">
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
import {onMounted, ref} from 'vue'
import type {Tag, Zone} from "@/utils/type";
import {createPost, getPostStatus, getTagList, getZoneList} from "@/utils/utils";
import {enterPost} from "@/views/test-posts/utils";
import {enterPost} from "@/views/posts/utils";
const isShowSetting = ref(true)
const sureOption = ref(false)
Expand Down
2 changes: 1 addition & 1 deletion src/views/test-posts/utils.ts → src/views/posts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,5 @@ export const getFollowPostList = async (limit: number, offset: number) => {
}

export const enterPost = (id: string) => {
router.push('/test/post/' + id)
router.push('/post/' + id)
}
File renamed without changes.
21 changes: 20 additions & 1 deletion src/views/register/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<script setup lang="ts">
import router from '../../router/index'
import Third from '@/views/login/third-login.vue'
import { ref } from 'vue'
import { onMounted, onUnmounted, ref } from 'vue'
import { judgeEmail, judgePassword } from '@/utils/judge'
import { errorMsg, successMsg } from '@/utils/message'
import { post, get } from '@/utils/request'
Expand Down Expand Up @@ -148,6 +148,25 @@ const errorConfirmPassword = ref(false)
const captchaMessage = ref('获取验证码')
const isButtonDisabled = ref(false) // 新增一个响应式变量来控制按钮的disabled状态
onMounted(() => {
document.addEventListener('keydown', handleEnterKey);
})
onUnmounted(() => {
document.removeEventListener('keydown', handleEnterKey);
})
const handleEnterKey = (e: KeyboardEvent) => {
if (e.key === 'Enter') {
if (!isNext.value) {
next()
} else {
register()
}
}
}
const emailBlur = () => {
if (email.value === '') {
errorEmail.value = true
Expand Down
18 changes: 14 additions & 4 deletions src/views/search/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
</li>
<li>
<input
type="radio"
type="radio"
name="select"
id="tags"
value="tags"
id="files"
value="files"
>
<label for="tags">标签</label>
<label for="files">文件</label>
</li>
<li>
<input
Expand Down Expand Up @@ -113,6 +113,16 @@
</template>
<script setup lang="ts">
import CHeader from '@/components/header.vue'
import { onMounted } from 'vue';
import { ref } from 'vue';
const keyword = ref('')
onMounted(() => {
keyword.value = location.href.split('/').pop() as string
console.log(keyword.value)
})
</script>
<style scoped lang="css">
.search-box {
Expand Down

0 comments on commit 454777a

Please sign in to comment.