deploy to gcloud
This commit is contained in:
1 parent
e4e364ae2a
commit
4b7252c15f
12 files changed
+190
-121
No files matched your search
@@ -9,7 +9,6 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component } from 'nuxt-property-decorator'
|
||||
import { api } from '~/assets/global'
|
||||
|
||||
@Component<BlogPage>({
|
||||
watch: {
|
||||
@@ -17,18 +16,13 @@ import { api } from '~/assets/global'
|
||||
'$route.query.page': '$fetch',
|
||||
},
|
||||
async fetch() {
|
||||
const { result, count, error } = await api('/api/q', {
|
||||
const { result, count } = await this.$axios.$get('/api/q', {
|
||||
params: {
|
||||
q: this.$route.query.q,
|
||||
page: this.$route.query.page,
|
||||
},
|
||||
})
|
||||
|
||||
if (error) {
|
||||
this.$nuxt.error(error)
|
||||
return
|
||||
}
|
||||
|
||||
this.posts = result
|
||||
this.count = count
|
||||
},
|
||||
|
||||
@@ -47,36 +47,22 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component } from 'nuxt-property-decorator'
|
||||
import { api, THEME } from '~/assets/global'
|
||||
import { Vue, Component, Watch } from 'nuxt-property-decorator'
|
||||
import { THEME } from '~/assets/global'
|
||||
import '~/assets/remark42'
|
||||
|
||||
@Component<PostPage>({
|
||||
async fetch() {
|
||||
const r = await api('/api', {
|
||||
const r = await this.$axios.$get('/api', {
|
||||
params: {
|
||||
path: this.$route.params.pathMatch,
|
||||
},
|
||||
})
|
||||
|
||||
if (r.error) {
|
||||
this.$nuxt.error(r.error)
|
||||
return
|
||||
}
|
||||
|
||||
this.post = r
|
||||
|
||||
setTimeout(() => {
|
||||
if (process.browser) {
|
||||
if (window.REMARK42) {
|
||||
this.initRemark42()
|
||||
} else {
|
||||
window.addEventListener('REMARK42::ready', () => {
|
||||
this.initRemark42()
|
||||
})
|
||||
}
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
mounted() {
|
||||
this.initRemark42()
|
||||
},
|
||||
beforeDestroy() {
|
||||
if (this.remark42Instance) {
|
||||
@@ -99,18 +85,26 @@ export default class PostPage extends Vue {
|
||||
remark42settings = THEME.comment?.remark42 || null
|
||||
remark42Instance: any = null
|
||||
|
||||
@Watch('$fetchState.pending')
|
||||
initRemark42() {
|
||||
if (process.browser && this.remark42settings && window.REMARK42) {
|
||||
if (this.remark42Instance) {
|
||||
this.remark42Instance.destroy()
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
if (
|
||||
this.$refs.remark42 &&
|
||||
process.browser &&
|
||||
this.remark42settings &&
|
||||
window.REMARK42
|
||||
) {
|
||||
if (this.remark42Instance) {
|
||||
this.remark42Instance.destroy()
|
||||
}
|
||||
|
||||
this.remark42Instance = window.REMARK42.createInstance({
|
||||
node: this.$refs.remark42 as HTMLElement,
|
||||
host: this.remark42settings.host,
|
||||
site_id: this.remark42settings.siteId,
|
||||
})
|
||||
}
|
||||
this.remark42Instance = window.REMARK42.createInstance({
|
||||
node: this.$refs.remark42 as HTMLElement,
|
||||
host: this.remark42settings.host,
|
||||
site_id: this.remark42settings.siteId,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Vue, Component } from 'nuxt-property-decorator'
|
||||
import { api } from '~/assets/global'
|
||||
|
||||
@Component<TagPage>({
|
||||
watch: {
|
||||
@@ -14,7 +13,7 @@ import { api } from '~/assets/global'
|
||||
'$route.query.page': '$fetch',
|
||||
},
|
||||
async fetch() {
|
||||
const { result, count, error } = await api('/api/q', {
|
||||
const { result, count } = await this.$axios.$get('/api/q', {
|
||||
params: {
|
||||
q: this.$route.query.q,
|
||||
page: this.$route.query.page,
|
||||
@@ -22,11 +21,6 @@ import { api } from '~/assets/global'
|
||||
},
|
||||
})
|
||||
|
||||
if (error) {
|
||||
this.$nuxt.error(error)
|
||||
return
|
||||
}
|
||||
|
||||
this.posts = result
|
||||
this.count = count
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user