md功能实现
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
import request from '../utils/request'
|
||||||
|
const authorize = (params: any) => {
|
||||||
|
return request({
|
||||||
|
url: '/api/vi/authorize',
|
||||||
|
method: 'post',
|
||||||
|
data: {}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export { authorize }
|
||||||
@@ -12,13 +12,13 @@
|
|||||||
<el-dropdown-item>删除</el-dropdown-item>
|
<el-dropdown-item>删除</el-dropdown-item>
|
||||||
</el-dropdown-menu>-->
|
</el-dropdown-menu>-->
|
||||||
</el-dropdown>
|
</el-dropdown>
|
||||||
<span>小管</span>
|
<span @click="doLogin">登录</span> </div>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang='ts'>
|
<script setup lang='ts'>
|
||||||
import $moment from "moment";
|
import $moment from "moment";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
import router from '../../router'
|
||||||
|
|
||||||
const getTime = () => {
|
const getTime = () => {
|
||||||
return $moment().format("YYYY年MM月DD日 HH:mm:ss");
|
return $moment().format("YYYY年MM月DD日 HH:mm:ss");
|
||||||
@@ -30,6 +30,12 @@ const timeChange = () => {
|
|||||||
time.value = getTime();
|
time.value = getTime();
|
||||||
};
|
};
|
||||||
setInterval(timeChange, 1000);
|
setInterval(timeChange, 1000);
|
||||||
|
|
||||||
|
const doLogin = () => {
|
||||||
|
router.push({
|
||||||
|
path: '/login'
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -37,6 +43,7 @@ setInterval(timeChange, 1000);
|
|||||||
background: url("../../assets/logo.png") center no-repeat;
|
background: url("../../assets/logo.png") center no-repeat;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-main {
|
.nav-main {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,76 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="login">
|
<div class="yuliu"></div>
|
||||||
login
|
<el-card class="box-card">
|
||||||
|
<el-form ref="ruleFormRef" :model="userForm" status-icon label-width="120px" class="demo-ruleForm">
|
||||||
|
<el-form-item label="用户名" prop="pass">
|
||||||
|
<el-input v-model="userForm.user_id" type="password" autocomplete="off" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户凭证" prop="checkPass">
|
||||||
|
<el-input v-model="userForm.password" type="password" autocomplete="off" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="dologin">login</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
------------------------------------------------------------
|
||||||
|
<div>
|
||||||
|
微信/支付宝
|
||||||
</div>
|
</div>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script lang="ts" setup>
|
||||||
</script>
|
import { reactive, ref } from 'vue'
|
||||||
|
import type { FormInstance } from 'element-plus'
|
||||||
|
import { authorize } from '../../api/user';
|
||||||
|
|
||||||
<style>
|
const userForm = reactive({
|
||||||
.login {
|
user_id: '',
|
||||||
background-color: beige;
|
password: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
const dologin = (form: FormInstance | undefined) => {
|
||||||
|
|
||||||
|
if (!form) return
|
||||||
|
form.validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
let validForm = {
|
||||||
|
}
|
||||||
|
authorize(validForm).then(response => {
|
||||||
|
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const resetForm = (formEl: FormInstance | undefined) => {
|
||||||
|
if (!formEl) return
|
||||||
|
formEl.resetFields()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.text {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.item {
|
||||||
|
padding: 18px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-card {
|
||||||
|
width: 480px;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yuliu {
|
||||||
|
width: 600px;
|
||||||
|
height: 600px;
|
||||||
|
background-color: antiquewhite;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
+6
-2
@@ -15,13 +15,13 @@ app.use(router)
|
|||||||
app.use(ElementPlus)
|
app.use(ElementPlus)
|
||||||
app.use(store)
|
app.use(store)
|
||||||
|
|
||||||
|
import { getToken } from './utils/auth'
|
||||||
const whiteList = ['/', '/blog']
|
const whiteList = ['/', '/blog']
|
||||||
let url = window.location.href
|
let url = window.location.href
|
||||||
console.log(url)
|
console.log(url)
|
||||||
if (url != 'http://localhost:3000/' && url.search("blog=") != -1) {
|
if (url != 'http://localhost:3000/' && url.search("blog=") != -1) {
|
||||||
let blog = {
|
let blog = {
|
||||||
blog_id: 1
|
blog_id: url.split("=")[1]
|
||||||
}
|
}
|
||||||
router.push({
|
router.push({
|
||||||
path: '/feedback',
|
path: '/feedback',
|
||||||
@@ -30,6 +30,10 @@ if (url != 'http://localhost:3000/' && url.search("blog=") != -1) {
|
|||||||
}
|
}
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
console.log(to.path, from.path)
|
console.log(to.path, from.path)
|
||||||
|
if (to.path === '/login') {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (whiteList.includes(to.path)) {
|
if (whiteList.includes(to.path)) {
|
||||||
|
|||||||
+5
-1
@@ -73,7 +73,11 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
{
|
{
|
||||||
path: "/feedback",
|
path: "/feedback",
|
||||||
component: () => import('../view/blog/mdview.vue')
|
component: () => import('../view/blog/mdview.vue')
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
path: "/login",
|
||||||
|
component: () => import('../components/login/login.vue')
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import MdEditor from 'md-editor-v3';
|
import MdEditor from 'md-editor-v3';
|
||||||
|
import 'md-editor-v3/lib/style.css';
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { get_blog } from '../../api/blog'
|
import { get_blog } from '../../api/blog'
|
||||||
let text = ref<string>('')
|
let text = ref<string>('')
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
get_blog(route.query).then(response => {
|
get_blog(route.query).then(response => {
|
||||||
console.log(response.data)
|
text.value = response.data.blog_text
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user