mirror of
https://github.com/Monibuca/plugin-ts.git
synced 2025-09-27 03:55:54 +08:00
添加了UI界面
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
.vscode
|
22
README.md
22
README.md
@@ -1,3 +1,25 @@
|
||||
# tsplugin
|
||||
ts publisher for monibuca
|
||||
|
||||
处理TS数据的插件
|
||||
|
||||
## 插件名称
|
||||
|
||||
TS
|
||||
|
||||
## 功能
|
||||
|
||||
1. 通过Publish发布一个TS流,然后通过Feed方法填入TS数据即可
|
||||
2. 通过PublishDir可以读取服务器上文件夹内的所有ts文件进行发布
|
||||
|
||||
## 配置
|
||||
|
||||
```toml
|
||||
[Plugins.TS]
|
||||
BufferLength = 2048
|
||||
Path = "ts"
|
||||
AutoPublish = true
|
||||
```
|
||||
BufferLength指的是解析TS流的时候的缓存大小,单位是PES包的个数
|
||||
Path 指存放ts的目录
|
||||
AutoPublish 是指是否当订阅者订阅某个房间时自动触发发布TS
|
74
dashboard/index.vue
Normal file
74
dashboard/index.vue
Normal file
@@ -0,0 +1,74 @@
|
||||
<template>
|
||||
<div class="layout">
|
||||
<Badge
|
||||
@click.native="publish(item)"
|
||||
v-for="item in Rooms"
|
||||
:key="item.StreamPath"
|
||||
:count="item.TsCount"
|
||||
class="room"
|
||||
>
|
||||
<Icon type="ios-folder-open-outline" size="100" />
|
||||
<div class="size">{{unitFormat(item.TotalSize)}}</div>
|
||||
<div>{{item.StreamPath}}</div>
|
||||
</Badge>
|
||||
<div v-if="Rooms.length==0" class="empty">
|
||||
<Icon type="md-wine" size="50" />没有任何文件夹
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Rooms: []
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
fetchlist() {
|
||||
window.ajax.getJSON("/ts/list").then(x => {
|
||||
this.Rooms = x;
|
||||
});
|
||||
},
|
||||
publish(item) {
|
||||
this.$Modal.confirm({
|
||||
title: "提示",
|
||||
content: "是否发布该目录",
|
||||
onOk() {
|
||||
window.ajax.getJSON(
|
||||
"/ts/publish?streamPath=" + item.StreamPath
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
unitFormat: window.unitFormat
|
||||
},
|
||||
mounted() {
|
||||
this.fetchlist();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@import url("/iview.css");
|
||||
.layout {
|
||||
padding-bottom: 30px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 30px;
|
||||
}
|
||||
.room {
|
||||
text-align: center;
|
||||
}
|
||||
.room:hover {
|
||||
border: 1px solid gray;
|
||||
border-radius: 10%;
|
||||
cursor: pointer;
|
||||
}
|
||||
.size {
|
||||
position: absolute;
|
||||
top: 40%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
</style>
|
9560
dashboard/package-lock.json
generated
Normal file
9560
dashboard/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
15
dashboard/package.json
Normal file
15
dashboard/package.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "dashboard",
|
||||
"version": "1.0.0",
|
||||
"description": "dashboard of ts plugin for monibuca",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "vue-cli-service build --dest ui --target wc --name plugin-ts index.vue"
|
||||
},
|
||||
"author": "dexter",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@vue/cli-service": "^4.2.3",
|
||||
"vue-template-compiler": "^2.6.11"
|
||||
}
|
||||
}
|
8
dashboard/ui/demo.html
Normal file
8
dashboard/ui/demo.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<meta charset="utf-8">
|
||||
<title>plugin-ts demo</title>
|
||||
<script src="https://unpkg.com/vue"></script>
|
||||
<script src="./plugin-ts.js"></script>
|
||||
|
||||
|
||||
<plugin-ts></plugin-ts>
|
||||
|
897
dashboard/ui/plugin-ts.js
Normal file
897
dashboard/ui/plugin-ts.js
Normal file
@@ -0,0 +1,897 @@
|
||||
/******/ (function(modules) { // webpackBootstrap
|
||||
/******/ // The module cache
|
||||
/******/ var installedModules = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/
|
||||
/******/ // Check if module is in cache
|
||||
/******/ if(installedModules[moduleId]) {
|
||||
/******/ return installedModules[moduleId].exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = installedModules[moduleId] = {
|
||||
/******/ i: moduleId,
|
||||
/******/ l: false,
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Flag the module as loaded
|
||||
/******/ module.l = true;
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/******/
|
||||
/******/ // expose the modules object (__webpack_modules__)
|
||||
/******/ __webpack_require__.m = modules;
|
||||
/******/
|
||||
/******/ // expose the module cache
|
||||
/******/ __webpack_require__.c = installedModules;
|
||||
/******/
|
||||
/******/ // define getter function for harmony exports
|
||||
/******/ __webpack_require__.d = function(exports, name, getter) {
|
||||
/******/ if(!__webpack_require__.o(exports, name)) {
|
||||
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = function(exports) {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // create a fake namespace object
|
||||
/******/ // mode & 1: value is a module id, require it
|
||||
/******/ // mode & 2: merge all properties of value into the ns
|
||||
/******/ // mode & 4: return value when already ns object
|
||||
/******/ // mode & 8|1: behave like require
|
||||
/******/ __webpack_require__.t = function(value, mode) {
|
||||
/******/ if(mode & 1) value = __webpack_require__(value);
|
||||
/******/ if(mode & 8) return value;
|
||||
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
||||
/******/ var ns = Object.create(null);
|
||||
/******/ __webpack_require__.r(ns);
|
||||
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
||||
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
||||
/******/ return ns;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = function(module) {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ function getDefault() { return module['default']; } :
|
||||
/******/ function getModuleExports() { return module; };
|
||||
/******/ __webpack_require__.d(getter, 'a', getter);
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Object.prototype.hasOwnProperty.call
|
||||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
||||
/******/
|
||||
/******/ // __webpack_public_path__
|
||||
/******/ __webpack_require__.p = "";
|
||||
/******/
|
||||
/******/
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(__webpack_require__.s = "5a74");
|
||||
/******/ })
|
||||
/************************************************************************/
|
||||
/******/ ({
|
||||
|
||||
/***/ "1471":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
// Imports
|
||||
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__("24fb");
|
||||
exports = ___CSS_LOADER_API_IMPORT___(false);
|
||||
exports.push([module.i, "@import url(/iview.css);"]);
|
||||
// Module
|
||||
exports.push([module.i, ".layout{padding-bottom:30px;display:flex;flex-wrap:wrap;padding:30px}.room{text-align:center}.room:hover{border:1px solid grey;border-radius:10%;cursor:pointer}.size{position:absolute;top:40%;left:0;right:0}", ""]);
|
||||
// Exports
|
||||
module.exports = exports;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "20f8":
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css_shadow__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("84d5");
|
||||
/* harmony import */ var _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css_shadow__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css_shadow__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css_shadow__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css_shadow__WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__));
|
||||
/* harmony default export */ __webpack_exports__["default"] = (_node_modules_vue_style_loader_index_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_lib_loaders_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_3_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_lib_index_js_vue_loader_options_index_vue_vue_type_style_index_0_lang_css_shadow__WEBPACK_IMPORTED_MODULE_0___default.a);
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "24fb":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
// css base code, injected by the css-loader
|
||||
// eslint-disable-next-line func-names
|
||||
module.exports = function (useSourceMap) {
|
||||
var list = []; // return the list of modules as css string
|
||||
|
||||
list.toString = function toString() {
|
||||
return this.map(function (item) {
|
||||
var content = cssWithMappingToString(item, useSourceMap);
|
||||
|
||||
if (item[2]) {
|
||||
return "@media ".concat(item[2], " {").concat(content, "}");
|
||||
}
|
||||
|
||||
return content;
|
||||
}).join('');
|
||||
}; // import a list of modules into the list
|
||||
// eslint-disable-next-line func-names
|
||||
|
||||
|
||||
list.i = function (modules, mediaQuery, dedupe) {
|
||||
if (typeof modules === 'string') {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
modules = [[null, modules, '']];
|
||||
}
|
||||
|
||||
var alreadyImportedModules = {};
|
||||
|
||||
if (dedupe) {
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
// eslint-disable-next-line prefer-destructuring
|
||||
var id = this[i][0];
|
||||
|
||||
if (id != null) {
|
||||
alreadyImportedModules[id] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var _i = 0; _i < modules.length; _i++) {
|
||||
var item = [].concat(modules[_i]);
|
||||
|
||||
if (dedupe && alreadyImportedModules[item[0]]) {
|
||||
// eslint-disable-next-line no-continue
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mediaQuery) {
|
||||
if (!item[2]) {
|
||||
item[2] = mediaQuery;
|
||||
} else {
|
||||
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
|
||||
}
|
||||
}
|
||||
|
||||
list.push(item);
|
||||
}
|
||||
};
|
||||
|
||||
return list;
|
||||
};
|
||||
|
||||
function cssWithMappingToString(item, useSourceMap) {
|
||||
var content = item[1] || ''; // eslint-disable-next-line prefer-destructuring
|
||||
|
||||
var cssMapping = item[3];
|
||||
|
||||
if (!cssMapping) {
|
||||
return content;
|
||||
}
|
||||
|
||||
if (useSourceMap && typeof btoa === 'function') {
|
||||
var sourceMapping = toComment(cssMapping);
|
||||
var sourceURLs = cssMapping.sources.map(function (source) {
|
||||
return "/*# sourceURL=".concat(cssMapping.sourceRoot || '').concat(source, " */");
|
||||
});
|
||||
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
|
||||
}
|
||||
|
||||
return [content].join('\n');
|
||||
} // Adapted from convert-source-map (MIT)
|
||||
|
||||
|
||||
function toComment(sourceMap) {
|
||||
// eslint-disable-next-line no-undef
|
||||
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
|
||||
var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
|
||||
return "/*# ".concat(data, " */");
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "35d6":
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, "default", function() { return /* binding */ addStylesToShadowDOM; });
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/vue-style-loader/lib/listToStyles.js
|
||||
/**
|
||||
* Translates the list format produced by css-loader into something
|
||||
* easier to manipulate.
|
||||
*/
|
||||
function listToStyles (parentId, list) {
|
||||
var styles = []
|
||||
var newStyles = {}
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var item = list[i]
|
||||
var id = item[0]
|
||||
var css = item[1]
|
||||
var media = item[2]
|
||||
var sourceMap = item[3]
|
||||
var part = {
|
||||
id: parentId + ':' + i,
|
||||
css: css,
|
||||
media: media,
|
||||
sourceMap: sourceMap
|
||||
}
|
||||
if (!newStyles[id]) {
|
||||
styles.push(newStyles[id] = { id: id, parts: [part] })
|
||||
} else {
|
||||
newStyles[id].parts.push(part)
|
||||
}
|
||||
}
|
||||
return styles
|
||||
}
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/vue-style-loader/lib/addStylesShadow.js
|
||||
|
||||
|
||||
function addStylesToShadowDOM (parentId, list, shadowRoot) {
|
||||
var styles = listToStyles(parentId, list)
|
||||
addStyles(styles, shadowRoot)
|
||||
}
|
||||
|
||||
/*
|
||||
type StyleObject = {
|
||||
id: number;
|
||||
parts: Array<StyleObjectPart>
|
||||
}
|
||||
|
||||
type StyleObjectPart = {
|
||||
css: string;
|
||||
media: string;
|
||||
sourceMap: ?string
|
||||
}
|
||||
*/
|
||||
|
||||
function addStyles (styles /* Array<StyleObject> */, shadowRoot) {
|
||||
const injectedStyles =
|
||||
shadowRoot._injectedStyles ||
|
||||
(shadowRoot._injectedStyles = {})
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
var item = styles[i]
|
||||
var style = injectedStyles[item.id]
|
||||
if (!style) {
|
||||
for (var j = 0; j < item.parts.length; j++) {
|
||||
addStyle(item.parts[j], shadowRoot)
|
||||
}
|
||||
injectedStyles[item.id] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createStyleElement (shadowRoot) {
|
||||
var styleElement = document.createElement('style')
|
||||
styleElement.type = 'text/css'
|
||||
shadowRoot.appendChild(styleElement)
|
||||
return styleElement
|
||||
}
|
||||
|
||||
function addStyle (obj /* StyleObjectPart */, shadowRoot) {
|
||||
var styleElement = createStyleElement(shadowRoot)
|
||||
var css = obj.css
|
||||
var media = obj.media
|
||||
var sourceMap = obj.sourceMap
|
||||
|
||||
if (media) {
|
||||
styleElement.setAttribute('media', media)
|
||||
}
|
||||
|
||||
if (sourceMap) {
|
||||
// https://developer.chrome.com/devtools/docs/javascript-debugging
|
||||
// this makes source maps inside style tags work properly in Chrome
|
||||
css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
|
||||
// http://stackoverflow.com/a/26603875
|
||||
css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
|
||||
}
|
||||
|
||||
if (styleElement.styleSheet) {
|
||||
styleElement.styleSheet.cssText = css
|
||||
} else {
|
||||
while (styleElement.firstChild) {
|
||||
styleElement.removeChild(styleElement.firstChild)
|
||||
}
|
||||
styleElement.appendChild(document.createTextNode(css))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "5a74":
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
|
||||
// This file is imported into lib/wc client bundles.
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
if (Object({"NODE_ENV":"production","BASE_URL":"/"}).NEED_CURRENTSCRIPT_POLYFILL) {
|
||||
__webpack_require__("f6fd")
|
||||
}
|
||||
|
||||
var i
|
||||
if ((i = window.document.currentScript) && (i = i.src.match(/(.+\/)[^/]+\.js(\?.*)?$/))) {
|
||||
__webpack_require__.p = i[1] // eslint-disable-line
|
||||
}
|
||||
}
|
||||
|
||||
// Indicate to webpack that this file can be concatenated
|
||||
/* harmony default export */ var setPublicPath = (null);
|
||||
|
||||
// EXTERNAL MODULE: external "Vue"
|
||||
var external_Vue_ = __webpack_require__("8bbf");
|
||||
var external_Vue_default = /*#__PURE__*/__webpack_require__.n(external_Vue_);
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/@vue/web-component-wrapper/dist/vue-wc-wrapper.js
|
||||
const camelizeRE = /-(\w)/g;
|
||||
const camelize = str => {
|
||||
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '')
|
||||
};
|
||||
|
||||
const hyphenateRE = /\B([A-Z])/g;
|
||||
const hyphenate = str => {
|
||||
return str.replace(hyphenateRE, '-$1').toLowerCase()
|
||||
};
|
||||
|
||||
function getInitialProps (propsList) {
|
||||
const res = {};
|
||||
propsList.forEach(key => {
|
||||
res[key] = undefined;
|
||||
});
|
||||
return res
|
||||
}
|
||||
|
||||
function injectHook (options, key, hook) {
|
||||
options[key] = [].concat(options[key] || []);
|
||||
options[key].unshift(hook);
|
||||
}
|
||||
|
||||
function callHooks (vm, hook) {
|
||||
if (vm) {
|
||||
const hooks = vm.$options[hook] || [];
|
||||
hooks.forEach(hook => {
|
||||
hook.call(vm);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function createCustomEvent (name, args) {
|
||||
return new CustomEvent(name, {
|
||||
bubbles: false,
|
||||
cancelable: false,
|
||||
detail: args
|
||||
})
|
||||
}
|
||||
|
||||
const isBoolean = val => /function Boolean/.test(String(val));
|
||||
const isNumber = val => /function Number/.test(String(val));
|
||||
|
||||
function convertAttributeValue (value, name, { type } = {}) {
|
||||
if (isBoolean(type)) {
|
||||
if (value === 'true' || value === 'false') {
|
||||
return value === 'true'
|
||||
}
|
||||
if (value === '' || value === name) {
|
||||
return true
|
||||
}
|
||||
return value != null
|
||||
} else if (isNumber(type)) {
|
||||
const parsed = parseFloat(value, 10);
|
||||
return isNaN(parsed) ? value : parsed
|
||||
} else {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
function toVNodes (h, children) {
|
||||
const res = [];
|
||||
for (let i = 0, l = children.length; i < l; i++) {
|
||||
res.push(toVNode(h, children[i]));
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
function toVNode (h, node) {
|
||||
if (node.nodeType === 3) {
|
||||
return node.data.trim() ? node.data : null
|
||||
} else if (node.nodeType === 1) {
|
||||
const data = {
|
||||
attrs: getAttributes(node),
|
||||
domProps: {
|
||||
innerHTML: node.innerHTML
|
||||
}
|
||||
};
|
||||
if (data.attrs.slot) {
|
||||
data.slot = data.attrs.slot;
|
||||
delete data.attrs.slot;
|
||||
}
|
||||
return h(node.tagName, data)
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function getAttributes (node) {
|
||||
const res = {};
|
||||
for (let i = 0, l = node.attributes.length; i < l; i++) {
|
||||
const attr = node.attributes[i];
|
||||
res[attr.nodeName] = attr.nodeValue;
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
function wrap (Vue, Component) {
|
||||
const isAsync = typeof Component === 'function' && !Component.cid;
|
||||
let isInitialized = false;
|
||||
let hyphenatedPropsList;
|
||||
let camelizedPropsList;
|
||||
let camelizedPropsMap;
|
||||
|
||||
function initialize (Component) {
|
||||
if (isInitialized) return
|
||||
|
||||
const options = typeof Component === 'function'
|
||||
? Component.options
|
||||
: Component;
|
||||
|
||||
// extract props info
|
||||
const propsList = Array.isArray(options.props)
|
||||
? options.props
|
||||
: Object.keys(options.props || {});
|
||||
hyphenatedPropsList = propsList.map(hyphenate);
|
||||
camelizedPropsList = propsList.map(camelize);
|
||||
const originalPropsAsObject = Array.isArray(options.props) ? {} : options.props || {};
|
||||
camelizedPropsMap = camelizedPropsList.reduce((map, key, i) => {
|
||||
map[key] = originalPropsAsObject[propsList[i]];
|
||||
return map
|
||||
}, {});
|
||||
|
||||
// proxy $emit to native DOM events
|
||||
injectHook(options, 'beforeCreate', function () {
|
||||
const emit = this.$emit;
|
||||
this.$emit = (name, ...args) => {
|
||||
this.$root.$options.customElement.dispatchEvent(createCustomEvent(name, args));
|
||||
return emit.call(this, name, ...args)
|
||||
};
|
||||
});
|
||||
|
||||
injectHook(options, 'created', function () {
|
||||
// sync default props values to wrapper on created
|
||||
camelizedPropsList.forEach(key => {
|
||||
this.$root.props[key] = this[key];
|
||||
});
|
||||
});
|
||||
|
||||
// proxy props as Element properties
|
||||
camelizedPropsList.forEach(key => {
|
||||
Object.defineProperty(CustomElement.prototype, key, {
|
||||
get () {
|
||||
return this._wrapper.props[key]
|
||||
},
|
||||
set (newVal) {
|
||||
this._wrapper.props[key] = newVal;
|
||||
},
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
});
|
||||
|
||||
isInitialized = true;
|
||||
}
|
||||
|
||||
function syncAttribute (el, key) {
|
||||
const camelized = camelize(key);
|
||||
const value = el.hasAttribute(key) ? el.getAttribute(key) : undefined;
|
||||
el._wrapper.props[camelized] = convertAttributeValue(
|
||||
value,
|
||||
key,
|
||||
camelizedPropsMap[camelized]
|
||||
);
|
||||
}
|
||||
|
||||
class CustomElement extends HTMLElement {
|
||||
constructor () {
|
||||
super();
|
||||
this.attachShadow({ mode: 'open' });
|
||||
|
||||
const wrapper = this._wrapper = new Vue({
|
||||
name: 'shadow-root',
|
||||
customElement: this,
|
||||
shadowRoot: this.shadowRoot,
|
||||
data () {
|
||||
return {
|
||||
props: {},
|
||||
slotChildren: []
|
||||
}
|
||||
},
|
||||
render (h) {
|
||||
return h(Component, {
|
||||
ref: 'inner',
|
||||
props: this.props
|
||||
}, this.slotChildren)
|
||||
}
|
||||
});
|
||||
|
||||
// Use MutationObserver to react to future attribute & slot content change
|
||||
const observer = new MutationObserver(mutations => {
|
||||
let hasChildrenChange = false;
|
||||
for (let i = 0; i < mutations.length; i++) {
|
||||
const m = mutations[i];
|
||||
if (isInitialized && m.type === 'attributes' && m.target === this) {
|
||||
syncAttribute(this, m.attributeName);
|
||||
} else {
|
||||
hasChildrenChange = true;
|
||||
}
|
||||
}
|
||||
if (hasChildrenChange) {
|
||||
wrapper.slotChildren = Object.freeze(toVNodes(
|
||||
wrapper.$createElement,
|
||||
this.childNodes
|
||||
));
|
||||
}
|
||||
});
|
||||
observer.observe(this, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
characterData: true,
|
||||
attributes: true
|
||||
});
|
||||
}
|
||||
|
||||
get vueComponent () {
|
||||
return this._wrapper.$refs.inner
|
||||
}
|
||||
|
||||
connectedCallback () {
|
||||
const wrapper = this._wrapper;
|
||||
if (!wrapper._isMounted) {
|
||||
// initialize attributes
|
||||
const syncInitialAttributes = () => {
|
||||
wrapper.props = getInitialProps(camelizedPropsList);
|
||||
hyphenatedPropsList.forEach(key => {
|
||||
syncAttribute(this, key);
|
||||
});
|
||||
};
|
||||
|
||||
if (isInitialized) {
|
||||
syncInitialAttributes();
|
||||
} else {
|
||||
// async & unresolved
|
||||
Component().then(resolved => {
|
||||
if (resolved.__esModule || resolved[Symbol.toStringTag] === 'Module') {
|
||||
resolved = resolved.default;
|
||||
}
|
||||
initialize(resolved);
|
||||
syncInitialAttributes();
|
||||
});
|
||||
}
|
||||
// initialize children
|
||||
wrapper.slotChildren = Object.freeze(toVNodes(
|
||||
wrapper.$createElement,
|
||||
this.childNodes
|
||||
));
|
||||
wrapper.$mount();
|
||||
this.shadowRoot.appendChild(wrapper.$el);
|
||||
} else {
|
||||
callHooks(this.vueComponent, 'activated');
|
||||
}
|
||||
}
|
||||
|
||||
disconnectedCallback () {
|
||||
callHooks(this.vueComponent, 'deactivated');
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAsync) {
|
||||
initialize(Component);
|
||||
}
|
||||
|
||||
return CustomElement
|
||||
}
|
||||
|
||||
/* harmony default export */ var vue_wc_wrapper = (wrap);
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/css-loader/dist/runtime/api.js
|
||||
var api = __webpack_require__("24fb");
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/vue-style-loader/lib/addStylesShadow.js + 1 modules
|
||||
var addStylesShadow = __webpack_require__("35d6");
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
|
||||
/* globals __VUE_SSR_CONTEXT__ */
|
||||
|
||||
// IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
|
||||
// This module is a runtime utility for cleaner component module output and will
|
||||
// be included in the final webpack user bundle.
|
||||
|
||||
function normalizeComponent (
|
||||
scriptExports,
|
||||
render,
|
||||
staticRenderFns,
|
||||
functionalTemplate,
|
||||
injectStyles,
|
||||
scopeId,
|
||||
moduleIdentifier, /* server only */
|
||||
shadowMode /* vue-cli only */
|
||||
) {
|
||||
// Vue.extend constructor export interop
|
||||
var options = typeof scriptExports === 'function'
|
||||
? scriptExports.options
|
||||
: scriptExports
|
||||
|
||||
// render functions
|
||||
if (render) {
|
||||
options.render = render
|
||||
options.staticRenderFns = staticRenderFns
|
||||
options._compiled = true
|
||||
}
|
||||
|
||||
// functional template
|
||||
if (functionalTemplate) {
|
||||
options.functional = true
|
||||
}
|
||||
|
||||
// scopedId
|
||||
if (scopeId) {
|
||||
options._scopeId = 'data-v-' + scopeId
|
||||
}
|
||||
|
||||
var hook
|
||||
if (moduleIdentifier) { // server build
|
||||
hook = function (context) {
|
||||
// 2.3 injection
|
||||
context =
|
||||
context || // cached call
|
||||
(this.$vnode && this.$vnode.ssrContext) || // stateful
|
||||
(this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
|
||||
// 2.2 with runInNewContext: true
|
||||
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
|
||||
context = __VUE_SSR_CONTEXT__
|
||||
}
|
||||
// inject component styles
|
||||
if (injectStyles) {
|
||||
injectStyles.call(this, context)
|
||||
}
|
||||
// register component module identifier for async chunk inferrence
|
||||
if (context && context._registeredComponents) {
|
||||
context._registeredComponents.add(moduleIdentifier)
|
||||
}
|
||||
}
|
||||
// used by ssr in case component is cached and beforeCreate
|
||||
// never gets called
|
||||
options._ssrRegister = hook
|
||||
} else if (injectStyles) {
|
||||
hook = shadowMode
|
||||
? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
|
||||
: injectStyles
|
||||
}
|
||||
|
||||
if (hook) {
|
||||
if (options.functional) {
|
||||
// for template-only hot-reload because in that case the render fn doesn't
|
||||
// go through the normalizer
|
||||
options._injectStyles = hook
|
||||
// register for functional component in vue file
|
||||
var originalRender = options.render
|
||||
options.render = function renderWithStyleInjection (h, context) {
|
||||
hook.call(context)
|
||||
return originalRender(h, context)
|
||||
}
|
||||
} else {
|
||||
// inject component registration as beforeCreate hook
|
||||
var existing = options.beforeCreate
|
||||
options.beforeCreate = existing
|
||||
? [].concat(existing, hook)
|
||||
: [hook]
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
exports: scriptExports,
|
||||
options: options
|
||||
}
|
||||
}
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"677aa4f3-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./index.vue?vue&type=template&id=c81a1b98&shadow
|
||||
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"layout"},[_vm._l((_vm.Rooms),function(item){return _c('Badge',{key:item.StreamPath,staticClass:"room",attrs:{"count":item.TsCount},nativeOn:{"click":function($event){return _vm.publish(item)}}},[_c('Icon',{attrs:{"type":"ios-folder-open-outline","size":"100"}}),_c('div',{staticClass:"size"},[_vm._v(_vm._s(_vm.unitFormat(item.TotalSize)))]),_c('div',[_vm._v(_vm._s(item.StreamPath))])],1)}),(_vm.Rooms.length==0)?_c('div',{staticClass:"empty"},[_c('Icon',{attrs:{"type":"md-wine","size":"50"}}),_vm._v("没有任何文件夹 ")],1):_vm._e()],2)}
|
||||
var staticRenderFns = []
|
||||
|
||||
|
||||
// CONCATENATED MODULE: ./index.vue?vue&type=template&id=c81a1b98&shadow
|
||||
|
||||
// CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./index.vue?vue&type=script&lang=js&shadow
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
/* harmony default export */ var lib_vue_loader_options_indexvue_type_script_lang_js_shadow = ({
|
||||
data() {
|
||||
return {
|
||||
Rooms: []
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
fetchlist() {
|
||||
window.ajax.getJSON("/ts/list").then(x => {
|
||||
this.Rooms = x;
|
||||
});
|
||||
},
|
||||
publish(item) {
|
||||
this.$Modal.confirm({
|
||||
title: "提示",
|
||||
content: "是否发布该目录",
|
||||
onOk() {
|
||||
window.ajax.getJSON(
|
||||
"/ts/publish?streamPath=" + item.StreamPath
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
unitFormat: window.unitFormat
|
||||
},
|
||||
mounted() {
|
||||
this.fetchlist();
|
||||
}
|
||||
});
|
||||
|
||||
// CONCATENATED MODULE: ./index.vue?vue&type=script&lang=js&shadow
|
||||
/* harmony default export */ var indexvue_type_script_lang_js_shadow = (lib_vue_loader_options_indexvue_type_script_lang_js_shadow);
|
||||
// CONCATENATED MODULE: ./index.vue?shadow
|
||||
|
||||
|
||||
|
||||
function injectStyles (context) {
|
||||
|
||||
var style0 = __webpack_require__("20f8")
|
||||
if (style0.__inject__) style0.__inject__(context)
|
||||
|
||||
}
|
||||
|
||||
/* normalize component */
|
||||
|
||||
var component = normalizeComponent(
|
||||
indexvue_type_script_lang_js_shadow,
|
||||
render,
|
||||
staticRenderFns,
|
||||
false,
|
||||
injectStyles,
|
||||
null,
|
||||
null
|
||||
,true
|
||||
)
|
||||
|
||||
/* harmony default export */ var indexshadow = (component.exports);
|
||||
// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-wc.js
|
||||
|
||||
|
||||
|
||||
|
||||
// runtime shared by every component chunk
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
window.customElements.define('plugin-ts', vue_wc_wrapper(external_Vue_default.a, indexshadow))
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "84d5":
|
||||
/***/ (function(module, exports, __webpack_require__) {
|
||||
|
||||
// style-loader: Adds some css to the DOM by adding a <style> tag
|
||||
|
||||
// load the styles
|
||||
var content = __webpack_require__("1471");
|
||||
if(typeof content === 'string') content = [[module.i, content, '']];
|
||||
if(content.locals) module.exports = content.locals;
|
||||
// add CSS to Shadow Root
|
||||
var add = __webpack_require__("35d6").default
|
||||
module.exports.__inject__ = function (shadowRoot) {
|
||||
add("452152fc", content, shadowRoot)
|
||||
};
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "8bbf":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = Vue;
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ "f6fd":
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
// document.currentScript polyfill by Adam Miller
|
||||
|
||||
// MIT license
|
||||
|
||||
(function(document){
|
||||
var currentScript = "currentScript",
|
||||
scripts = document.getElementsByTagName('script'); // Live NodeList collection
|
||||
|
||||
// If browser needs currentScript polyfill, add get currentScript() to the document object
|
||||
if (!(currentScript in document)) {
|
||||
Object.defineProperty(document, currentScript, {
|
||||
get: function(){
|
||||
|
||||
// IE 6-10 supports script readyState
|
||||
// IE 10+ support stack trace
|
||||
try { throw new Error(); }
|
||||
catch (err) {
|
||||
|
||||
// Find the second match for the "at" string to get file src url from stack.
|
||||
// Specifically works with the format of stack traces in IE.
|
||||
var i, res = ((/.*at [^\(]*\((.*):.+:.+\)$/ig).exec(err.stack) || [false])[1];
|
||||
|
||||
// For all scripts on the page, if src matches or if ready state is interactive, return the script tag
|
||||
for(i in scripts){
|
||||
if(scripts[i].src == res || scripts[i].readyState == "interactive"){
|
||||
return scripts[i];
|
||||
}
|
||||
}
|
||||
|
||||
// If no match, return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})(document);
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
//# sourceMappingURL=plugin-ts.js.map
|
1
dashboard/ui/plugin-ts.js.map
Normal file
1
dashboard/ui/plugin-ts.js.map
Normal file
File diff suppressed because one or more lines are too long
2
dashboard/ui/plugin-ts.min.js
vendored
Normal file
2
dashboard/ui/plugin-ts.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dashboard/ui/plugin-ts.min.js.map
Normal file
1
dashboard/ui/plugin-ts.min.js.map
Normal file
File diff suppressed because one or more lines are too long
106
main.go
106
main.go
@@ -2,7 +2,13 @@ package tsplugin
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
. "github.com/Monibuca/engine"
|
||||
@@ -11,17 +17,45 @@ import (
|
||||
"github.com/Monibuca/engine/util"
|
||||
)
|
||||
|
||||
func init() {
|
||||
var config = struct {
|
||||
BufferLength int
|
||||
Path string
|
||||
AutoPublish bool
|
||||
}{2048, "ts", true}
|
||||
|
||||
func init() {
|
||||
_, currentFilePath, _, _ := runtime.Caller(0)
|
||||
InstallPlugin(&PluginConfig{
|
||||
Name: "TS",
|
||||
Type: PLUGIN_PUBLISHER,
|
||||
Version: "1.0.1",
|
||||
UI: filepath.Join(filepath.Dir(currentFilePath), "dashboard", "ui", "plugin-ts.min.js"),
|
||||
Config: &config,
|
||||
Run: func() {
|
||||
if config.AutoPublish {
|
||||
OnSubscribeHooks.AddHook(func(s *OutputStream) {
|
||||
if s.Publisher == nil {
|
||||
new(TS).PublishDir(s.StreamPath)
|
||||
}
|
||||
})
|
||||
}
|
||||
http.HandleFunc("/ts/list", listTsDir)
|
||||
http.HandleFunc("/ts/publish", publishTsDir)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
type TSDir struct {
|
||||
StreamPath string
|
||||
TsCount int
|
||||
TotalSize int64
|
||||
}
|
||||
type TS struct {
|
||||
InputStream
|
||||
*mpegts.MpegTsStream
|
||||
TSInfo
|
||||
//TsChan chan io.Reader
|
||||
lastDts uint64
|
||||
parent Publisher
|
||||
}
|
||||
type TSInfo struct {
|
||||
TotalPesCount int
|
||||
@@ -165,19 +199,69 @@ func (ts *TS) run() {
|
||||
}
|
||||
}
|
||||
}
|
||||
func (ts *TS) OnClosed() {
|
||||
if ts.parent != nil {
|
||||
ts.parent.OnClosed()
|
||||
}
|
||||
}
|
||||
func (ts *TS) Publish(streamPath string, publisher Publisher) (result bool) {
|
||||
if publisher != ts {
|
||||
ts.parent = publisher
|
||||
}
|
||||
if result = ts.InputStream.Publish(streamPath, publisher); result {
|
||||
ts.TSInfo.RoomInfo = &ts.Room.RoomInfo
|
||||
ts.MpegTsStream = mpegts.NewMpegTsStream(2048)
|
||||
ts.MpegTsStream = mpegts.NewMpegTsStream(config.BufferLength)
|
||||
go ts.run()
|
||||
}
|
||||
return
|
||||
}
|
||||
func (ts *TS) PublishDir(streamPath string) {
|
||||
dirPath := filepath.Join(config.Path, streamPath)
|
||||
files, err := ioutil.ReadDir(dirPath)
|
||||
if err != nil || len(files) == 0 {
|
||||
return
|
||||
}
|
||||
if ts.InputStream.Publish(streamPath, ts) {
|
||||
ts.TSInfo.RoomInfo = &ts.Room.RoomInfo
|
||||
ts.MpegTsStream = mpegts.NewMpegTsStream(0)
|
||||
go ts.run()
|
||||
for _, file := range files {
|
||||
fullPath := filepath.Join(dirPath, file.Name())
|
||||
if filepath.Ext(fullPath) == ".ts" {
|
||||
if data, err := os.Open(fullPath); err == nil {
|
||||
ts.Feed(data)
|
||||
data.Close()
|
||||
}
|
||||
}
|
||||
}
|
||||
ts.Close()
|
||||
}
|
||||
}
|
||||
func publishTsDir(w http.ResponseWriter, r *http.Request) {
|
||||
streamPath := r.URL.Query().Get("streamPath")
|
||||
go new(TS).PublishDir(streamPath)
|
||||
}
|
||||
func readTsDir(currentDir string) []*TSDir {
|
||||
var list []*TSDir
|
||||
abDir := filepath.Join(config.Path, currentDir)
|
||||
if items, err := ioutil.ReadDir(abDir); err == nil {
|
||||
tscount := 0
|
||||
var totalSize int64
|
||||
for _, file := range items {
|
||||
if file.IsDir() {
|
||||
list = append(list, readTsDir(filepath.Join(currentDir, file.Name()))...)
|
||||
} else if filepath.Ext(filepath.Join(abDir, file.Name())) == ".ts" {
|
||||
tscount++
|
||||
totalSize = totalSize + file.Size()
|
||||
}
|
||||
}
|
||||
if tscount > 0 {
|
||||
info := TSDir{
|
||||
currentDir, tscount, totalSize,
|
||||
}
|
||||
list = append(list, &info)
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
func listTsDir(w http.ResponseWriter, r *http.Request) {
|
||||
var list []*TSDir = readTsDir(".")
|
||||
bytes, err := json.Marshal(list)
|
||||
if err == nil {
|
||||
w.Write(bytes)
|
||||
} else {
|
||||
w.Write([]byte("{\"code\":1}"))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user