Skip to content

Commit

Permalink
Merge branch 'dev' and release 1.0.8(20221126)
Browse files Browse the repository at this point in the history
  • Loading branch information
chihuo2104 committed Nov 26, 2022
2 parents 01a51e6 + ceb9f3a commit 295eec1
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chiblog",
"version": "1.0.7",
"version": "1.0.8",
"private": true,
"author": "chihuo2104<[email protected]>",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"settings": "mock.json",
"settings": "mock.1.0.8.json",
"model": "mocks"
}
1 change: 1 addition & 0 deletions public/mock.1.0.8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"status":200,"data":{"posts":[{"id":2,"title":"Hello World","path":"hello-world","name":"hello-world","time":1900000000,"updtime":1957027880,"author":"admin","content":"Hello World!","china":false,"comment":true},{"id":1,"title":"你处于mock模式!","path":"default","name":"default","time":1657027436,"updtime":1657027880,"author":"admin","content":"# 可能是网络问题!","china":true,"comment":false},{"id":5,"title":"排版测试","path":"paiban","name":"paiban1","time":122,"updtime":1663,"author":"mm","content":"# chiblog123\n## chiblog1234\n### test123\n\n*嘿嘿 喵喵*\n\n~~sci:其实我很会assign人的~~\n\n<https://github.com/scientificworld>\n\n**图片测试**\n\n![chiimg](https://ttfou.com/images/2022/09/09/60e9b0235f60e89df07a4c7a801af7c4.png)\n\n[喵~](https://github.com/scientificworld)\n\n> 猫猫:玩mc\n> sci:玩fxtz和mc\n\n```import sci from 'scitools'```\n\n`scientificworld`\n\n| sci | mzw |\n|-----|-----|\n|a |bbb |","china":true,"comment":true,"desc":"摘要测试qwqwqwqwqwq","category":"test","tags":["test","html","css"]},{"id":4,"title":"你好,世界!","path":"hello-world","name":"hello-world","time":0,"updtime":0,"author":"chiblog","content":"当你看到这一段文字的时候,你的chiblog已经可以正常运行,恭喜!","china":true,"comment":false}],"settings":{"site":{"title":"您已离线","baseurl":"https://offline","comment":{"enabled":true,"commiturl":"http://127.0.0.1:8787/","avatar":{"type":"gravatar","cacheurl":"//g.chicdn.cn/avatar/","ghcacheurl":"//ghavatar.chicdn.cn/u/","d":"monsterid"},"ghauth":{"enabled":true,"client_id":"204a53c84ec3ff5e5a82","client_secret":"f29752d306876dc5d7959f8da8a37386ea3e3adf","proxy_url":"https://ghproxy.moekonnyaku.workers.dev/"},"backend":{"enabled":true,"type":"workers","url":"http://127.0.0.1:8787/"}},"footer":"","announcement":"","author":{"name":"chihuo2104","url":"https://im.chihuo2104.dev/"},"copyright":{"startyear":2018},"customjs":{"enabled":false,"type":"script","script":"alert('Hi!')"},"showstats":false,"showcopyright":false,"debug":false}},"comments":[{"id":1,"email":"[email protected]","name":"某位不知名的好心人","site":"https://offline","content":"当你看到我的时候,你就已经离线了!","to":1,"reply":-1,"time":1657100000}],"pages":[{"id":1,"type":"link","url":"https://im.chihuo2104.dev","title":"关于","name":"about","target":"_blank"},{"id":2,"type":"article","title":"友人帐","name":"friends","content":"# test123......\n# chiblog123\n## chiblog1234\n### test123\n\n*嘿嘿 喵喵*\n\n~~sci:其实我很会assign人的~~\n\n<https://github.com/scientificworld>\n\n**图片测试**\n\n![chiimg](https://ttfou.com/images/2022/09/09/60e9b0235f60e89df07a4c7a801af7c4.png)\n\n[喵~](https://github.com/scientificworld)\n\n> 猫猫:玩mc\n> sci:玩fxtz和mc\n\n```import sci from 'scitools'```\n\n`scientificworld`\n\n| sci | mzw |\n|-----|-----|\n|a |bbb |"}],"createVersion":"1.0.8"}}
84 changes: 79 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ const bTime = ref(0)
const sTime = ref((new Date().getTime()))
// console.log(sTime)
const s = ref('')
const isDifferentVersion = ref(false)
const versionDifference = ref('')
const dataFileVersionInfo = ref({})
const versionSupported = ref(false)
const isMockMode = ref(true)
// check ip address
axios.get('https://api.ip.sb/geoip?t=' + new Date().getTime())
.then((res) => {
Expand All @@ -41,7 +49,7 @@ onBeforeMount(async () => {
bTime.value = (new Date()).getTime()
// console.log(bTime)
try {
confdata = (await axios.get('config.json?t=' + new Date())).data
confdata = (await axios.get('config.json?t=' + new Date().getTime())).data
$store.commit('updmodel', confdata.model)
} catch (e) {
console.error(e)
Expand Down Expand Up @@ -112,6 +120,32 @@ watch(() => $store.state.model, async () => {
$store.commit('updall', res.data.data)
settings.value = res.data.data.settings
pages.value = res.data.data.pages
dataFileVersionInfo.value = {
createVersion: res.data.createVersion,
createVersionDate: res.data.createVersionDate
}
if (res.data.data.createVersion === undefined && res.data.data.createVersionDate === undefined) {
isDifferentVersion.value = true
const ver = 20220924
dataFileVersionInfo.value = {
createVersion: '1.0.7',
createVersionDate: 20220924
}
// version 1.0.8(20221126) and later will write the version into json file.
if (ver < version.versionReleaseDate) {
versionDifference.value = 'old'
}
} else {
if (res.data.data.createVersionDate < version.versionReleaseDate) {
versionDifference.value = 'old'
if (res.data.data.createVersionDate < version.supportVersionDate) {
versionSupported.value = true
}
} else if (res.data.data.createVersionDate > version.versionRelease) {
versionDifference.value = 'new'
}
}
isMockMode.value = false
await configureComments(res)
// console.log(pages.value, settings.value)
} catch (e) {
Expand All @@ -121,6 +155,24 @@ watch(() => $store.state.model, async () => {
} else {
settings.value = setting
pages.value = page
// initial your application here.
// check version accessbility.
if (settings.value.site.customjs.enabled) {
console.log('customjs!')
const element = document.createElement('script')
if (settings.value.site.customjs.type === 'script') {
element.textContent = settings.value.site.customjs.script
document.head.appendChild(element)
} else {
element.src = settings.value.site.customjs.script
document.head.appendChild(element)
}
// expermental
// if (settings.value.site.debug !== true) {
// console.log(settings.value.site.debug)
// window.console.log = () => {}
// }
}
await configureComments({ data: { data: { settings: settings, comments: {} } } })
// console.log(settings, pages)
}
Expand All @@ -130,6 +182,7 @@ function changePagesShowData () {
showLinks.value = !(showLinks.value)
}
// console.log(confdata)
</script>
<template>
<div id="indexapp">
Expand Down Expand Up @@ -165,13 +218,34 @@ function changePagesShowData () {
<!-- <h2><button id="open-toolbar" @click="this.isToolOpen = !(this.isToolOpen)"><h2><span v-if="!isToolOpen">打开工具箱</span><span v-if="isToolOpen">关闭工具箱</span></h2></button></h2> -->
<!-- <Toolbar v-if="isToolOpen" id="toolbar"></Toolbar> -->
<div id="viewer">
<div id="datatip" v-if="versionDifference !== ''">
数据文件过时提醒:<br/>
尽管本版本最低支持{{version.supportVersion}}({{version.supportVersionDate}}),
但是您的数据文件所用的版本为
{{(dataFileVersionInfo.createVersionDate === 20220924)?'v1.0.7(20220924)':dataFileVersionInfo.createVersion}}
({{(dataFileVersionInfo.createVersionDate === 20220924)?'或更早':dataFileVersionInfo.createVersionDate}}),过于{{(versionDifference === 'old')?'老旧':''}}
{{(versionSupported === false)?'且并不受目前版本支持':''}},可能会产生数据无法正常读取或无法使用新版本功能的错误。<br/>
如果你是这个博客的管理员,请更新你的数据文件。<br/>
如果您是访客,请联系管理员。<br/>
数据正常即可关闭此提示。
</div>
<div v-if="isMockMode === true">
提示:您正在使用mock模式!<br/>
如果您在正常情况下看到本页面,那就可能说明您的网络连接已经断开或无法获取数据文件。<br/>
如果您的网络正常,请联系管理员。<br/>
数据文件转存地址:#/mock2get/ 打开Devtools即可发现
</div>
<router-view/>
<hr/>
<div id="footer">本页面由<a :href="settings.site.author.url" target="_blank">{{settings.site.author.name}}</a>进行维护。版权所有&copy;{{settings.site.copyright.startyear}}-{{ new Date().getFullYear() }}。
<br/>页面生成于{{ s }},最后渲染于{{(new Date()).toLocaleString()}}。加载&nbsp;{{ loadTime }}ms&nbsp;渲染&nbsp;{{ renderTime }}ms
<br/>Powered by <a href="https://chiblog.apps.chihuo2104.dev/" target="_blank">chiblog</a>@{{version.version}}({{version.versionReleaseDate}}) based on <a href="https://vuejs.org" target="_blank">Vue</a>.
<div id="footer">
<div id="cpr" v-show="settings.site.showcopyright">本页面由<a :href="settings.site.author.url" target="_blank">{{settings.site.author.name}}</a>进行维护。版权所有&copy;{{settings.site.copyright.startyear}}-{{ new Date().getFullYear() }}。</div>
<div v-show="settings.site.showstats">页面生成于{{ s }},最后渲染于{{(new Date()).toLocaleString()}}。加载&nbsp;{{ loadTime }}ms&nbsp;渲染&nbsp;{{ renderTime }}ms</div>
<div>
Powered by
<a href="https://chiblog.apps.chihuo2104.dev/" target="_blank">chiblog</a>@{{version.version}}({{version.versionReleaseDate}}) based on <a href="https://vuejs.org" target="_blank">Vue</a>.
</div>
<div v-html="settings.site.footer"></div>
</div>
<div v-html="settings.site.footer"></div>
</div>
</div>
</template>
Expand Down
10 changes: 9 additions & 1 deletion src/mocks/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ export default {
},
copyright: {
startyear: 2018
}
},
customjs: {
enabled: false,
type: 'script', // script or url
script: 'alert(\'Hi!\')'
},
showstats: false,
showcopyright: false,
debug: false
}
}
9 changes: 5 additions & 4 deletions src/version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export default {
version: '1.0.7',
versionReleaseDate: '20220924',
versionDisplay: '1.0.7(20220924)',
supportVersion: '20220924'
version: '1.0.8',
versionReleaseDate: '20221126',
versionDisplay: '1.0.8(20221126)',
supportVersionDate: '20220924',
supportVersion: '1.0.7'
}
2 changes: 1 addition & 1 deletion src/views/ArticleList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if ($store.state.model === 'production') {
settings.value = mocksettings
comments.value = mockcomments
}
console.log(posts.value)
// console.log(posts.value)
posts.value.sort((a, b) => {
if (a.updtime > b.updtime) return -1
else if (a.updtime < b.updtime) return 1
Expand Down
3 changes: 2 additions & 1 deletion src/views/mock2get.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import settings from '@/mocks/settings'
import posts from '@/mocks/posts'
import pages from '@/mocks/pages'
import { useStore } from 'vuex'
import version from '@/version'
const $store = useStore()
Expand All @@ -13,7 +14,7 @@ if ($store.state.model === 'production') {
if ($store.state.model === 'mocks') {
console.log('You can use this mock data write in a json file and then deploy into a static file server and then you can use a static blog~')
console.log('Enjoy it ;)')
console.log(JSON.stringify({ status: 200, data: { posts, settings, comments, pages } }))
console.log(JSON.stringify({ status: 200, data: { posts, settings, comments, pages, createVersion: version.version, createVersionDate: version.versionDate, lastUpdate: (Math.floor(new Date().getTime() / 1000)) } }))
}
</script>
<template>
Expand Down

0 comments on commit 295eec1

Please sign in to comment.