Skip to content

Commit

Permalink
编辑器页面的标题跟随文件标题
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglin2 committed Jul 4, 2024
1 parent f0c7c1a commit c05a98d
Show file tree
Hide file tree
Showing 19 changed files with 96 additions and 13 deletions.
5 changes: 5 additions & 0 deletions bpmn/src/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createPinia, defineStore } from 'pinia'
import api from './api'
import config from '@/config'
import { setPageTitle } from '@/utils'

export const pinia = createPinia()

Expand Down Expand Up @@ -63,6 +64,7 @@ export const useStore = defineStore('main', {
const { data } = await api.getFileContent({
id
})
setPageTitle(data.name)
this.fileData = data
return data
},
Expand All @@ -79,6 +81,9 @@ export const useStore = defineStore('main', {
id: this.fileData.id,
...data
})
if (data.name) {
setPageTitle(data.name)
}
this.setAutoSaveStatus('success')
} catch (error) {
console.log(error)
Expand Down
8 changes: 7 additions & 1 deletion bpmn/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@ export const svgToPng = (str, exportPadding = 0) => {
}
img.src = svgUrl
})
}
}

// 设置页面标题
export const setPageTitle = (title) => {
title = title || 'Bpmn'
document.title = title + '_理想文档'
}
2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Doc_理想文档</title>
<title>文档_理想文档</title>
</head>
<body>
<div id="app"></div>
Expand Down
7 changes: 6 additions & 1 deletion doc/src/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createPinia, defineStore } from 'pinia'
import api from './api'
import config from '@/config';
import config from '@/config'
import { setPageTitle } from '@/utils'

export const pinia = createPinia()

Expand Down Expand Up @@ -63,6 +64,7 @@ export const useStore = defineStore('main', {
const { data } = await api.getFileContent({
id
})
setPageTitle(data.name)
this.fileData = data
return data
},
Expand All @@ -79,6 +81,9 @@ export const useStore = defineStore('main', {
id: this.fileData.id,
...data
})
if (data.name) {
setPageTitle(data.name)
}
this.setAutoSaveStatus('success')
} catch (error) {
console.log(error)
Expand Down
6 changes: 6 additions & 0 deletions doc/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ export const downloadFile = (data, fileName) => {
// 模拟点击下载
link.click()
}

// 设置页面标题
export const setPageTitle = (title) => {
title = title || '文档'
document.title = title + '_理想文档'
}
9 changes: 9 additions & 0 deletions flowchart/src/main/webapp/js/ui/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
setAutoSaveStatus(data) {
this.autoSaveStatus = data
},
// 设置页面标题
setPageTitle(title) {
title = title || '流程图'
document.title = title + '_理想文档'
},
// 获取用户信息
async getUserInfo() {
try {
Expand All @@ -110,6 +115,7 @@
})
this.fileData = data
this.fileName = this.fileData.name
this.setPageTitle(this.fileName)
initChart()
} catch (error) {
console.log(error)
Expand All @@ -128,6 +134,9 @@
id: this.fileData.id,
...data
})
if (data.name) {
this.setPageTitle(data.name)
}
const file = window.editorApp.getCurrentFile()
file.setModified(false)
this.setAutoSaveStatus('success')
Expand Down
7 changes: 6 additions & 1 deletion markdown/src/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createPinia, defineStore } from 'pinia'
import api from './api'
import config from '@/config';
import config from '@/config'
import { setPageTitle } from '@/utils'

export const pinia = createPinia()

