diff --git a/app/model/Post.php b/app/model/Post.php index 64bf654..05ef89e 100644 --- a/app/model/Post.php +++ b/app/model/Post.php @@ -6,6 +6,7 @@ namespace app\model; use Parsedown; use ScssPhp\ScssPhp\Compiler; +use think\Env as ThinkEnv; use think\facade\App; use think\facade\Cache; use think\facade\Env; @@ -207,12 +208,25 @@ class Post extends Model } $components_path = $components_type_path . '/' . $components_name; - $list_components_data[$components_name]['title'] = file_get_contents($components_path . '/_title.txt'); + // $list_components_data[$components_name]['title'] = file_get_contents($components_path . '/_title.txt'); + + $env_info = new ThinkEnv(); + + $env_info->load($components_path . '/_index.env'); + + $list_components_data[$components_name]['config'] = $env_info->get(); $list_components_data[$components_name]['html'] = file_get_contents($components_path . '/_index.html'); $list_components_data[$components_name]['scss'] = file_get_contents($components_path . '/_index.scss'); $list_components_data[$components_name]['css'] = $scss_compiler->compileString($list_components_data[$components_name]['scss'])->getCss(); $list_components_data[$components_name]['markdown'] = file_get_contents($components_path . '/_index.md'); $list_components_data[$components_name]['desc'] = $markdown_parser->text($list_components_data[$components_name]['markdown']); + + $uniapp_code = $list_components_data[$components_name]['html']; + + $uniapp_code = str_replace('', 'view>', $uniapp_code); + + $list_components_data[$components_name]['uniapp'] = $uniapp_code; } Cache::set($cache_key, $list_components_data, 60); diff --git a/public/cdn/img/view.jpg b/public/cdn/img/view.jpg new file mode 100644 index 0000000..4eacd39 Binary files /dev/null and b/public/cdn/img/view.jpg differ diff --git a/public/static/lib/vue/vue.global.js b/public/static/lib/vue/vue.global.js new file mode 100644 index 0000000..55d94ea --- /dev/null +++ b/public/static/lib/vue/vue.global.js @@ -0,0 +1,15990 @@ +var Vue = (function (exports) { + 'use strict'; + + /** + * Make a map and return a function for checking if a key + * is in that map. + * IMPORTANT: all calls of this function must be prefixed with + * \/\*#\_\_PURE\_\_\*\/ + * So that rollup can tree-shake them if necessary. + */ + function makeMap(str, expectsLowerCase) { + const map = Object.create(null); + const list = str.split(','); + for (let i = 0; i < list.length; i++) { + map[list[i]] = true; + } + return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val]; + } + + /** + * dev only flag -> name mapping + */ + const PatchFlagNames = { + [1 /* PatchFlags.TEXT */]: `TEXT`, + [2 /* PatchFlags.CLASS */]: `CLASS`, + [4 /* PatchFlags.STYLE */]: `STYLE`, + [8 /* PatchFlags.PROPS */]: `PROPS`, + [16 /* PatchFlags.FULL_PROPS */]: `FULL_PROPS`, + [32 /* PatchFlags.HYDRATE_EVENTS */]: `HYDRATE_EVENTS`, + [64 /* PatchFlags.STABLE_FRAGMENT */]: `STABLE_FRAGMENT`, + [128 /* PatchFlags.KEYED_FRAGMENT */]: `KEYED_FRAGMENT`, + [256 /* PatchFlags.UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`, + [512 /* PatchFlags.NEED_PATCH */]: `NEED_PATCH`, + [1024 /* PatchFlags.DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`, + [2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`, + [-1 /* PatchFlags.HOISTED */]: `HOISTED`, + [-2 /* PatchFlags.BAIL */]: `BAIL` + }; + + /** + * Dev only + */ + const slotFlagsText = { + [1 /* SlotFlags.STABLE */]: 'STABLE', + [2 /* SlotFlags.DYNAMIC */]: 'DYNAMIC', + [3 /* SlotFlags.FORWARDED */]: 'FORWARDED' + }; + + const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' + + 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' + + 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt'; + const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED); + + const range = 2; + function generateCodeFrame(source, start = 0, end = source.length) { + // Split the content into individual lines but capture the newline sequence + // that separated each line. This is important because the actual sequence is + // needed to properly take into account the full line length for offset + // comparison + let lines = source.split(/(\r?\n)/); + // Separate the lines and newline sequences into separate arrays for easier referencing + const newlineSequences = lines.filter((_, idx) => idx % 2 === 1); + lines = lines.filter((_, idx) => idx % 2 === 0); + let count = 0; + const res = []; + for (let i = 0; i < lines.length; i++) { + count += + lines[i].length + + ((newlineSequences[i] && newlineSequences[i].length) || 0); + if (count >= start) { + for (let j = i - range; j <= i + range || end > count; j++) { + if (j < 0 || j >= lines.length) + continue; + const line = j + 1; + res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`); + const lineLength = lines[j].length; + const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0; + if (j === i) { + // push underline + const pad = start - (count - (lineLength + newLineSeqLength)); + const length = Math.max(1, end > count ? lineLength - pad : end - start); + res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length)); + } + else if (j > i) { + if (end > count) { + const length = Math.max(Math.min(end - count, lineLength), 1); + res.push(` | ` + '^'.repeat(length)); + } + count += lineLength + newLineSeqLength; + } + } + break; + } + } + return res.join('\n'); + } + + /** + * On the client we only need to offer special cases for boolean attributes that + * have different names from their corresponding dom properties: + * - itemscope -> N/A + * - allowfullscreen -> allowFullscreen + * - formnovalidate -> formNoValidate + * - ismap -> isMap + * - nomodule -> noModule + * - novalidate -> noValidate + * - readonly -> readOnly + */ + const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`; + const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs); + /** + * Boolean attributes should be included if the value is truthy or ''. + * e.g. `