• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript appUtils.getMeta函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript appUtils.onContent函数代码示例发布时间:2022-05-28
下一篇:
TypeScript appUtils.formatUrl函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap