fix import path
This commit is contained in:
@@ -4,7 +4,7 @@ import { markedHighlight } from "marked-highlight";
|
||||
import { mangle } from "marked-mangle";
|
||||
import Prism from "prismjs";
|
||||
import "prismjs/themes/prism.css";
|
||||
import { Toolkit } from "~/index";
|
||||
import SettingMapper from "./SettingMapper";
|
||||
|
||||
export default class Markdown {
|
||||
|
||||
@@ -99,7 +99,7 @@ export default class Markdown {
|
||||
}
|
||||
// 内部资源链接
|
||||
if (href.indexOf("@") !== -1) {
|
||||
href = Toolkit.toResURL(href);
|
||||
href = SettingMapper.toResURL(href);
|
||||
}
|
||||
{
|
||||
// 处理嵌套 markdown,这可能不是最优解
|
||||
@@ -159,7 +159,7 @@ export default class Markdown {
|
||||
if (extendTag) {
|
||||
href = href.substring(1);
|
||||
}
|
||||
href = Toolkit.toResURL(href);
|
||||
href = SettingMapper.toResURL(href);
|
||||
}
|
||||
|
||||
const clazzStr = clazz.join(" ");
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import axios, { InternalAxiosRequestConfig } from "axios";
|
||||
import { Response } from "~/types/Model";
|
||||
import { Cooker, Time, userStore } from "~/index";
|
||||
import Cooker from "./Cooker";
|
||||
import type { Response } from "../types/Model";
|
||||
import Time from "./Time";
|
||||
import { userStore } from "../store/user";
|
||||
|
||||
type ErrorCallback = (response: Response<any>) => void;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { SettingKey } from "~/types/Setting";
|
||||
import { readonly, Ref, ref } from "vue";
|
||||
import CommonAPI from "~/api/CommonAPI";
|
||||
import { RunEnv, Toolkit } from "timi-web";
|
||||
import { RunEnv, SettingKey } from "../types";
|
||||
import Toolkit from "./Toolkit";
|
||||
import CommonAPI from "../api/CommonAPI";
|
||||
|
||||
export default class SettingMapper {
|
||||
|
||||
@@ -100,4 +100,22 @@ export default class SettingMapper {
|
||||
}
|
||||
return SettingMapper.instance = new SettingMapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析资源 URL 协议前缀
|
||||
*
|
||||
* @param val 原始值,如 `res@/path/to/file`
|
||||
* @returns 完整 URL
|
||||
*/
|
||||
public static toResURL(val: string): string {
|
||||
const at = val.indexOf("@");
|
||||
const start = val.substring(0, at);
|
||||
const path = val.substring(at + 1);
|
||||
switch (start) {
|
||||
case "res": return SettingMapper.getDomainLink(SettingKey.DOMAIN_RESOURCE) + path;
|
||||
case "dl": return SettingMapper.getDomainLink(SettingKey.DOMAIN_DOWNLOAD) + path;
|
||||
case "attach": return CommonAPI.getAttachmentReadAPI(path);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import type { App } from "vue";
|
||||
import type { InstallRecord } from "~/types";
|
||||
import { UserLevelType } from "~/types/User";
|
||||
import { CommonAPI, SettingKey, SettingMapper } from "~/index";
|
||||
import { InstallRecord, UserLevelType } from "../types";
|
||||
|
||||
export default class Toolkit {
|
||||
|
||||
@@ -340,18 +338,6 @@ export default class Toolkit {
|
||||
return form;
|
||||
}
|
||||
|
||||
public static toResURL(val: string): string {
|
||||
const at = val.indexOf("@");
|
||||
const start = val.substring(0, at);
|
||||
const path = val.substring(at + 1);
|
||||
switch (start) {
|
||||
case "res": return SettingMapper.getDomainLink(SettingKey.DOMAIN_RESOURCE) + path;
|
||||
case "dl": return SettingMapper.getDomainLink(SettingKey.DOMAIN_DOWNLOAD) + path;
|
||||
case "attach": return CommonAPI.getAttachmentReadAPI(path);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
public static format(template: string, variables: { [key: string]: any }): string {
|
||||
return template.replace(/\$\{(\w+)}/g, (_, key) => variables[key]);
|
||||
}
|
||||
|
||||
22
src/utils/index.ts
Normal file
22
src/utils/index.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
export { default as Cooker } from "./Cooker";
|
||||
export { default as Events } from "./Events";
|
||||
export { default as IOSize } from "./IOSize";
|
||||
export { default as Markdown } from "./Markdown";
|
||||
export { default as Network } from "./Network";
|
||||
export { default as Prismjs } from "./Prismjs";
|
||||
export { default as Resizer } from "./Resizer";
|
||||
export { default as Scroller } from "./Scroller";
|
||||
export { default as Storage } from "./Storage";
|
||||
export { default as Time } from "./Time";
|
||||
export { default as Toolkit } from "./Toolkit";
|
||||
export { default as IconMapper } from "./IconMapper";
|
||||
export { default as SettingMapper } from "./SettingMapper";
|
||||
|
||||
export { default as VDraggable } from "./directives/Draggable";
|
||||
export { default as VPopup } from "./directives/Popup";
|
||||
|
||||
export * from "./MethodLocker";
|
||||
export * from "./Network";
|
||||
export * from "./Prismjs";
|
||||
export * from "./directives/Draggable";
|
||||
export * from "./directives/Popup";
|
||||
Reference in New Issue
Block a user