|
|
@@ -13,7 +13,7 @@ import { resolveAssetUrl } from './asset'
|
|
|
|
|
|
const BASE_URL = process.env.VUE_APP_BASE_API || ''
|
|
|
|
|
|
-function getUploadHeaders() {
|
|
|
+export function getUploadHeaders() {
|
|
|
const token = localStorage.getItem('token')
|
|
|
return token ? { Authorization: 'Bearer ' + token } : {}
|
|
|
}
|
|
|
@@ -32,7 +32,19 @@ function makeCustomInsert() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function makeCustomAlert() {
|
|
|
+/**
|
|
|
+ * 编辑器顶层 config.customAlert 工厂。
|
|
|
+ *
|
|
|
+ * <p>注意:wangEditor 从编辑器顶层 config.customAlert 读取(不是 MENU_CONF.uploadImage.customAlert),
|
|
|
+ * 因此必须挂在 editorConfig 根节点上:
|
|
|
+ * <pre>
|
|
|
+ * editorConfig = {
|
|
|
+ * customAlert: getEditorCustomAlert(),
|
|
|
+ * MENU_CONF: buildEditorAssetMenuConf({ category: 'articles' })
|
|
|
+ * }
|
|
|
+ * </pre>
|
|
|
+ */
|
|
|
+export function getEditorCustomAlert() {
|
|
|
// 注意:wangEditor 从编辑器顶层 config.customAlert 读取(不是 MENU_CONF.uploadImage.customAlert)
|
|
|
return function customAlert(msg, type) {
|
|
|
Message({ message: msg, type: type || 'error' })
|
|
|
@@ -132,6 +144,6 @@ export function insertAssetIntoEditor(editor, record, type) {
|
|
|
export default {
|
|
|
buildEditorAssetMenuConf,
|
|
|
insertAssetIntoEditor,
|
|
|
- getEditorCustomAlert: makeCustomAlert,
|
|
|
+ getEditorCustomAlert,
|
|
|
getUploadHeaders
|
|
|
}
|