Skip to content

Commit

Permalink
feat:#13 发布到Vuepress-支持挂件模式与非挂件模式
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jul 29, 2022
1 parent e7ea073 commit 9f59f99
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 155 deletions.
5 changes: 4 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# env example
# 是否开启info日志,true | false
# VITE_LOG_INFO_ENABLED=
# VITE_LOG_INFO_ENABLED=

# 思源笔记授权token,部分api调用需要
# VITE_SIYUAN_CONFIG_TOKEN=
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
name: 'App',
components: {PublishService},
setup() {
console.log("MODE=>", import.meta.env.MODE)
log.logWarn("MODE=>", import.meta.env.MODE)
log.logInfo("App setup")
return {}
}
Expand Down
34 changes: 23 additions & 11 deletions src/components/main/VuepressMain.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
</template>

<script lang="ts" setup>
import {onBeforeMount} from "vue";
import {getSiyuanPage} from "../../lib/siyuan/siyuanUtil";
import log from "../../lib/logUtil"
const isPublished = false
const formData = {
title: "",
Expand Down Expand Up @@ -190,6 +194,14 @@ const copyToClipboard = () => {
const publishPage = () => {
}
onBeforeMount(async () => {
const page = await getSiyuanPage()
log.logInfo("page=>", page)
if(!page){
return
}
})
</script>

<script lang="ts">
Expand Down Expand Up @@ -272,7 +284,7 @@ export default {
// return
// }
// const page = await getBlockByID(pageId)
// console.log("VuepressMain获取主文档", page)
// log.logInfo("VuepressMain获取主文档", page)
//
// // 思源笔记数据
// this.siyuanData.pageId = pageId;
Expand All @@ -289,7 +301,7 @@ export default {
// this.formData.tag.dynamicTags.push(tgarr[i])
// }
// this.formData.created = formatNumToZhDate(page.created)
// console.log("VuepressMain初始化页面,meta=>", this.siyuanData.meta);
// log.logInfo("VuepressMain初始化页面,meta=>", this.siyuanData.meta);
//
// // 表单属性转换为HTML
// this.convertAttrToYAML()
Expand All @@ -305,7 +317,7 @@ export default {
// if (this.formData.checkList.length > 0) {
// // 调用Google翻译API
// const result = await zhSlugify(title);
// console.log("result=>", result)
// log.logInfo("result=>", result)
// if (result) {
// this.formData.customSlug = result
// } else {
Expand All @@ -324,7 +336,7 @@ export default {
// this.formData.desc = parseHtml(html, CONSTANTS.MAX_PREVIEW_LENGTH, true)
// },
// createTimeChanged(val) {
// console.log("createTimeChanged=>", val)
// log.logInfo("createTimeChanged=>", val)
// },
// tagHandleClose(tag) {
// this.formData.tag.dynamicTags.splice(this.formData.tag.dynamicTags.indexOf(tag), 1)
Expand All @@ -347,10 +359,10 @@ export default {
//
// const md = data.content
// const genTags = await cutWords(md)
// console.log("genTags=>", genTags)
// log.logInfo("genTags=>", genTags)
//
// const hotTags = jiebaToHotWords(genTags, 5)
// console.log("hotTags=>", hotTags)
// log.logInfo("hotTags=>", hotTags)
//
// // 如果标签不存在,保存新标签到表单
// for (let i = 0; i < hotTags.length; i++) {
Expand All @@ -367,17 +379,17 @@ export default {
// tags: this.formData.tag.dynamicTags.join(",")
// };
// await setBlockAttrs(this.siyuanData.pageId, customAttr)
// console.log("VuepressMain保存属性到思源笔记,meta=>", customAttr);
// log.logInfo("VuepressMain保存属性到思源笔记,meta=>", customAttr);
//
// // 刷新属性数据
// await this.initPage();
//
// alert(this.$t('main.opt.success'))
// },
// convertAttrToYAML() {
// console.log("convertAttrToYAML")
// log.logInfo("convertAttrToYAML")
// // 表单属性转yamlObj
// console.log("convertAttrToYAML,formData=>", this.formData)
// log.logInfo("convertAttrToYAML,formData=>", this.formData)
// this.vuepressData.yamlObj.title = this.formData.title;
// this.vuepressData.yamlObj.permalink = "/post/" + this.formData.customSlug + ".html";
// this.vuepressData.yamlObj.date = covertStringToDate(this.formData.created)
Expand All @@ -403,12 +415,12 @@ export default {
// this.vuepressData.vuepressFullContent = this.vuepressData.formatter;
// },
// async convertYAMLToAttr() {
// console.log("convertYAMLToAttr")
// log.logInfo("convertYAMLToAttr")
// this.vuepressData.formatter = this.vuepressData.vuepressFullContent
// this.vuepressData.yamlObj = yaml2Obj(this.vuepressData.formatter)
//
// // yamlObj转表单属性
// console.log("convertYAMLToAttr,yamlObj=>", this.vuepressData.yamlObj)
// log.logInfo("convertYAMLToAttr,yamlObj=>", this.vuepressData.yamlObj)
// this.formData.title = this.vuepressData.yamlObj.title
// this.formData.customSlug = this.vuepressData.yamlObj.permalink.replace("/pages/", "")
// .replace("/post/", "").replace(".html", "")
Expand Down
2 changes: 1 addition & 1 deletion src/components/setting/JVueSetting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const initConf = () => {
log.logInfo("Jvue配置初始化")
const conf = getJSONConf(PUBLISH_TYPE_CONSTANTS.API_TYPE_JVUE)
if (conf) {
console.log("jvue conf=>", conf)
log.logInfo("jvue conf=>", conf)
// @ts-ignore
home.value = conf[PUBLISH_HOME_KEY_CONSTANTS.JVUE_HOME_KEY]
Expand Down
2 changes: 1 addition & 1 deletion src/lib/envUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function getBooleanEnv(key: string) {
* @param key key
*/
export function getEnv(key: string) {
let env = null
let env = ""
if (import.meta.env[key]) {
env = import.meta.env[key]
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/publishUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {getJSONConf} from "./config.js";
import log from "./logUtil";

const API_TYPE_CNBLPGS = "cnblogs";
const API_TYPE_WORDPRESS = "wordpress";
Expand Down Expand Up @@ -278,7 +279,7 @@ export function getApiParams(apiType: string) {
postidKey
}

console.log("获取最新apiParams=>", {
log.logInfo("获取最新apiParams=>", {
home,
apiUrl,
appKey,
Expand Down
Loading

0 comments on commit 9f59f99

Please sign in to comment.