UNPKG

@lcap/asl

Version:

NetEase Application Specific Language

70 lines 2.7 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.loadTemplates = exports.TEMPLATE_MAP = exports.TEMPLATE_LIST = exports.h5List = void 0; const assets_1 = require("../assets"); const config_1 = __importDefault(require("../../types/config")); /** * 页面区块 * @TODO 之后没有文件服务器了,所以后面需要改到区块接口中 * @TODO 另外 nodejs 下不支持 webpack loader,所以这里直接搞成了文件内容 */ const pcList = [ { text: '仪表盘布局', value: 'dashboard' }, { text: '通用页面布局', value: 'page' }, { text: '空白页', value: 'wrapper' }, { text: '首页', value: 'index-page' }, { text: '登录页', value: 'login-page' }, { text: '404 页面', value: '404-page' }, { text: '无权限页面', value: '401-page' }, { text: '禁止访问页面', value: '403-page' }, { text: '服务器错误页面', value: '500-page' }, ]; exports.h5List = [ { text: '空白页', value: 'lcap-h5-blank' }, { text: '登录页', value: 'lcap-h5-login' }, { text: '主页', value: 'lcap-h5-navi' }, { text: '个人中心页', value: 'lcap-h5-user' }, { text: '404 页面', value: 'lcap-h5-404' }, { text: '无权限页面', value: 'lcap-h5-401' }, ]; exports.TEMPLATE_LIST = pcList; exports.TEMPLATE_MAP = {}; async function loadTemplates() { const ifH5 = config_1.default.scope === 'h5'; const { rows } = await assets_1.blockService.loadList({ query: { keyword: ifH5 ? `template-h5` : `view-template`, }, }); if (ifH5) { exports.TEMPLATE_LIST = exports.h5List; } exports.TEMPLATE_LIST.forEach((item) => exports.TEMPLATE_MAP[item.value] = item); const h5Real = []; const templates = rows.forEach((row) => { const item = { text: row.title, value: row.name.replace(/^@cloud-ui\/s-/, '').replace(/^@lcap\/mobile-ui\//, '').replace(/\.vue$/, ''), screenshots: row.screenshots, }; if (ifH5) { exports.TEMPLATE_LIST.forEach((v) => { if (v.value === item.value) { h5Real.push(item); } }); } else { if (!exports.TEMPLATE_MAP[item.value]) { exports.TEMPLATE_LIST.push(item); exports.TEMPLATE_MAP[item.value] = item; } } }); return ifH5 ? h5Real : exports.TEMPLATE_LIST; } exports.loadTemplates = loadTemplates; //# sourceMappingURL=templates.js.map