From 978356a713d410e6be4e9f241f7a5ebc82e41aaa Mon Sep 17 00:00:00 2001 From: simple321vip Date: Sat, 26 Nov 2022 20:58:49 +0800 Subject: [PATCH] =?UTF-8?q?wiki=E4=BF=9D=E5=AD=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mock/blogView.ts | 44 ++++++++++++++++++++++++++++++++++ src/components/login/login.vue | 26 ++++---------------- src/const/config.ts | 30 ++++++++++++++++++++--- src/view/blog/createBlog.vue | 44 ++++++++++++++++------------------ 4 files changed, 96 insertions(+), 48 deletions(-) create mode 100644 mock/blogView.ts diff --git a/mock/blogView.ts b/mock/blogView.ts new file mode 100644 index 0000000..c5ae00c --- /dev/null +++ b/mock/blogView.ts @@ -0,0 +1,44 @@ +import { MockMethod } from 'vite-plugin-mock' + +export default [ + { + url: '/auth/api/v1/reader/blogs', + method: 'get', + response: () => { + return [ + { + bid: "string", + btId: "string", + btName: "string", + title: "string", + blog_prex: "string", + content: "string" + }, + { + bid: "string", + btId: "string", + btName: "string", + title: "string", + blog_prex: "string", + content: "string" + }, + ] + } + }, + { + url: '/auth/api/v1/reader/blog_type', + method: 'get', + response: () => { + return [ + { + btId: "string", + btName: "string", + }, + { + btId: "string", + btName: "string", + }, + ] + } + }, +] as MockMethod[] \ No newline at end of file diff --git a/src/components/login/login.vue b/src/components/login/login.vue index 66dbdf2..3ee30b5 100644 --- a/src/components/login/login.vue +++ b/src/components/login/login.vue @@ -8,21 +8,11 @@

秘密基地

- -

百度网盘扫码登陆请使用微信扫一扫登录

- - - +
+ +
- 其他登录方式 - + 其他登录方式暂时还没有哦 ------------------------------------------------------------ @@ -39,7 +29,7 @@ import type { FormInstance } from 'element-plus' import { tenantStore } from '../../store/tenant' import router from '../../router' import baiduCloudImage from "../../assets/baiducloud.png" -import config from '../../const/config' +import { config, scan } from '../../const/config' let qrcode = config.BAIDU_CLOUD_URL + config.RESPONSE_TYPE + config.CLIENT_ID + config.REDIRECT_URI + config.SCOPE + config.DEVICE_ID + config.QR_CODE + config.DISPLAY @@ -104,12 +94,6 @@ style.width = window.innerWidth * 0.7 + 'px' padding: 18px 0; } -.box-card { - - /* top: 50%; - left: 50%; */ -} - .yuliu { /* width: 600px; */ height: 600px; diff --git a/src/const/config.ts b/src/const/config.ts index dff62e4..b4b8b85 100644 --- a/src/const/config.ts +++ b/src/const/config.ts @@ -1,4 +1,5 @@ -import { type } from "os"; +import router from '../router' +import { setToken, setTenant } from '../utils/auth' // config/index.js const env = process.env.NODE_ENV!; @@ -34,6 +35,29 @@ const configObj: any = { QR_CODE: '&qrcode=' + '1', DISPLAY: '&display=popup' }, -}; +} -export default { ...configObj[env] }; +const scan_method: any = { + production: (qrcode: string) => { + window.location.href = qrcode + }, + development: () => { + setToken("token") + setTenant( + { + tenantId: "111" + } + ) + router.push({ + path: '/home' + }) + }, + test: (qrcode: string) => { + window.location.href = qrcode + }, +} + +const scan = scan_method[env] +const config = configObj[env] + +export { scan, config } diff --git a/src/view/blog/createBlog.vue b/src/view/blog/createBlog.vue index e89bd9e..f664ce9 100644 --- a/src/view/blog/createBlog.vue +++ b/src/view/blog/createBlog.vue @@ -66,8 +66,8 @@
- 已保存 - 更新中 +
@@ -165,8 +165,6 @@ let checkedIndex = ref(0) let checkedBlogIndex = ref(0) let isclicked = ref(false) let isReady = ref(false) -let updated = ref(false) -let startTime = reactive($moment()); // tmp btName for create, edit, delete let btName = ref("") let deleteBtName = ref("") @@ -232,18 +230,23 @@ const getTestData = async () => { * 获取上一次修改时间,startTime * */ - watch(current_blog, (newVal, oldVal) => { - - let current = $moment() // 获取当前时间,current 09:00:00 09:00:00.500 - const tmp = startTime // 获取开始时间,将值赋给tmp 8:30:00 09:00:00 - startTime = current // 更新开始时间为当前 09:00:00 09:00:00.500 - setTimeout(() => { - if ($moment(current).diff($moment(tmp), 'seconds') >= 1) { - saveContent() + let old_blog = { + bid: current_blog.bid, + content: current_blog.content, + } + setInterval(async () => { + if (current_blog.bid == old_blog.bid) { + if (old_blog.content == current_blog.content) { + return } - }, 1000) - updated.value = false - }) + await saveContent().then(() => { + old_blog.content = current_blog.content + }) + } else { + old_blog.bid = current_blog.bid + old_blog.content = current_blog.content + } + }, 5000) } /** @@ -254,7 +257,6 @@ const onclickTypeTab = (order: number) => { const bid = blogTypes[order].blogs[0].bid deleteBtName.value = "" getContent(bid).then(response => { - updated.value = true blogTypes[order].blogs[0].content = response.data.content checkedBlogIndex.value = order checkedIndex.value = 0 @@ -268,7 +270,6 @@ const onclickBlogTab = (blog: Blog) => { checkedIndex.value = blog.order blogTypes[checkedBlogIndex.value].blogs[checkedIndex.value].content = response.data.content copy(current_blog, blog) - updated.value = true }).catch(() => { checkedIndex.value = blog.order }) @@ -277,18 +278,13 @@ const onclickBlogTab = (blog: Blog) => { /** * Blog内容修正 */ -const saveContent = () => { - updated.value = true +const saveContent = async () => { const query = { bid: current_blog.bid, content: current_blog.content } updateContent(query).then(() => { - ElMessage({ - message: h('p', null, [ - h('i', { style: 'color: teal' }, "文章保存成功"), - ]), - }) + }).catch(() => { ElMessage({ message: h('p', null, [