Skip to content

Commit

Permalink
feat: 在线分享第一版-新增调试模式
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Jun 15, 2023
1 parent eab210d commit a375318
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 15 deletions.
5 changes: 1 addition & 4 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import "./assets/default/fonts/webfont.css"
const layout = "default"
</script>

Expand All @@ -9,6 +8,4 @@ const layout = "default"
</NuxtLayout>
</template>

<style scoped>
</style>
<style scoped></style>
7 changes: 4 additions & 3 deletions common/appLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* questions.
*/

import { isDev } from "~/common/Constants.ts"
import { isDev } from "~/common/Constants"
import { simpleLogger } from "zhi-lib-base"

/**
Expand All @@ -49,12 +49,13 @@ interface ILogger {
* @since 1.0.0
*/
export const createAppLogger = (name: string): ILogger => {
return simpleLogger(name, "picgo-plugin-app", isDev)
return simpleLogger(name, "siyuan-blog", isDev)
}

/**
* 销毁日志
*/
export const destroyLogger = (): void => {
;(window as any).eruda.destroy()
const win = window as any
win.eruda.destroy()
}
7 changes: 7 additions & 0 deletions libs/eruda/backers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions libs/eruda/eruda.js

Large diffs are not rendered by default.

File renamed without changes.
46 changes: 39 additions & 7 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,32 @@ const getAppBase = (isSiyuanBuild: boolean, isNodeBuild: boolean, isVercelBuild:
}
}

const generateDynamicV = () => {
const now = new Date()
const year = now.getFullYear().toString()
const month = (now.getMonth() + 1).toString().padStart(2, "0")
const day = now.getDate().toString().padStart(2, "0")
const hour = now.getHours().toString().padStart(2, "0")
const minute = now.getMinutes().toString().padStart(2, "0")
return year + month + day + hour + minute
}

const isDev = process.env.NODE_ENV === "development"
const isVercelBuild = process.env.BUILD_TYPE === "vercel"
const isNodeBuild = process.env.BUILD_TYPE === "node"
const isSiyuanBuild = process.env.BUILD_TYPE === "siyuan"
const debugMode = process.env.DEBUG_MODE === "true" || isDev

const appBase = getAppBase(isSiyuanBuild, isNodeBuild, isVercelBuild, isDev)
const isSsr = isNodeBuild || isVercelBuild

const ssrPreset = isVercelBuild ? "vercel" : isNodeBuild ? "node-server" : undefined
const ssrServeStatic = isSiyuanBuild

const staticV = generateDynamicV()
console.log("staticV=>", staticV)
console.log("isDev=>", isDev)
console.log("debugMode=>", debugMode)
console.log("isVercelBuild=>", isVercelBuild)
console.log("isNodeBuild=>", isNodeBuild)
console.log("isSiyuanBuild=>", isSiyuanBuild)
Expand All @@ -44,18 +58,36 @@ export default defineNuxtConfig({
enabled: true,
},

vite: {
plugins: [],
},

app: {
baseURL: appBase,
head: {
charset: "utf-8",
viewport: "width=device-width, initial-scale=1",
// link: [{ rel: "stylesheet", href: appBase + "lib/webfont/webfont.css?v=" + staticV }],
// script: [
// {
// src: appBase + "lib/lute/lute-1.7.5-20230410.min.js?v=" + staticV,
// body: true,
// },
// ],
link: [{ rel: "stylesheet", href: appBase + "lib/fonts/webfont.css?v=" + staticV }],
// https://nuxt.com/docs/api/configuration/nuxt-config#head
script: debugMode
? [
// {
// src: appBase + "lib/lute/lute-1.7.5-20230410.min.js?v=" + staticV,
// body: true,
// },
{
src: appBase + "libs/eruda/eruda.js",
},
{
children: "eruda.init();console.log('eruda inited');",
},
]
: [
// {
// src: appBase + "lib/lute/lute-1.7.5-20230410.min.js?v=" + staticV,
// body: true,
// },
],
},
},

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"serve": "nuxt dev",
"build": "pnpm pluginBuild && pnpm siyuanBuild",
"dev": "rm -rf ./dist && pnpm pluginBuild && pnpm siyuanBuild && pnpm siyuanSync",
"dev": "rm -rf ./dist && pnpm pluginBuild && DEBUG_MODE=true pnpm siyuanBuild && pnpm siyuanSync",
"pluginBuild": "zhi-build --production",
"vercelBuild": "BUILD_TYPE=vercel nuxt build",
"nodeBuild": "BUILD_TYPE=node nuxt build",
Expand Down

0 comments on commit a375318

Please sign in to comment.