fix: mpv completed; add ci
This commit is contained in:
@@ -14,6 +14,8 @@ const userInfo = userInfoStore();
|
||||
const vditorRef = ref(null);
|
||||
let vditor = null;
|
||||
|
||||
const emit = defineEmits(['ready'])
|
||||
|
||||
// 定义 localStorage 的 key
|
||||
const STORAGE_KEY = 'publishArticle';
|
||||
|
||||
@@ -54,6 +56,7 @@ onMounted(() => {
|
||||
}
|
||||
},
|
||||
after() {
|
||||
emit('ready');
|
||||
console.log('Vditor 初始化完成');
|
||||
// 初始化后,加载本地缓存内容
|
||||
const cachedContent = localStorage.getItem(STORAGE_KEY);
|
||||
|
||||
@@ -41,11 +41,6 @@ const router = createRouter({
|
||||
component: () => import("@/views/admin/admin.vue"),
|
||||
|
||||
children: [
|
||||
// {
|
||||
// path: "/",
|
||||
// name: "dashboard",
|
||||
// component: () => import("@/views/admin/dashboard.vue"),
|
||||
// },
|
||||
{
|
||||
path: "posts",
|
||||
name: "posts",
|
||||
@@ -62,14 +57,6 @@ const router = createRouter({
|
||||
title: "新闻管理",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "projects",
|
||||
name: "projects",
|
||||
component: () => import("@/views/admin/projects.vue"),
|
||||
meta: {
|
||||
title: "项目管理",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "details",
|
||||
name: "details",
|
||||
@@ -80,21 +67,6 @@ const router = createRouter({
|
||||
name: "comments",
|
||||
component: () => import("@/views/admin/comments.vue"),
|
||||
},
|
||||
// {
|
||||
// path: "tags",
|
||||
// name: "tags",
|
||||
// component: () => import("@/views/admin/tags.vue"),
|
||||
// },
|
||||
// {
|
||||
// path: "users",
|
||||
// name: "users",
|
||||
// component: () => import("@/views/admin/users.vue"),
|
||||
// },
|
||||
// {
|
||||
// path: "settings",
|
||||
// name: "settings",
|
||||
// component: () => import("@/views/admin/settings.vue"),
|
||||
// },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -78,8 +78,9 @@ export const viewDetailsStore = defineStore("viewDetails", {
|
||||
id: "",
|
||||
title: "",
|
||||
content: "",
|
||||
created: "",
|
||||
updated: "",
|
||||
cover: "",
|
||||
published: "",
|
||||
related: "",
|
||||
},
|
||||
}),
|
||||
actions: {
|
||||
@@ -87,8 +88,9 @@ export const viewDetailsStore = defineStore("viewDetails", {
|
||||
this.detail.id = data.id;
|
||||
this.detail.title = data.title;
|
||||
this.detail.content = data.content;
|
||||
this.detail.created = data.created;
|
||||
this.detail.updated = data.updated;
|
||||
this.detail.cover = data.cover;
|
||||
this.detail.published = data.published;
|
||||
this.detail.related = data.related;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,22 +7,24 @@ export const userInfoStore = defineStore(
|
||||
const token = ref(null);
|
||||
|
||||
const user = reactive({
|
||||
u_id: "",
|
||||
u_name: "",
|
||||
u_avatar: "@/assets/defaultavatar.jpg",
|
||||
u_account: "",
|
||||
id: "",
|
||||
name: "",
|
||||
profile: "@/assets/defaultavatar.jpg",
|
||||
account: "",
|
||||
role: "",
|
||||
});
|
||||
|
||||
const clearUserInfo = () => {
|
||||
this.token.value = null;
|
||||
this.user = {
|
||||
u_id: "",
|
||||
u_name: "",
|
||||
u_avatar: "@/assets/defaultavatar.jpg",
|
||||
u_account: "",
|
||||
role: "",
|
||||
};
|
||||
token.value = null;
|
||||
|
||||
user.id = "";
|
||||
user.name = "";
|
||||
user.profile = "@/assets/defaultavatar.jpg";
|
||||
user.account = "";
|
||||
user.role = "";
|
||||
|
||||
// 清除本地存储的用户信息
|
||||
localStorage.removeItem("userInfo");
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
.show-top-text{
|
||||
text-align: center;
|
||||
}
|
||||
.newsbox {
|
||||
.newsbox, .articlesbox{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.news {
|
||||
.news, .articles{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
@@ -32,7 +32,7 @@
|
||||
flex: 2;
|
||||
height: 100px;
|
||||
}
|
||||
.newspic {
|
||||
.newspic, .articlespic{
|
||||
display: inline-block;
|
||||
background-color: #5b5a5a;
|
||||
width: 20%;
|
||||
@@ -40,7 +40,7 @@
|
||||
max-width: 130px;
|
||||
height: 100%;
|
||||
}
|
||||
.newscontent {
|
||||
.newscontent, .articlescontent{
|
||||
margin-right: auto;
|
||||
display: inline-block;
|
||||
padding: 10px;
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
</el-icon>
|
||||
<span>文章管理</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/admin/projects">
|
||||
<el-icon>
|
||||
<document />
|
||||
</el-icon>
|
||||
<span>项目管理</span>
|
||||
</el-menu-item>
|
||||
<el-menu-item index="/admin/comments">
|
||||
<el-icon><chat-line-round /></el-icon>
|
||||
<span>评论管理</span>
|
||||
|
||||
@@ -3,30 +3,33 @@
|
||||
<template #header>
|
||||
<div class="flex justify-between items-center">
|
||||
<span>文章列表</span>
|
||||
<el-button type="primary" @click="openAddArticleModal = true">新增文章</el-button>
|
||||
<el-button type="primary" @click="openAddarticlesModal = true">新增文章</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table :data="tableData" style="width: 100%">
|
||||
<el-table-column prop="title" label="标题" />
|
||||
<el-table-column prop="created" label="创建时间" />
|
||||
<el-table-column prop="updated" label="更新时间" />
|
||||
<el-table-column prop="published" label="发布时间" />
|
||||
<el-table-column label="操作">
|
||||
<template #default="scope">
|
||||
<el-button size="small" @click="openDetails(scope.row)">查看</el-button>
|
||||
<el-button size="small">编辑</el-button>
|
||||
<el-button size="small" @click="edit(scope)">编辑</el-button>
|
||||
<el-button size="small" type="danger">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<el-dialog v-model="openAddArticleModal" title="新增文章" style="height: 70%; width: 80%;">
|
||||
<el-input size="large" v-model="title" prefix-icon="el-icon-edit" placeholder="请输入文章标题"></el-input>
|
||||
<MarkdownEditor ref="editor" />
|
||||
<el-button type="primary" @click="submitArticle">发布</el-button>
|
||||
<el-dialog v-model="openAddarticlesModal" title="新增文章" style="height: 70%; width: 80%;">
|
||||
<el-input size="large" v-model=title prefix-icon="el-icon-edit" placeholder="请输入文章标题"></el-input>
|
||||
<MarkdownEditor ref="editor1" @ready="editor1ready" />
|
||||
<el-button type="primary" @click="submit()">发布</el-button>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="openEditarticlesModal" title="编辑文章" style="height: 70%; width: 80%;">
|
||||
<el-input size="large" v-model=title prefix-icon="el-icon-edit" placeholder="请输入文章标题"></el-input>
|
||||
<MarkdownEditor ref="editor2" @ready="editor2ready" />
|
||||
<el-button type="primary" @click="update()">更新</el-button>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -35,35 +38,45 @@ import { ElMessage } from 'element-plus'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import axios from 'axios'
|
||||
import MarkdownEditor from '@/components/MarkdownEditor.vue'
|
||||
import { articleStore, detailsStore } from '@/store/details'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { Edit } from '@element-plus/icons-vue'
|
||||
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const detail = detailsStore()
|
||||
const articleinfo = articleStore()
|
||||
const userinfo = userInfoStore()
|
||||
|
||||
const openAddArticleModal = ref(false)
|
||||
const openEditarticlesModal =ref(false)
|
||||
const openAddarticlesModal = ref(false)
|
||||
|
||||
const editor = ref(null)
|
||||
const id = ref('')
|
||||
const title = ref('')
|
||||
const content = ref('')
|
||||
|
||||
const page = ref(1)
|
||||
const pageSize = ref(5)
|
||||
const total = ref()
|
||||
|
||||
const title = ref("")
|
||||
const tableData = ref([
|
||||
])
|
||||
const editor1 = ref(null)
|
||||
const editor2 = ref(null)
|
||||
|
||||
const getArticle = async () => {
|
||||
const tableData = ref([])
|
||||
|
||||
const edit = (scope) => {
|
||||
openEditarticlesModal.value = true
|
||||
id.value = scope.row.id
|
||||
title.value = scope.row.title
|
||||
content.value = scope.row.content
|
||||
}
|
||||
|
||||
|
||||
const editor1ready = () =>{
|
||||
title.value = ''
|
||||
editor1.value.setContent('')
|
||||
}
|
||||
|
||||
const editor2ready = () =>{
|
||||
editor2.value.setContent(content.value)
|
||||
}
|
||||
|
||||
const getarticles = async () => {
|
||||
try {
|
||||
const response = await axios.get("/api/admin/get/article", {
|
||||
headers: {
|
||||
Authorization: "Bearer " + userinfo.token,
|
||||
},
|
||||
const response = await axios.get("/api/blog/get/articles", {
|
||||
params: {
|
||||
current: page.value,
|
||||
size: pageSize.value
|
||||
@@ -75,55 +88,68 @@ const getArticle = async () => {
|
||||
}
|
||||
tableData.value = response.data.data.records
|
||||
total.value = response.data.data.total
|
||||
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
ElMessage.error("获取文章失败")
|
||||
}
|
||||
}
|
||||
|
||||
const submitArticle = async () => {
|
||||
const markdownContent = editor.value.getContent()
|
||||
console.log("提交的内容:", markdownContent)
|
||||
try {
|
||||
const response = await axios.post("/api/admin/publish/article", {
|
||||
|
||||
|
||||
const submit = async () => {
|
||||
try{
|
||||
const response = await axios.post("/api/admin/add/article", {
|
||||
title: title.value,
|
||||
content: markdownContent,
|
||||
content: editor1.value.getContent(),
|
||||
}, {
|
||||
headers: {
|
||||
Authorization: "Bearer " + userinfo.token,
|
||||
contentType: "application/json"
|
||||
},
|
||||
}
|
||||
})
|
||||
if (!response.data.code === 200) {
|
||||
if (response.data.code !== 200) {
|
||||
ElMessage.error(response.data.message)
|
||||
return
|
||||
}
|
||||
ElMessage.success("发布成功")
|
||||
openAddArticleModal.value = false
|
||||
getArticle()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
ElMessage.error("发布失败")
|
||||
return
|
||||
ElMessage.success("发布文章成功")
|
||||
openAddarticlesModal.value = false
|
||||
getarticles()
|
||||
}
|
||||
catch (error){
|
||||
console.log(error)
|
||||
ElMessage.error("发布文章失败")
|
||||
}
|
||||
editor.value.clearContent()
|
||||
title.value = ""
|
||||
}
|
||||
|
||||
const openDetails = (row) => {
|
||||
console.log(row)
|
||||
// 打开文章详情页面
|
||||
articleinfo.setArticle(row) // 设置文章详情
|
||||
detail.setType("article")
|
||||
// 跳转到文章详情页面
|
||||
router.push('/admin/details')
|
||||
|
||||
const update = async () => {
|
||||
console.log(userinfo.token)
|
||||
try{
|
||||
const response = await axios.post("/api/admin/update/article", {
|
||||
id: id.value,
|
||||
title: title.value,
|
||||
content: editor2.value.getContent(),
|
||||
}, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${userinfo.token}`,
|
||||
}
|
||||
})
|
||||
if (response.data.code !== 200) {
|
||||
ElMessage.error(response.data.message)
|
||||
return
|
||||
}
|
||||
ElMessage.success("更新文章成功")
|
||||
openEditarticlesModal.value = false
|
||||
getarticles()
|
||||
}
|
||||
catch (error){
|
||||
console.log(error)
|
||||
ElMessage.error("更新文章失败")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
page.value = 1
|
||||
getArticle()
|
||||
getarticles()
|
||||
})
|
||||
|
||||
</script>
|
||||
@@ -8,12 +8,11 @@
|
||||
</template>
|
||||
|
||||
<el-table :data="tableData" style="width: 100%">
|
||||
<el-table-column prop="n_title" label="标题" />
|
||||
<el-table-column prop="title" label="标题" />
|
||||
<el-table-column prop="published" label="发布时间" />
|
||||
<el-table-column label="操作">
|
||||
<template #default="scope">
|
||||
<el-button size="small" @click="openDetails(scope.row)">查看</el-button>
|
||||
<el-button size="small">编辑</el-button>
|
||||
<el-button size="small" @click="edit(scope)">编辑</el-button>
|
||||
<el-button size="small" type="danger">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -21,10 +20,16 @@
|
||||
</el-card>
|
||||
|
||||
<el-dialog v-model="openAddNewsModal" title="新增新闻" style="height: 70%; width: 80%;">
|
||||
<el-input size="large" v-model="title" prefix-icon="el-icon-edit" placeholder="请输入文章标题"></el-input>
|
||||
<MarkdownEditor ref="editor" />
|
||||
<el-input size="large" v-model=title prefix-icon="el-icon-edit" placeholder="请输入文章标题"></el-input>
|
||||
<MarkdownEditor ref="editor1" @ready="editor1ready" />
|
||||
<el-button type="primary" @click="submit()">发布</el-button>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="openEditNewsModal" title="编辑新闻" style="height: 70%; width: 80%;">
|
||||
<el-input size="large" v-model=title prefix-icon="el-icon-edit" placeholder="请输入文章标题"></el-input>
|
||||
<MarkdownEditor ref="editor2" @ready="editor2ready" />
|
||||
<el-button type="primary" @click="update()">更新</el-button>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -32,27 +37,46 @@ import { userInfoStore } from '@/store/store'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import axios from 'axios'
|
||||
import { newsStore, detailsStore } from '@/store/details'
|
||||
import { useRouter } from 'vue-router'
|
||||
import MarkdownEditor from '@/components/MarkdownEditor.vue'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const newsinfo = newsStore()
|
||||
const detailtype = detailsStore()
|
||||
const userinfo = userInfoStore()
|
||||
|
||||
const openEditNewsModal =ref(false)
|
||||
const openAddNewsModal = ref(false)
|
||||
|
||||
const id = ref('')
|
||||
const title = ref('')
|
||||
const content = ref('')
|
||||
|
||||
const page = ref(1)
|
||||
const pageSize = ref(5)
|
||||
const total = ref()
|
||||
|
||||
const editor1 = ref(null)
|
||||
const editor2 = ref(null)
|
||||
|
||||
const tableData = ref([])
|
||||
|
||||
const edit = (scope) => {
|
||||
openEditNewsModal.value = true
|
||||
id.value = scope.row.id
|
||||
title.value = scope.row.title
|
||||
content.value = scope.row.content
|
||||
}
|
||||
|
||||
|
||||
const editor1ready = () =>{
|
||||
title.value = ''
|
||||
editor1.value.setContent('')
|
||||
}
|
||||
|
||||
const editor2ready = () =>{
|
||||
editor2.value.setContent(content.value)
|
||||
}
|
||||
|
||||
const getNews = async () => {
|
||||
try {
|
||||
const response = await axios.get("/api/admin/get/news", {
|
||||
const response = await axios.get("/api/blog/get/news", {
|
||||
headers: {
|
||||
Authorization: "Bearer " + userinfo.token,
|
||||
},
|
||||
@@ -73,20 +97,55 @@ const getNews = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const openDetails = (row) => {
|
||||
console.log(row)
|
||||
// 打开文章详情页面
|
||||
newsinfo.setNews(row) // 设置文章详情
|
||||
detailtype.setType("news")
|
||||
// 跳转到文章详情页面
|
||||
router.push('/admin/details')
|
||||
}
|
||||
|
||||
|
||||
const submit = async () => {
|
||||
|
||||
|
||||
try{
|
||||
const response = await axios.post("/api/admin/add/news", {
|
||||
title: title.value,
|
||||
content: editor1.value.getContent(),
|
||||
})
|
||||
if (response.data.code !== 200) {
|
||||
ElMessage.error(response.data.message)
|
||||
return
|
||||
}
|
||||
ElMessage.success("发布新闻成功")
|
||||
openAddNewsModal.value = false
|
||||
getNews()
|
||||
}
|
||||
catch (error){
|
||||
console.log(error)
|
||||
ElMessage.error("发布新闻失败")
|
||||
}
|
||||
}
|
||||
|
||||
const update = async () => {
|
||||
console.log(userinfo.token)
|
||||
try{
|
||||
const response = await axios.post("/api/admin/update/news", {
|
||||
id: id.value,
|
||||
title: title.value,
|
||||
content: editor2.value.getContent(),
|
||||
}, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${userinfo.token}`,
|
||||
}
|
||||
})
|
||||
if (response.data.code !== 200) {
|
||||
ElMessage.error(response.data.message)
|
||||
return
|
||||
}
|
||||
ElMessage.success("更新新闻成功")
|
||||
openEditNewsModal.value = false
|
||||
getNews()
|
||||
}
|
||||
catch (error){
|
||||
console.log(error)
|
||||
ElMessage.error("更新新闻失败")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
page.value = 1
|
||||
getNews()
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
<template>
|
||||
<el-card>
|
||||
<template #header>
|
||||
<div class="flex justify-between items-center">
|
||||
<span>文章列表</span>
|
||||
<el-button type="primary">新增文章</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table :data="tableData" style="width: 100%">
|
||||
<el-table-column prop="p_name" label="项目名称" />
|
||||
<el-table-column prop="techstack" label="技术栈" />
|
||||
<el-table-column prop="p_status" label="项目状态" />
|
||||
<el-table-column label="操作">
|
||||
<template #default="scope">
|
||||
<el-button size="small">查看</el-button>
|
||||
<el-button size="small">编辑</el-button>
|
||||
<el-button size="small" type="danger">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { userInfoStore } from '@/store/store'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import axios from 'axios'
|
||||
|
||||
const userinfo = userInfoStore()
|
||||
|
||||
const page = ref(1)
|
||||
const pageSize = ref(5)
|
||||
const total = ref()
|
||||
|
||||
const tableData = ref([])
|
||||
|
||||
const getProject = async () => {
|
||||
try {
|
||||
const response = await axios.get("/api/admin/get/projects", {
|
||||
headers: {
|
||||
Authorization: "Bearer " + userinfo.token,
|
||||
},
|
||||
params: {
|
||||
current: page.value,
|
||||
size: pageSize.value
|
||||
}
|
||||
})
|
||||
if (!response.data.code === 200) {
|
||||
ElMessage.error(response.data.message)
|
||||
return
|
||||
}
|
||||
tableData.value = response.data.data.records
|
||||
total.value = response.data.data.total
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
ElMessage.error("获取文章失败")
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
page.value = 1
|
||||
getProject()
|
||||
})
|
||||
|
||||
</script>
|
||||
@@ -20,12 +20,12 @@
|
||||
</el-row>
|
||||
<el-row style="height: 60%;">
|
||||
<el-col :span="24" style="height: 100%;">
|
||||
<div class="news" v-for="item in news" @click="openDetails(item.a_id)">
|
||||
<div class="newspic">
|
||||
<div class="articles" v-for="item in articles" @click="openDetails(item)">
|
||||
<div class="articlespic">
|
||||
<img :src="item.pic" alt="芜湖" />
|
||||
</div>
|
||||
<div class="newscontent">
|
||||
<h2>{{ item.n_title }}</h2>
|
||||
<div class="articlescontent">
|
||||
<h2>{{ item.title }}</h2>
|
||||
<p class="date">{{ item.published }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -54,65 +54,18 @@ const search_text = ref('')
|
||||
|
||||
const pageSize = 5
|
||||
const page = 1
|
||||
const news = ref([
|
||||
{
|
||||
a_id: '1',
|
||||
n_title: '1',
|
||||
synopsis: '1',
|
||||
published: '1',
|
||||
pic: '1'
|
||||
},
|
||||
{
|
||||
a_id: '2',
|
||||
n_title: '2',
|
||||
synopsis: '2',
|
||||
published: '2',
|
||||
pic: '2'
|
||||
},
|
||||
{
|
||||
a_id: '3',
|
||||
n_title: '3',
|
||||
synopsis: '3',
|
||||
published: '3',
|
||||
pic: '3'
|
||||
},
|
||||
{
|
||||
a_id: '1',
|
||||
n_title: '1',
|
||||
synopsis: '1',
|
||||
published: '1',
|
||||
pic: '1'
|
||||
},
|
||||
{
|
||||
a_id: '2',
|
||||
n_title: '2',
|
||||
synopsis: '2',
|
||||
published: '2',
|
||||
pic: '2'
|
||||
},
|
||||
{
|
||||
a_id: '3',
|
||||
n_title: '3',
|
||||
synopsis: '3',
|
||||
published: '3',
|
||||
pic: '3'
|
||||
},
|
||||
const articles = ref([])
|
||||
|
||||
])
|
||||
|
||||
const getNews = async () => {
|
||||
const getArticles = async () => {
|
||||
try {
|
||||
const response = await axios.get('/api/blog/get/news', {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + userinfo.token
|
||||
},
|
||||
const response = await axios.get('/api/blog/get/articles', {
|
||||
params: {
|
||||
current: page,
|
||||
size: pageSize
|
||||
}
|
||||
})
|
||||
if (response.data.code === 200) {
|
||||
news.value = response.data.data.records
|
||||
articles.value = response.data.data.records
|
||||
} else {
|
||||
console.log(response.data.message)
|
||||
return
|
||||
@@ -124,31 +77,15 @@ const getNews = async () => {
|
||||
|
||||
}
|
||||
|
||||
const openDetails = async (a_id) => {
|
||||
// const response = await axios.get('/api/blog/get/article/' + a_id, {
|
||||
// headers: {
|
||||
// Authorization: 'Bearer ' + userinfo.token
|
||||
// }
|
||||
// })
|
||||
// if (!response.data.code === 200) {
|
||||
// console.log(response.data.message)
|
||||
// return
|
||||
// }
|
||||
// details.setViewDetails(response.data.data)
|
||||
details.setViewDetails({
|
||||
id: "1212",
|
||||
title: "12312",
|
||||
content: "231323",
|
||||
created: "123123",
|
||||
updated: "123132",
|
||||
})
|
||||
const openDetails = async (item) => {
|
||||
details.setViewDetails(item)
|
||||
router.push('viewDetails')
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
getNews()
|
||||
getArticles()
|
||||
|
||||
})
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
<!-- 用户登录、注册弹窗 -->
|
||||
<el-dialog title="用户登录" v-model="loginDialog" style="min-width: 400px; max-width: 500px;">
|
||||
<el-form :model="loginInfo" label-width="auto" style="width: 100%;" :rules="isadmin ? null : rules">
|
||||
<el-form-item label="账号or邮箱" prop="u_account">
|
||||
<el-input v-model="loginInfo.u_account"></el-input>
|
||||
<el-form-item label="账号or邮箱" prop="account">
|
||||
<el-input v-model="loginInfo.account"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="u_password">
|
||||
<el-input v-model="loginInfo.u_password" type="password"></el-input>
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="loginInfo.password" type="password"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="isadmin">管理员登录</el-checkbox>
|
||||
@@ -54,14 +54,14 @@
|
||||
|
||||
<el-dialog title="用户注册" v-model="registDialog" style="min-width: 400px; max-width: 500px;">
|
||||
<el-form ref="formRef" :model="loginInfo" label-width="auto" style="width: 100%;" :rules="rules">
|
||||
<el-form-item label="邮箱" prop="u_account">
|
||||
<el-input v-model="loginInfo.u_account"></el-input>
|
||||
<el-form-item label="邮箱" prop="account">
|
||||
<el-input v-model="loginInfo.account"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码" prop="u_password">
|
||||
<el-input v-model="loginInfo.u_password" type="password"></el-input>
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="loginInfo.password" type="password"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="确认密码" prop="u_password_confirm">
|
||||
<el-input v-model="loginInfo.u_password_confirm" type="password"></el-input>
|
||||
<el-form-item label="确认密码" prop="password_confirm">
|
||||
<el-input v-model="loginInfo.password_confirm" type="password"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="验证码" prop="code">
|
||||
<el-input v-model="loginInfo.code" style="width: 50%; margin-right: 10px" />
|
||||
@@ -81,7 +81,6 @@
|
||||
<script setup>
|
||||
import { reactive, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import SHA256 from 'crypto-js/sha256';
|
||||
import { userInfoStore } from '@/store/store';
|
||||
import { getUserInfo } from '@/function/user';
|
||||
import { ElMessage } from 'element-plus';
|
||||
@@ -103,9 +102,9 @@ const router = useRouter(); // 获取路由实例
|
||||
const formRef = ref(null); // 用于表单验证的引用
|
||||
|
||||
const loginInfo = reactive({
|
||||
u_account: '',
|
||||
u_password: '',
|
||||
u_password_confirm: '',
|
||||
account: '',
|
||||
password: '',
|
||||
password_confirm: '',
|
||||
code_id: '',
|
||||
code: ''
|
||||
})
|
||||
@@ -115,19 +114,19 @@ const countdown = ref(0);
|
||||
let timer = null;
|
||||
|
||||
const rules = reactive({
|
||||
u_account: [
|
||||
account: [
|
||||
{ required: true, message: '请输入邮箱', trigger: 'blur' },
|
||||
{ type: 'email', message: '请输入有效的邮箱地址', trigger: ['blur', 'change'] }
|
||||
],
|
||||
u_password: [
|
||||
password: [
|
||||
{ required: true, message: '请输入密码', trigger: 'blur' },
|
||||
{ min: 6, max: 20, message: '密码长度必须在6到20个字符之间', trigger: 'blur' }
|
||||
],
|
||||
u_password_confirm: [
|
||||
password_confirm: [
|
||||
{ required: true, message: '请确认密码', trigger: 'blur' },
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
if (value !== loginInfo.u_password) {
|
||||
if (value !== loginInfo.password) {
|
||||
callback(new Error('两次输入的密码不一致'));
|
||||
} else {
|
||||
callback();
|
||||
@@ -170,7 +169,7 @@ watch(route, () => {
|
||||
});
|
||||
|
||||
const blogLogin = () => {
|
||||
if (u_name.value == 'admin') {
|
||||
if (userinfo.user.role == 'admin') {
|
||||
const origin = window.location.origin
|
||||
const redirect_uri = `${origin}/admin`
|
||||
window.open(redirect_uri, '_blank')
|
||||
@@ -200,39 +199,38 @@ const submitForm = () => {
|
||||
}
|
||||
|
||||
const login = async () => {
|
||||
hashpassword.value = SHA256(loginInfo.u_password).toString();
|
||||
// console.log(hashpassword.value)
|
||||
if (isadmin.value) {
|
||||
const response = await axios.post('/api/admin/login', {
|
||||
u_account: loginInfo.u_account,
|
||||
u_password: hashpassword.value
|
||||
const response = await axios.post('/api/login', {
|
||||
account: loginInfo.account,
|
||||
password: loginInfo.password
|
||||
})
|
||||
if (!response.data.code == 200) {
|
||||
ElMessage.error(response.data.message)
|
||||
return
|
||||
} else if (response.data.data.role !== 'Admin') {
|
||||
} else if (response.data.data.role !== 'admin') {
|
||||
ElMessage.error('不是管理员,请联系站长')
|
||||
return
|
||||
} else {
|
||||
userinfo.token = response.data.data.token
|
||||
userinfo.user.u_account = loginInfo.u_account
|
||||
userinfo.user.account = loginInfo.account
|
||||
loginDialog.value = false;
|
||||
getUserInfo();
|
||||
u_name.value = userinfo.user.u_name
|
||||
userinfo.user.name = response.data.data.userInfo.name
|
||||
userinfo.user.role = response.data.data.role
|
||||
u_name.value = userinfo.user.name
|
||||
const origin = window.location.origin
|
||||
const redirect_uri = `${origin}/admin`
|
||||
window.open(redirect_uri, '_blank')
|
||||
}
|
||||
} else {
|
||||
const response = await axios.post('/api/login', {
|
||||
u_account: loginInfo.u_account,
|
||||
u_password: hashpassword.value
|
||||
account: loginInfo.account,
|
||||
password: loginInfo.password
|
||||
}).then((response) => {
|
||||
console.log(response.data);
|
||||
if (response.data.code == 200) {
|
||||
userinfo.token = response.data.data.token;
|
||||
getUserInfo();
|
||||
u_name.value = response.data.u_name;
|
||||
userinfo.user.name = response.data.data.userInfo.name
|
||||
u_name.value = userinfo.user.name
|
||||
loginDialog.value = false;
|
||||
ElMessage.success('登录成功');
|
||||
} else {
|
||||
@@ -262,7 +260,7 @@ const getCode = async () => {
|
||||
if (countdown.value > 0) return
|
||||
|
||||
// 此处调用你的发送验证码接口逻辑
|
||||
// 例如 axios.post('/api/code', { email: loginInfo.value.u_account })
|
||||
// 例如 axios.post('/api/code', { email: loginInfo.value.account })
|
||||
|
||||
// 成功后开始倒计时
|
||||
startCountdown()
|
||||
@@ -358,8 +356,8 @@ const getCode = async () => {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
/* .login-btn {
|
||||
display: none;
|
||||
}
|
||||
} */
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,19 @@
|
||||
<template>
|
||||
<div>me</div>
|
||||
<el-buton type="primary" @click="logout">
|
||||
退出登录
|
||||
</el-buton>
|
||||
</template>
|
||||
<script>
|
||||
<script setup>
|
||||
import {userInfoStore} from "@/store/store";
|
||||
|
||||
const userinfo = userInfoStore();
|
||||
|
||||
const logout = () => {
|
||||
userinfo.clearUserInfo();
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
</script>
|
||||
<style>
|
||||
</style>
|
||||
@@ -20,12 +20,12 @@
|
||||
</el-row>
|
||||
<el-row style="height: 60%;">
|
||||
<el-col :span="24" style="height: 100%;">
|
||||
<div class="news" v-for="item in news" @click="openDetails(item.a_id)">
|
||||
<div class="news" v-for="item in news" @click="openDetails(item)">
|
||||
<div class="newspic">
|
||||
<img :src="item.pic" alt="芜湖" />
|
||||
</div>
|
||||
<div class="newscontent">
|
||||
<h2>{{ item.n_title }}</h2>
|
||||
<h2>{{ item.title }}</h2>
|
||||
<p class="date">{{ item.published }}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -67,51 +67,7 @@ const search_text = ref('')
|
||||
|
||||
const pageSize = 5
|
||||
const page = 1
|
||||
const news = ref([
|
||||
{
|
||||
a_id: '1',
|
||||
n_title: '1',
|
||||
synopsis: '1',
|
||||
published: '1',
|
||||
pic: '1'
|
||||
},
|
||||
{
|
||||
a_id: '2',
|
||||
n_title: '2',
|
||||
synopsis: '2',
|
||||
published: '2',
|
||||
pic: '2'
|
||||
},
|
||||
{
|
||||
a_id: '3',
|
||||
n_title: '3',
|
||||
synopsis: '3',
|
||||
published: '3',
|
||||
pic: '3'
|
||||
},
|
||||
{
|
||||
a_id: '1',
|
||||
n_title: '1',
|
||||
synopsis: '1',
|
||||
published: '1',
|
||||
pic: '1'
|
||||
},
|
||||
{
|
||||
a_id: '2',
|
||||
n_title: '2',
|
||||
synopsis: '2',
|
||||
published: '2',
|
||||
pic: '2'
|
||||
},
|
||||
{
|
||||
a_id: '3',
|
||||
n_title: '3',
|
||||
synopsis: '3',
|
||||
published: '3',
|
||||
pic: '3'
|
||||
},
|
||||
|
||||
])
|
||||
const news = ref([])
|
||||
|
||||
const dialogWidth = computed(() => {
|
||||
return window.innerWidth < 768 ? '90%' : '60%'
|
||||
@@ -121,7 +77,6 @@ const getNews = async () => {
|
||||
try {
|
||||
const response = await axios.get('/api/blog/get/news', {
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + userinfo.token
|
||||
},
|
||||
params: {
|
||||
current: page,
|
||||
@@ -141,24 +96,8 @@ const getNews = async () => {
|
||||
|
||||
}
|
||||
|
||||
const openDetails = async (a_id) => {
|
||||
// const response = await axios.get('/api/blog/get/article/' + a_id, {
|
||||
// headers: {
|
||||
// Authorization: 'Bearer ' + userinfo.token
|
||||
// }
|
||||
// })
|
||||
// if (!response.data.code === 200) {
|
||||
// console.log(response.data.message)
|
||||
// return
|
||||
// }
|
||||
// details.setViewDetails(response.data.data)
|
||||
details.setViewDetails({
|
||||
id: "1212",
|
||||
title: "12312",
|
||||
content: "231323",
|
||||
created: "123123",
|
||||
updated: "123132",
|
||||
})
|
||||
const openDetails = async (item) => {
|
||||
details.setViewDetails(item)
|
||||
router.push('viewDetails')
|
||||
}
|
||||
|
||||
@@ -166,7 +105,6 @@ const openDetails = async (a_id) => {
|
||||
|
||||
onMounted(() => {
|
||||
getNews()
|
||||
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<h1>{{ details.detail.title }}</h1>
|
||||
<p style="padding: 20px;">发布时间:{{ details.detail.created }}---更新时间:{{
|
||||
details.detail.updated }}</p>
|
||||
<p style="padding: 20px;">发布时间: {{ details.detail.published }}</p>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
@@ -17,7 +16,6 @@
|
||||
<div style="width: 100%;">
|
||||
<div v-html="Content" class="markdown-body"></div>
|
||||
</div>
|
||||
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user