本文整理汇总了TypeScript中@library/utility/appUtils.getMeta函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getMeta函数的具体用法?TypeScript getMeta怎么用?TypeScript getMeta使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getMeta函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: uploadFile
export async function uploadFile(file: File, requestConfig: AxiosRequestConfig = {}) {
let allowedExtensions = getMeta("upload.allowedExtensions", []) as string[];
allowedExtensions = allowedExtensions.map((ext: string) => ext.toLowerCase());
const maxSize = getMeta("upload.maxSize", 0);
const filePieces = file.name.split(".");
const extension = filePieces[filePieces.length - 1] || "";
if (file.size > maxSize) {
const humanSize = humanFileSize(maxSize);
const stringTotal: string = humanSize.amount + humanSize.unitAbbr;
const message = sprintf(t("The uploaded file was too big (max %s)."), stringTotal);
throw new Error(message);
} else if (!allowedExtensions.includes(extension.toLowerCase())) {
const attachmentsString = allowedExtensions.join(", ");
const message = sprintf(
t(
"The uploaded file did not have an allowed extension. \nOnly the following extensions are allowed. \n%s.",
),
attachmentsString,
);
throw new Error(message);
}
const data = new FormData();
data.append("file", file, file.name);
const result = await apiv2.post("/media", data, requestConfig);
return result.data;
}
示例2: it
it("dot syntax for nested getMeta values", () => {
application.setMeta("ui", { foo: "bar", bar: { baz: "bam" } });
expect(application.getMeta("ui.foo")).eq("bar");
expect(application.getMeta("ui.bar.baz")).eq("bam");
expect(application.getMeta("ui.bar.bax", "de")).eq("de");
expect(application.getMeta("uiz.bar.bax", "de")).eq("de");
expect(application.getMeta("ui.foo.bax", "de")).eq("de");
});
示例3: getMeta
const makeCacheKey = () => {
const storeState = getDeferredStoreState<ICoreStoreState, null>(null);
const themeKey = getMeta("ui.themeKey", "default");
const status = storeState ? storeState.theme.assets.status : "not loaded yet";
const cacheKey = themeKey + status;
return cacheKey;
};
示例4: getMeta
* @license GPL-2.0-only
*/
import { formatUrl, getMeta } from "@library/utility/appUtils";
import { log, matchAtMention as _matchAtMention } from "@library/utility/utils";
// Store cache results in an outer scoped variable., so all instances share the same data
// and can build the cache together.
const atCache = {};
const atEmpty = {};
// The current raw match. This is needed to properly match quoted strings.
let rawMatch: string | undefined;
// Set minimum characters to type for @mentions to fire
const minCharacters = getMeta("mentionMinChars", 2);
// Max suggestions to show in flyouts.
const maxSuggestions = getMeta("mentionSuggestionCount", 5);
// Server response limit. This should match the limit set in
// *UserController->TagSearch* and UserModel->TagSearch
const serverLimit = 30;
// Emoji, set in definition list in foot, by Emoji class. Make sure
// that class is getting instantiated, otherwise emoji will be empty.
interface IEmojiData {
assetPath?: string;
emoji?: {
[key: string]: string;
示例5: getMeta
/**
* Primary bootstrapping of the frontend JS. This entrypoint should be the last once executed.
*
* @copyright 2009-2019 Vanilla Forums Inc.
* @license GPL-2.0-only
*/
import { onContent, getMeta, _executeReady, _mountComponents } from "@library/utility/appUtils";
import { log, logError, debug } from "@library/utility/utils";
import gdn from "@library/gdn";
import apiv2 from "@library/apiv2";
// Inject the debug flag into the utility.
const debugValue = getMeta("context.debug", getMeta("debug", false));
debug(debugValue);
// Export the API to the global object.
gdn.apiv2 = apiv2;
log("Bootstrapping");
_executeReady()
.then(() => {
log("Bootstrapping complete.");
// Mount all data-react components.
onContent(e => {
_mountComponents(e.target);
});
const contentEvent = new CustomEvent("X-DOMContentReady", { bubbles: true, cancelable: false });
document.dispatchEvent(contentEvent);
})
示例6: getMeta
requestInterceptor: (request: Request) => {
request.headers["x-transient-key"] = getMeta("TransientKey");
return request;
},