Expand Down Expand Up @@ -63,6 +64,7 @@ export const useStore = defineStore('main', {
const { data } = await api.getFileContent({
id
})
setPageTitle(data.name)
this.fileData = data
return data
},
Expand All @@ -79,6 +81,9 @@ export const useStore = defineStore('main', {
id: this.fileData.id,
...data
})
if (data.name) {
setPageTitle(data.name)
}
this.setAutoSaveStatus('success')
} catch (error) {
console.log(error)
Expand Down
5 changes: 5 additions & 0 deletions markdown/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// 设置页面标题
export const setPageTitle = title => {
title = title || 'Markdown'
document.title = title + '_理想文档'
}
10 changes: 5 additions & 5 deletions mind-map/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,19 @@ const store = new Vuex.Store({
},

// 更新文件数据
async storeFileInfo(ctx, info) {
async storeFileInfo(ctx, data) {
try {
ctx.commit('setAutoSaveStatus', 'ing')
ctx.state.mindMapData = {
...ctx.state.mindMapData,
...info
...data
}
await updateFile({
id: ctx.state.mindMapData.id,
...info
...data
})
if (info.name) {
setPageTitle(info.name)
if (data.name) {
setPageTitle(data.name)
}
ctx.commit('setAutoSaveStatus', 'success')
} catch (error) {
Expand Down
7 changes: 6 additions & 1 deletion note/src/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createPinia, defineStore } from 'pinia'
import api from './api'
import config from '@/config';
import config from '@/config'
import { setPageTitle } from '@/utils'

export const pinia = createPinia()

Expand Down Expand Up @@ -63,6 +64,7 @@ export const useStore = defineStore('main', {
const { data } = await api.getFileContent({
id
})
setPageTitle(data.name)
this.fileData = data
return data
},
Expand All @@ -79,6 +81,9 @@ export const useStore = defineStore('main', {
id: this.fileData.id,
...data
})
if (data.name) {
setPageTitle(data.name)
}
this.setAutoSaveStatus('success')
} catch (error) {
console.log(error)
Expand Down
5 changes: 5 additions & 0 deletions note/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// 设置页面标题
export const setPageTitle = title => {
title = title || '笔记'
document.title = title + '_理想文档'
}
2 changes: 1 addition & 1 deletion ppt/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PPT_理想文档</title>
<title>幻灯片_理想文档</title>

<style>
.first-screen-loading {
Expand Down
5 changes: 5 additions & 0 deletions ppt/src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SYS_FONTS } from '@/configs/font'
import { isSupportFont } from '@/utils/font'
import api from '@/api'
import config from '@/configs/user'
import { setPageTitle } from '@/utils/common'

import { useSlidesStore } from './slides'

Expand Down Expand Up @@ -163,6 +164,7 @@ export const useMainStore = defineStore('main', {
const { data } = await api.getFileContent({
id
})
setPageTitle(data.name)
this.fileData = data
return data
},
Expand All @@ -179,6 +181,9 @@ export const useMainStore = defineStore('main', {
id: this.fileData.id,
...data
})
if (data.name) {
setPageTitle(data.name)
}
this.setAutoSaveStatus('success')
} catch (error) {
console.log(error)
Expand Down
6 changes: 6 additions & 0 deletions ppt/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ export const fillDigit = (digit: number, len: number) => {
*/
export const isPC = () => {
return !navigator.userAgent.match(/(iPhone|iPod|iPad|Android|Mobile|BlackBerry|Symbian|Windows Phone)/i)
}

// 设置页面标题
export const setPageTitle = (title: string) => {
title = title || '幻灯片'
document.title = title + '_理想文档'
}
2 changes: 1 addition & 1 deletion sheet/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sheet_理想文档</title>
<title>电子表格_理想文档</title>
<link rel="stylesheet" href="/sheet/plugins/css/pluginsCss.css" />
<link rel="stylesheet" href="/sheet/plugins/plugins.css" />
<link rel="stylesheet" href="/sheet/css/luckysheet.css" />
Expand Down
7 changes: 6 additions & 1 deletion sheet/src/store.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createPinia, defineStore } from 'pinia'
import api from './api'
import config from '@/config';
import config from '@/config'
import { setPageTitle } from '@/utils'

export const pinia = createPinia()

Expand Down Expand Up @@ -63,6 +64,7 @@ export const useStore = defineStore('main', {
const { data } = await api.getFileContent({
id
})
setPageTitle(data.name)
this.fileData = data
return data
},
Expand All @@ -79,6 +81,9 @@ export const useStore = defineStore('main', {
id: this.fileData.id,
...data
})
if (data.name) {
setPageTitle(data.name)
}
this.setAutoSaveStatus('success')
} catch (error) {
console.log(error)
Expand Down
5 changes: 5 additions & 0 deletions sheet/src/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// 设置页面标题
export const setPageTitle = title => {
title = title || '电子表格'
document.title = title + '_理想文档'
}
5 changes: 5 additions & 0 deletions whiteboard/src/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import api from '@/api'
import eventBus from '@/utils/eventBus'
import { setPageTitle } from '@/utils'

const store = {
data: {
Expand Down Expand Up @@ -59,6 +60,7 @@ const store = {
const { data } = await api.getFileContent({
id
})
setPageTitle(data.name)
if (data.content) {
data.content = data.content ? JSON.parse(data.content) : null
}
Expand All @@ -78,6 +80,9 @@ const store = {
id: store.data.fileData.id,
...data
})
if (data.name) {
setPageTitle(data.name)
}
store.methods.setAutoSaveStatus('success')
} catch (error) {
console.log(error)
Expand Down
6 changes: 6 additions & 0 deletions whiteboard/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ export const imgToDataURL = src => {
img.src = src
})
}

// 设置页面标题
export const setPageTitle = title => {
title = title || '白板'
document.title = title + '_理想文档'
}

0 comments on commit c05a98d

Please sign in to comment.