-
Notifications
You must be signed in to change notification settings - Fork 829
Expand file tree
/
Copy pathsite.ts
More file actions
135 lines (130 loc) · 3.74 KB
/
Copy pathsite.ts
File metadata and controls
135 lines (130 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import { ActionTree, Module, MutationTree } from 'vuex'
import { IPost } from '../../interfaces/post'
import { ITag } from '../../interfaces/tag'
import { ITheme } from '../../interfaces/theme'
import { IMenu } from '../../interfaces/menu'
import { ISetting, ICommentSetting } from '../../interfaces/setting'
import {
DEFAULT_POST_PAGE_SIZE, DEFAULT_ARCHIVES_PAGE_SIZE, DEFAULT_FEED_COUNT, DEFAULT_ARCHIVES_PATH, DEFAULT_POST_PATH, DEFAULT_TAG_PATH,
} from '../../helpers/constants'
export interface Site {
appDir: string
buildDir: string
config: any
posts: IPost[]
tags: ITag[]
menus: IMenu[]
themeConfig: ITheme
themeCustomConfig: any
currentThemeConfig: any
themes: string[]
setting: ISetting
commentSetting: ICommentSetting
}
const siteState: Site = {
appDir: '',
buildDir: '',
config: {},
posts: [],
tags: [],
menus: [],
themeConfig: {
themeName: '',
postPageSize: DEFAULT_POST_PAGE_SIZE,
archivesPageSize: DEFAULT_ARCHIVES_PAGE_SIZE,
siteName: '',
siteDescription: '',
footerInfo: 'Powered by Gridea',
showFeatureImage: true,
postUrlFormat: 'SLUG',
tagUrlFormat: 'SLUG',
dateFormat: 'YYYY-MM-DD',
feedCount: DEFAULT_FEED_COUNT,
feedFullText: true,
archivesPath: DEFAULT_ARCHIVES_PATH,
postPath: DEFAULT_POST_PATH,
tagPath: DEFAULT_TAG_PATH,
},
themeCustomConfig: {},
currentThemeConfig: {},
themes: [],
setting: {
platform: 'github',
domain: '',
repository: '',
branch: '',
username: '',
email: '',
tokenUsername: '',
token: '',
cname: '',
port: '22',
server: '',
password: '',
privateKey: '',
remotePath: '',
proxyPath: '',
proxyPort: '',
enabledProxy: 'direct',
netlifySiteId: '',
netlifyAccessToken: '',
},
commentSetting: {
showComment: false,
commentPlatform: 'gitalk',
gitalkSetting: {
clientId: '',
clientSecret: '',
repository: '',
owner: '',
},
disqusSetting: {
api: '',
apikey: '',
shortname: '',
},
},
}
const mutations: MutationTree<Site> = {
updateSite(state, siteData: Site) {
console.log('data', siteData)
state.appDir = siteData.appDir
state.buildDir = siteData.buildDir
state.posts = siteData.posts
state.tags = siteData.tags
state.menus = siteData.menus
state.config = siteData.config
state.themeConfig = siteData.themeConfig
state.themeConfig.postUrlFormat = siteData.themeConfig.postUrlFormat || 'SLUG'
state.themeConfig.tagUrlFormat = siteData.themeConfig.tagUrlFormat || 'SLUG'
state.themeConfig.dateFormat = siteData.themeConfig.dateFormat || 'YYYY-MM-DD'
state.themeConfig.postPageSize = siteData.themeConfig.postPageSize || DEFAULT_POST_PAGE_SIZE
state.themeConfig.archivesPageSize = siteData.themeConfig.archivesPageSize || DEFAULT_ARCHIVES_PAGE_SIZE
state.themeConfig.feedCount = siteData.themeConfig.feedCount || DEFAULT_FEED_COUNT
state.themeConfig.feedFullText = (typeof siteData.themeConfig.feedFullText) === 'undefined' ? true : siteData.themeConfig.feedFullText // from > 0.8.0
state.themes = siteData.themes
state.setting = siteData.setting
state.commentSetting = siteData.commentSetting
state.themeCustomConfig = siteData.themeCustomConfig
state.currentThemeConfig = siteData.currentThemeConfig
},
updatePosts(state, posts: IPost[]) {
state.posts = posts
},
}
const actions: ActionTree<Site, any> = {
updatePosts({ commit }, posts: IPost[]) {
commit('updatePosts', posts)
},
updateSite({ commit }, siteData: Site) {
console.log('siteData:', siteData)
commit('updateSite', siteData)
},
}
const module: Module<Site, any> = {
namespaced: true,
state: siteState,
mutations,
actions,
}
export default module