當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript appUtils.getMeta函數代碼示例

本文整理匯總了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;
}
開發者ID:vanilla,項目名稱:vanilla,代碼行數:29,代碼來源:apiv2.ts

示例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");
 });
開發者ID:vanilla,項目名稱:vanilla,代碼行數:8,代碼來源:appUtils.test.ts

示例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;
 };
開發者ID:vanilla,項目名稱:vanilla,代碼行數:7,代碼來源:styleUtils.ts

示例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;
開發者ID:vanilla,項目名稱:vanilla,代碼行數:31,代碼來源:atwho.ts

示例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);
    })
開發者ID:vanilla,項目名稱:vanilla,代碼行數:31,代碼來源:bootstrap.ts

示例6: getMeta

 requestInterceptor: (request: Request) => {
     request.headers["x-transient-key"] = getMeta("TransientKey");
     return request;
 },
開發者ID:vanilla,項目名稱:vanilla,代碼行數:4,代碼來源:mountSwagger.ts


注:本文中的@library/utility/appUtils.getMeta函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。