mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-11 13:17:29 +08:00
chore: add helper to clear vditor cache
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, onMounted, computed, watch } from 'vue'
|
import { ref, onMounted, computed, watch, onUnmounted } from 'vue'
|
||||||
import { themeState } from '../utils/theme'
|
import { themeState } from '../utils/theme'
|
||||||
import {
|
import {
|
||||||
createVditor,
|
createVditor,
|
||||||
@@ -26,6 +26,7 @@ import {
|
|||||||
getPreviewTheme as getPreviewThemeUtil
|
getPreviewTheme as getPreviewThemeUtil
|
||||||
} from '../utils/vditor'
|
} from '../utils/vditor'
|
||||||
import LoginOverlay from './LoginOverlay.vue'
|
import LoginOverlay from './LoginOverlay.vue'
|
||||||
|
import { clearVditorStorage } from '../utils/clearVditorStorage'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CommentEditor',
|
name: 'CommentEditor',
|
||||||
@@ -90,6 +91,10 @@ export default {
|
|||||||
// applyTheme()
|
// applyTheme()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
clearVditorStorage()
|
||||||
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.loading,
|
() => props.loading,
|
||||||
val => {
|
val => {
|
||||||
|
|||||||
@@ -8,13 +8,14 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, onMounted, watch } from 'vue'
|
import { ref, onMounted, watch, onUnmounted } from 'vue'
|
||||||
import { themeState } from '../utils/theme'
|
import { themeState } from '../utils/theme'
|
||||||
import {
|
import {
|
||||||
createVditor,
|
createVditor,
|
||||||
getEditorTheme as getEditorThemeUtil,
|
getEditorTheme as getEditorThemeUtil,
|
||||||
getPreviewTheme as getPreviewThemeUtil
|
getPreviewTheme as getPreviewThemeUtil
|
||||||
} from '../utils/vditor'
|
} from '../utils/vditor'
|
||||||
|
import { clearVditorStorage } from '../utils/clearVditorStorage'
|
||||||
import { hatch } from 'ldrs'
|
import { hatch } from 'ldrs'
|
||||||
hatch.register()
|
hatch.register()
|
||||||
|
|
||||||
@@ -106,6 +107,10 @@ export default {
|
|||||||
// applyTheme()
|
// applyTheme()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
clearVditorStorage()
|
||||||
|
})
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { useToast } from 'vue-toastification'
|
|||||||
import { checkToken, clearToken, isLogin } from './utils/auth'
|
import { checkToken, clearToken, isLogin } from './utils/auth'
|
||||||
import { initTheme } from './utils/theme'
|
import { initTheme } from './utils/theme'
|
||||||
import { loginWithGoogle } from './utils/google'
|
import { loginWithGoogle } from './utils/google'
|
||||||
|
import { clearVditorStorage } from './utils/clearVditorStorage'
|
||||||
|
|
||||||
// Configurable API domain and port
|
// Configurable API domain and port
|
||||||
// export const API_DOMAIN = 'http://127.0.0.1'
|
// export const API_DOMAIN = 'http://127.0.0.1'
|
||||||
@@ -28,6 +29,7 @@ export const TWITTER_CLIENT_ID = 'ZTRTU05KSk9KTTJrTTdrVC1tc1E6MTpjaQ'
|
|||||||
export const toast = useToast()
|
export const toast = useToast()
|
||||||
|
|
||||||
initTheme()
|
initTheme()
|
||||||
|
clearVditorStorage()
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
app.use(router)
|
app.use(router)
|
||||||
|
|||||||
7
frontend/src/utils/clearVditorStorage.js
Normal file
7
frontend/src/utils/clearVditorStorage.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export function clearVditorStorage() {
|
||||||
|
Object.keys(localStorage).forEach(key => {
|
||||||
|
if (key.startsWith('vditoreditor-') || key === 'vditor') {
|
||||||
|
localStorage.removeItem(key)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user