add profile function
This commit is contained in:
@@ -0,0 +1,55 @@
|
|||||||
|
import { service } from '../utils/request'
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
'Content-Type': 'application/json;charsetset=UTF-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
const create_profile = (data: Object) => {
|
||||||
|
return service({
|
||||||
|
url: '/wiki/api/v1/author/profile',
|
||||||
|
method: 'POST',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const update_profile = (data: Object) => {
|
||||||
|
return service({
|
||||||
|
url: '/wiki/api/v1/author/profile',
|
||||||
|
method: 'PUT',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const get_profile = () => {
|
||||||
|
return service({
|
||||||
|
url: '/wiki/api/v1/author/profile',
|
||||||
|
method: 'GET',
|
||||||
|
headers: headers
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const get_profileName = () => {
|
||||||
|
return service({
|
||||||
|
url: '/wiki/api/v1/author/profile/name',
|
||||||
|
method: 'GET',
|
||||||
|
headers: headers
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const judge_profile = (data: Object) => {
|
||||||
|
return service({
|
||||||
|
url: '/wiki/api/v1/author/profile/judge',
|
||||||
|
method: 'POST',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export {
|
||||||
|
create_profile,
|
||||||
|
get_profile,
|
||||||
|
update_profile,
|
||||||
|
get_profileName,
|
||||||
|
judge_profile
|
||||||
|
}
|
||||||
@@ -22,6 +22,9 @@ router.beforeEach((to, from, next) => {
|
|||||||
if (url.search("write") != -1) {
|
if (url.search("write") != -1) {
|
||||||
next('/BlogEditer')
|
next('/BlogEditer')
|
||||||
}
|
}
|
||||||
|
if (url.search("profile") != -1) {
|
||||||
|
next('/ProfileEditer')
|
||||||
|
}
|
||||||
if (url.search("view") != -1) {
|
if (url.search("view") != -1) {
|
||||||
let arr = url.split('?')
|
let arr = url.split('?')
|
||||||
let bid = arr[1].split('=')[1]
|
let bid = arr[1].split('=')[1]
|
||||||
|
|||||||
@@ -95,6 +95,10 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
path: "/BlogEditer",
|
path: "/BlogEditer",
|
||||||
component: () => import('@/view/blog/createBlog.vue'),
|
component: () => import('@/view/blog/createBlog.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/ProfileEditer",
|
||||||
|
component: () => import('@/view/dashboard/editProfile.vue'),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/BlogViewer",
|
path: "/BlogViewer",
|
||||||
component: () => import('@/view/blog/mdview.vue'),
|
component: () => import('@/view/blog/mdview.vue'),
|
||||||
|
|||||||
@@ -7,13 +7,15 @@ export const settingsStore = defineStore('settings', () => {
|
|||||||
sideMode: '#191a23',
|
sideMode: '#191a23',
|
||||||
isMobile: false,
|
isMobile: false,
|
||||||
isRouterAlive: true,
|
isRouterAlive: true,
|
||||||
isLoading: false
|
isLoading: false,
|
||||||
|
profileName: null,
|
||||||
})
|
})
|
||||||
|
|
||||||
const sideMode = computed(() => settings.value.sideMode)
|
const sideMode = computed(() => settings.value.sideMode)
|
||||||
const isMobile = computed(() => settings.value.isMobile)
|
const isMobile = computed(() => settings.value.isMobile)
|
||||||
const isRouterAlive = computed(() => settings.value.isRouterAlive)
|
const isRouterAlive = computed(() => settings.value.isRouterAlive)
|
||||||
const isLoading = computed(() => settings.value.isLoading)
|
const isLoading = computed(() => settings.value.isLoading)
|
||||||
|
const profileName = computed(() => settings.value.profileName)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
settings,
|
settings,
|
||||||
@@ -21,6 +23,7 @@ export const settingsStore = defineStore('settings', () => {
|
|||||||
isMobile,
|
isMobile,
|
||||||
isRouterAlive,
|
isRouterAlive,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
profileName,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<template>
|
||||||
|
<md-editor v-model="content" @save="onUpdateContent" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import MdEditor from 'md-editor-v3';
|
||||||
|
import 'md-editor-v3/lib/style.css';
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useRoute } from 'vue-router'
|
||||||
|
import {
|
||||||
|
get_profile,
|
||||||
|
update_profile
|
||||||
|
} from '../../api/profile'
|
||||||
|
|
||||||
|
|
||||||
|
let content = ref<string>('')
|
||||||
|
let lastUpdateDatetime = ref<string>('')
|
||||||
|
const route = useRoute()
|
||||||
|
const params = route.query
|
||||||
|
|
||||||
|
|
||||||
|
const onUpdateContent = async () => {
|
||||||
|
await update_profile({ content: content.value }).then(resp => {
|
||||||
|
lastUpdateDatetime.value = resp.data.updateDatetime
|
||||||
|
}).catch(() => {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const onGetProfile = async () => {
|
||||||
|
await get_profile().then(resp => {
|
||||||
|
content.value = resp.data.content
|
||||||
|
lastUpdateDatetime.value = resp.data.updateDatetime
|
||||||
|
}).catch(() => {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onGetProfile()
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
@@ -97,26 +97,61 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- create blogtype dialog -->
|
||||||
|
<el-dialog v-model="profileNameCreateDialogVisible" title="发现主人还没有创建新的wiki个人主页, 来创建吧" width="30%"
|
||||||
|
@close="onCloseProfileDialog">
|
||||||
|
Profile name:
|
||||||
|
<el-autocomplete v-model="profileName" :fetch-suggestions="querySearchAsync" />
|
||||||
|
<el-input v-model="profileName">
|
||||||
|
</el-input>
|
||||||
|
<el-descriptions title="你的 wiki 主页将为">
|
||||||
|
<el-icon>
|
||||||
|
<Link />
|
||||||
|
</el-icon>
|
||||||
|
<el-descriptions-item>https://www.violin-home.cn/docs#/{{ profileName ? profileName : profileNameText
|
||||||
|
}}/</el-descriptions-item>
|
||||||
|
<!-- <el-descriptions-item label="Remarks">
|
||||||
|
<el-tag size="small">School</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="Address">No.1188, Wuzhong Avenue, Wuzhong District, Suzhou, Jiangsu
|
||||||
|
Province</el-descriptions-item> -->
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="onCloseProfileDialog">取消</el-button>
|
||||||
|
<el-button type="primary" @click="onCreateProfile">确认</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import $moment from "moment"
|
import $moment from "moment"
|
||||||
|
import { Link } from "@element-plus/icons-vue"
|
||||||
import EchartsLine from '@/view/dashboard/dashboardCharts/index.vue'
|
import EchartsLine from '@/view/dashboard/dashboardCharts/index.vue'
|
||||||
import DashboardTable from '@/view/dashboard/dashboardTable/index.vue'
|
import DashboardTable from '@/view/dashboard/dashboardTable/index.vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useWeatherInfo } from '@/service/weather'
|
import { useWeatherInfo } from '@/service/weather'
|
||||||
import { countWiki } from "@/api/blog"
|
import { countWiki } from "@/api/blog"
|
||||||
import { bookmarks_count } from "@/api/bookmark"
|
import { bookmarks_count } from "@/api/bookmark"
|
||||||
|
import { get_profileName, create_profile, judge_profile } from "@/api/profile"
|
||||||
|
import { settingsStore } from "@/store/modules/settings"
|
||||||
|
|
||||||
// -- IMPORT --
|
// -- IMPORT --
|
||||||
const weatherInfo = useWeatherInfo()
|
const weatherInfo = useWeatherInfo()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const useSettingsStore = settingsStore()
|
||||||
|
|
||||||
// -- REACTIVE OBJECT --
|
// -- REACTIVE OBJECT --
|
||||||
|
|
||||||
// -- REF OBJECT --
|
// -- REF OBJECT --
|
||||||
let time = ref<String>($moment().format("YYYY年MM月DD日 HH:mm:ss"));
|
let time = ref<String>($moment().format("YYYY年MM月DD日 HH:mm:ss"));
|
||||||
|
const profileNameCreateDialogVisible = ref(false)
|
||||||
|
const profileName = ref<string>()
|
||||||
|
const profileNameText = ref<string>("{Profile name}")
|
||||||
|
|
||||||
const statistics = ref({
|
const statistics = ref({
|
||||||
wiki_count: 0,
|
wiki_count: 0,
|
||||||
@@ -153,9 +188,9 @@ const toolCards = ref([
|
|||||||
bg: 'rgba(255, 214, 102,.3)'
|
bg: 'rgba(255, 214, 102,.3)'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '表单生成器',
|
label: 'wiki主页编辑',
|
||||||
icon: 'document-checked',
|
icon: 'document-checked',
|
||||||
name: 'formCreate',
|
name: 'profile',
|
||||||
color: '#ff85c0',
|
color: '#ff85c0',
|
||||||
bg: 'rgba(255, 133, 192,.3)'
|
bg: 'rgba(255, 133, 192,.3)'
|
||||||
},
|
},
|
||||||
@@ -185,9 +220,50 @@ const toTarget = (name: string) => {
|
|||||||
case 'scrum':
|
case 'scrum':
|
||||||
window.open('https://www.leangoo.com/kanban/board_list?#/home/list', '_blank')
|
window.open('https://www.leangoo.com/kanban/board_list?#/home/list', '_blank')
|
||||||
break;
|
break;
|
||||||
|
case 'profile':
|
||||||
|
if (useSettingsStore.settings.profileName) {
|
||||||
|
openTag()
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
profileNameCreateDialogVisible.value = true
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onCreateProfile = async () => {
|
||||||
|
|
||||||
|
if (!profileName.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await create_profile({ name: profileName.value }).then(() => {
|
||||||
|
openTag()
|
||||||
|
}).finally(() => {
|
||||||
|
profileNameCreateDialogVisible.value = false
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const openTag = () => {
|
||||||
|
const { href } = router.resolve({
|
||||||
|
path: '/profile/'
|
||||||
|
})
|
||||||
|
window.open(href, '_blank')
|
||||||
|
}
|
||||||
|
|
||||||
|
const querySearchAsync = async (queryString: string, cb: any) => {
|
||||||
|
judge_profile({ name: profileName.value }).then(() => {
|
||||||
|
|
||||||
|
}).then(e => {
|
||||||
|
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const onCloseProfileDialog = () => {
|
||||||
|
profileName.value = ""
|
||||||
|
profileNameCreateDialogVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AUTO INVOKE FUNCTION
|
* AUTO INVOKE FUNCTION
|
||||||
*/
|
*/
|
||||||
@@ -203,6 +279,11 @@ bookmarks_count().then((resp) => {
|
|||||||
const data = resp.data
|
const data = resp.data
|
||||||
statistics.value.bookmark_count = data.count
|
statistics.value.bookmark_count = data.count
|
||||||
})
|
})
|
||||||
|
get_profileName().then((resp) => {
|
||||||
|
if (resp.data) {
|
||||||
|
useSettingsStore.settings.profileName = resp.data.name
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user