-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
168 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,77 @@ | ||
// config/index.js | ||
export default { | ||
title: 'My Static Site Generator', | ||
description: 'A simple static site generator with configurable navigation', | ||
logo: '/navpress/images/logo.svg', | ||
github: 'https://github.com/aaronlamz/navpress', | ||
base:'/navpress/', | ||
title: "我的开发导航", | ||
description: "A simple static site generator with configurable navigation", | ||
logo: "/navpress/images/logo.svg", | ||
github: "https://github.com/aaronlamz/navpress", | ||
base: "/navpress/", | ||
meta: { | ||
title: 'My Navpress', | ||
description: 'Navpress - a simple static site generator with configurable navigation', | ||
keywords: 'static site, generator, navpress, vue', | ||
author: 'aaronlamz', | ||
title: "My Navpress", | ||
description: | ||
"Navpress - a simple static site generator with configurable navigation", | ||
keywords: "static site, generator, navpress, vue", | ||
author: "aaronlamz", | ||
}, | ||
sidebar: [ | ||
{ | ||
text: 'Home', | ||
link: '/', | ||
{ | ||
text: "Web", | ||
link: "/", | ||
items: [ | ||
{ | ||
text: 'Group 1', | ||
link: '#group1', | ||
text: "前端", | ||
link: "#group1", | ||
items: [ | ||
{ text: 'Child 1', link: 'https://example.com/child1' }, | ||
{ text: 'Child 2', link: 'https://example.com/child2' }, | ||
{ text: 'Child 2', link: 'https://example.com/child2' }, | ||
] | ||
{ text: "Child 1", link: "https://example.com/child1" }, | ||
{ text: "Child 2", link: "https://example.com/child2" }, | ||
{ text: "Child 2", link: "https://example.com/child2" }, | ||
], | ||
}, | ||
{ | ||
text: 'Group 2', | ||
link: '#group2', | ||
text: "设计", | ||
link: "#group2", | ||
items: [ | ||
{ text: 'Child 3', link: 'https://example.com/child3' }, | ||
{ text: 'Child 4', link: 'https://example.com/child4' }, | ||
{ text: 'Child 2', link: 'https://example.com/child2' }, | ||
] | ||
{ text: "Child 3", link: "https://example.com/child3" }, | ||
{ text: "Child 4", link: "https://example.com/child4" }, | ||
{ text: "Child 2", link: "https://example.com/child2" }, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
text: "效率工具", | ||
link: "/efficient", | ||
expanded: true, | ||
items: [ | ||
{ | ||
text: 'Group 3', | ||
link: '#group3', | ||
items: [ | ||
{ text: 'Child 3', link: 'https://example.com/child3' }, | ||
{ text: 'Child 4', link: 'https://example.com/child4' }, | ||
] | ||
text: "Group A", | ||
link: "#groupA", | ||
items: [{ text: "Child A1", link: "https://example.com/childA1" }], | ||
}, | ||
], | ||
}, | ||
{ | ||
text: "AI 资源", | ||
link: "/ai", | ||
expanded: true, | ||
items: [ | ||
{ | ||
text: 'Group 4', | ||
link: '#group4', | ||
items: [ | ||
{ text: 'Child 3', link: 'https://example.com/child3' }, | ||
{ text: 'Child 4', link: 'https://example.com/child4' }, | ||
] | ||
} | ||
] | ||
text: "Group A", | ||
link: "#groupA", | ||
items: [{ text: "Child A1", link: "https://example.com/childA1" }], | ||
}, | ||
], | ||
}, | ||
{ | ||
text: 'About', | ||
link: '/about', | ||
expanded: false, | ||
{ | ||
text: "副业有道", | ||
link: "/second-job", | ||
expanded: true, | ||
items: [ | ||
{ | ||
text: 'Group A', | ||
link: '#groupA', | ||
items: [ | ||
{ text: 'Child A1', link: 'https://example.com/childA1' }, | ||
] | ||
} | ||
] | ||
text: "Group A", | ||
link: "#groupA", | ||
items: [{ text: "Child", link: "https://example.com/childA1" }], | ||
}, | ||
], | ||
}, | ||
], | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,45 @@ | ||
import { createSSRApp, createApp as createCSRApp } from 'vue' | ||
import App from './App.vue' | ||
import router from './router/index.js' // 明确导入文件 | ||
import './assets/style/index.css' | ||
import { createSSRApp, createApp as createCSRApp, reactive } from 'vue'; | ||
import App from './App.vue'; | ||
import { createRouterInstance } from './router'; | ||
import './assets/style/index.css'; | ||
|
||
// 获取全局配置 | ||
const config = typeof __USER_CONFIG__ !== 'undefined' ? __USER_CONFIG__ : {}; | ||
const initialConfig = typeof __USER_CONFIG__ !== 'undefined' ? __USER_CONFIG__ : {}; | ||
const userConfig = reactive(initialConfig); // 使用 reactive 创建响应式的配置对象 | ||
|
||
console.log('Initial userConfig:', userConfig); | ||
|
||
export function createApp() { | ||
const app = createSSRApp(App) | ||
app.use(router) | ||
const app = createSSRApp(App); | ||
const router = createRouterInstance(userConfig); | ||
app.use(router); | ||
// 将配置挂载到全局 | ||
app.config.globalProperties.$config = config; | ||
return { app, router } | ||
app.config.globalProperties.$config = userConfig; | ||
return { app, router }; | ||
} | ||
|
||
if (typeof window !== 'undefined') { | ||
const app = createCSRApp(App) | ||
app.use(router) | ||
// 将配置挂载到全局 | ||
app.config.globalProperties.$config = config; | ||
app.mount('#app') | ||
} | ||
let app; | ||
let router; | ||
|
||
const initializeApp = () => { | ||
app = createCSRApp(App); | ||
router = createRouterInstance(userConfig); | ||
app.use(router); | ||
// 将配置挂载到全局 | ||
app.config.globalProperties.$config = userConfig; | ||
app.mount('#app'); | ||
}; | ||
|
||
initializeApp(); | ||
|
||
// 监听 Vite 的自定义事件更新配置 | ||
if (import.meta.hot) { | ||
import.meta.hot.on('config-updated', (newConfig) => { | ||
Object.assign(userConfig, newConfig); // 更新响应式对象 | ||
console.log('Config updated:', userConfig); | ||
app.unmount(); | ||
initializeApp(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters