Commit dccc8998 by haojie

提交文件大小

parent 478e5d31
import { app, BrowserWindow, Menu } from 'electron';
function createWindow() {
// 去掉菜单
Menu.setApplicationMenu(null);
// 创建浏览器窗口
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
},
});
// 并且为你的应用加载index.html
win.loadFile('index.html');
// 打开开发者工具
// win.webContents.openDevTools()
}
// Electron会在初始化完成并且准备好创建浏览器窗口时调用这个方法
// 部分 API 在 ready 事件触发后才能使用。
app.whenReady().then(createWindow);
//当所有窗口都被关闭后退出
app.on('window-all-closed', () => {
// 在 macOS 上,除非用户用 Cmd + Q 确定地退出,
// 否则绝大部分应用及其菜单栏会保持激活。
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
// 在macOS上,当单击dock图标并且没有其他窗口打开时,
// 通常在应用程序中重新创建一个窗口。
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
{
"name": "electron-quick-start",
"version": "1.0.0",
"description": "A minimal Electron application",
"main": "main.js",
"scripts": {
"start": "electron .",
"package": "electron-packager . HelloWorld --platform=win32 --arch=x64 --icon=computer.ico --out=./out --asar --app-version=0.0.1 --overwrite --ignore=node_modules"
},
"repository": "https://github.com/electron/electron-quick-start",
"keywords": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"author": "GitHub",
"license": "CC0-1.0",
"devDependencies": {
"electron": "^9.0.0"
},
"dependencies": {
"electron-packager": "^14.2.1"
}
}
{
"name": "snow-mobile",
"name": "tiktok-upload",
"private": true,
"version": "0.0.0",
"type": "module",
......@@ -30,6 +30,7 @@
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"axios": "^0.24.0",
"electron": "^25.2.0",
"express": "^4.18.2",
"http-proxy-middleware": "^2.0.6",
"less": "^4.1.1",
......
......@@ -141,7 +141,11 @@ export default defineComponent({
// return { name: 'FileName', url: response.url };
};
// 上传成功回调
const UploadSuccessCallback = (uuid: any, url: any) => {
const UploadSuccessCallback = (
uuid: any,
url: any = '',
fileSize: any = ''
) => {
// 关闭定时器
window.clearInterval(percentageInterval);
MessagePlugin.success('上传成功');
......@@ -149,7 +153,7 @@ export default defineComponent({
Curfile.url = url;
// 成功2
Curfile.status = 2;
emit('UploadVideo', props.index, Curfile.url);
emit('UploadVideo', props.index, Curfile.url, fileSize);
};
// 上传失败回调
const UploadErrorCallback = () => {
......@@ -158,7 +162,7 @@ export default defineComponent({
Curfile.url = '';
// 失败0
Curfile.status = 0;
emit('UploadVideo', props.index, Curfile.url);
emit('UploadVideo', props.index);
MessagePlugin.warning('上传失败');
};
// 内网上传-Intranet
......@@ -172,7 +176,6 @@ export default defineComponent({
if (import.meta.env.MODE == 'production') {
// 线上地址使用完整url
url = adminConfigUrl.value + 'video/' + uuid + '.mp4';
// url = `http://192.168.1.19:5000/video/` + uuid + '.mp4';
} else if (import.meta.env.MODE == 'app') {
// app
url = '/video/' + uuid + '.mp4';
......@@ -181,11 +184,7 @@ export default defineComponent({
url = '/video/' + uuid + '.mp4';
}
const timer = setTimeout(() => {
let http = xhr();
// 中断上传
const CancelToken = axios.CancelToken;
request.put(url, file[0].raw).then((res: any) => {
// resolve 参数为关键代码
if (res == 200) {
let url = adminConfigUrl.value + 'video/' + uuid + '.mp4';
UploadSuccessCallback(uuid, url);
......@@ -201,17 +200,6 @@ export default defineComponent({
Curfile.uploadStatus = false;
}
});
// http.request(
// 'post',
// url,
// file[0].raw,
// function (res: any) {
// console.log(res);
// },
// function (err: any) {
// console.log(err);
// }
// );
}, 1000);
});
};
......@@ -232,6 +220,9 @@ export default defineComponent({
// url = '/files';
url = 'https://' + config.host;
}
// 获取文件大小
let fileSize: any = file[0].size / 1024 / 1024;
fileSize = fileSize.toFixed(3);
const timer = setTimeout(() => {
let formData = new FormData();
formData.append('key', config.dir + uuid + '.mp4');
......@@ -250,11 +241,10 @@ export default defineComponent({
},
})
.then((res: any) => {
// resolve 参数为关键代码
if (res == 200) {
// 外网url
let url = config.domain + config.dir + uuid + '.mp4';
UploadSuccessCallback(uuid, url);
UploadSuccessCallback(uuid, url, fileSize);
//
Curfile.uploadStatus = true;
resolve({
......
......@@ -71,8 +71,13 @@ export default defineComponent({
};
//
// 上传视频成功回调
const UploadVideo = (index: number, url: string) => {
const UploadVideo = (
index: number,
url: string = '',
size: string = ''
) => {
uploadList2.value[`r${accountId.value}`][index].files = url;
uploadList2.value[`r${accountId.value}`][index].file_size = size;
};
// 文本提交
const TextareaChange = (index: number, value: string) => {
......@@ -107,6 +112,7 @@ export default defineComponent({
let obj: any = {
video_url: current_account_data[index].files,
title: current_account_data[index].textValue,
file_size: current_account_data[index].file_size,
};
if (current_account_data[index].time_release) {
obj.startTime = current_account_data[index].time_release;
......
/*
* @Author: walker.liu
* @Date: 2022-05-24 10:51:56
* @Copyright(C): 2019-2020 ZP Inc. All rights reserved.
*/
import store from '@/store';
import request from '@/utils/request';
import { PriceAccuracy, computedTime } from './tool';
declare const TradingView: any;
/**
* @key Server ding字段 supported_resolutions
*/
// 1min, 5min, 15min, 30min, 60min, 4hour, 1day, 1mon, 1week, 1year
export const intervalMap = {
'1min': '1',
'5min': '5',
'15min': '15',
'30min': '30',
'60min': '60',
'4hour': '240',
'1day': 'D',
'1week': 'W',
'1mon': 'M',
};
/** trading-view 的時間區間 */
export const supportedResolutions = [
'1',
'5',
'15',
'30',
'60',
'240',
'D',
'W',
'M',
];
export class DataFeed {
private symbolInfo: any;
private subscribers: any[] = [];
private interval: any = null;
private resolution = '1';
// 每个时间段都要给5次重试次数
private RetryTime: any = {
r1: 0,
r5: 0,
r15: 0,
r60: 0,
r240: 0,
r1D: 0,
};
private KPirce: any = null;
constructor(symbolInfo: any, timeInterval = 1000) {
this.KPirce = symbolInfo.KPirce;
// 将传过来的多余参数剔除
delete symbolInfo.KPirce;
this.symbolInfo = symbolInfo;
this.intervalGetBars(symbolInfo.ticker, timeInterval);
}
public onReady(onGameLoad: any) {
new Promise((resolve) => {
resolve(void 0);
}).then(() => {
onGameLoad({
supported_resolutions: supportedResolutions,
});
});
}
public searchSymbols() {}
public resolveSymbol(
symbolName: any,
onSymbolResolvedCallback: any,
onResolveErrorCallback: any
) {
new Promise((resolve) => {
resolve(void 0);
}).then(() => {
let PriceNum = 10000000000;
PriceNum = PriceAccuracy(this.KPirce);
onSymbolResolvedCallback({
session: '24x7',
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
supported_resolutions: supportedResolutions,
has_intraday: true,
has_daily: true,
// has_no_volume: true,
minmov: 1,
// minmove2:0,
// 最多支持16位小数
pricescale: PriceNum,
...this.symbolInfo,
});
});
}
/**
* 订阅K线数据。图表库将调用onRealtimeCallback方法以更新实时数据
*/
public subscribeBars(
symbolInfo: any,
resolution: string,
onRealtimeCallback: any,
subscriberUID: any,
onResetCacheNeededCallback: () => void
) {
if (this.subscribers[subscriberUID]) {
return;
}
this.resolution = resolution;
this.subscribers[subscriberUID] = {
lastBarTime: null,
listener: onRealtimeCallback,
resolution: resolution,
symbolInfo: symbolInfo,
};
}
/**
* 取消订阅K线数据
*/
public unsubscribeBars(subscriberUID: any) {
if (!this.subscribers[subscriberUID]) {
return;
}
delete this.subscribers[subscriberUID];
}
public updateKLine(bar: any) {
for (const listenerGuid in this.subscribers) {
const subscriptionRecord = this.subscribers[listenerGuid];
if (
subscriptionRecord.lastBarTime !== null &&
bar.time < subscriptionRecord.lastBarTime
) {
continue;
}
subscriptionRecord.lastBarTime = bar.time;
subscriptionRecord.listener(bar);
}
}
public async getBars(
symbolInfo: any,
resolution: any,
periodParams: any,
onHistoryCallback: any,
onErrorCallback: any
) {
try {
const token = store.getters['user/token'];
let params = {
...periodParams,
resolution,
symbol: symbolInfo.ticker,
};
params.from = params.from * 1000;
params.to = params.to * 1000;
// 是否第一次請求歷史數據
if (periodParams.firstDataRequest) {
params.to = Date.now();
params.is_first = true;
// 添加limit
params.limit = params.countBack + 50;
delete params.firstDataRequest;
delete params.countBack;
} else {
params.is_first = false;
delete params.firstDataRequest;
// 添加limit
params.limit = params.countBack;
delete params.countBack;
}
request
.get(`/api/currencies/kline`, {
params: params,
headers: {
authorization: `Bearer ${token}`,
},
})
.then((res: any) => {
let result = {
bars: [],
meta: { noData: false },
};
if (
res.data.list &&
res.data.list.length > 0 &&
this.RetryTime[`r${resolution}`] < 5
) {
result.meta.noData = false;
result.bars = res.data.list.map((item: any) => {
return {
time: item.ts,
open: item.open,
high: item.high,
low: item.low,
close: item.close,
volume: item.volume,
};
});
store.commit(
'token/setTradePrice',
res.data.list[res.data.list.length - 1].close
);
} else {
if (this.RetryTime[`r${resolution}`] < 5) {
this.RetryTime[`r${resolution}`] += 1;
} else {
result.meta.noData = true;
}
}
onHistoryCallback(result.bars, result.meta);
});
} catch (error) {
onHistoryCallback({
bars: [],
meta: { noData: true },
});
}
}
public intervalGetBars(symbol: any, timeInterval: number) {
this.interval = setInterval(() => {
const token = store.getters['user/token'];
let from = computedTime(this.resolution);
let current = new Date().getTime();
let params = {
resolution: this.resolution,
to: current,
// from: current - timeInterval,
from: from ? from : current - timeInterval,
// from: current - 5000,
symbol: symbol,
is_first: false,
limit: 2,
};
request
.get(`/api/currencies/kline`, {
params: params,
headers: {
authorization: `Bearer ${token}`,
},
})
.then((res: any) => {
if (res && res.data.list.length) {
res.data.list.forEach((item: any) => {
this.updateKLine({
time: item.ts,
open: item.open,
high: item.high,
low: item.low,
close: item.close,
volume: item.volume,
});
});
store.commit(
'token/setTradePrice',
res.data.list[res.data.list.length - 1].close
);
}
});
}, 5000);
}
public clearIntervalGetBars() {
window.clearInterval(this.interval);
}
}
export class Widget {
private options: any;
public widget = null;
constructor(options = {}) {
const mode = store.getters['theme/getTheme'];
// 语言
const language = store.getters['language/getLang'];
// 获取当前语言
let CurLanguage = 'zh';
if (language == 'cn') {
CurLanguage = 'zh';
} else if (language == 'es') {
CurLanguage = 'es';
} else if (language == 'en') {
CurLanguage = 'en';
}
let VITE_MODE = import.meta.env.MODE;
this.options = {
// debug: true,
library_path:
VITE_MODE == 'app' ? './charting_library/' : '/charting_library/',
// 主题
theme: mode,
locale: CurLanguage,
autosize: 1,
container: 'tv_chart_container',
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
interval: '1',
// toolbar_bg: '#ffffff', //左侧工具栏背景色
favorites: {
intervals: ['1', '5', '15', '60', '240', 'D', 'W', 'M'],
chartTypes: ['Candles', 'Line'],
},
// enabled_features: ['study_templates'],
disabled_features: [
'header_symbol_search',
'left_toolbar', // 隐藏左侧工具栏
'timeframes_toolbar', //底部tab
'header_compare',
'header_saveload',
'header_fullscreen_button',
'header_screenshot', //截图相机
'vert_touch_drag_scroll', //垂直移动
// 禁用本地存储功能
// 'use_localstorage_for_settings',
'save_chart_properties_to_local_storage',
],
overrides: {
// 默认展示的图表
'mainSeriesProperties.style': 1,
// 'mainSeriesProperties.highLowAvgPrice.highLowPriceLinesVisible': true, //高低线值
// 'mainSeriesProperties.highLowAvgPrice.highLowPriceLabelsVisible': true, //高低线名称
// 'mainSeriesProperties.highLowAvgPrice.averageClosePriceLineVisible':
// true, //均线
// 'mainSeriesProperties.highLowAvgPrice.averageClosePriceLabelVisible':
// true, //均线
},
custom_css_url:
VITE_MODE == 'app'
? './src/style/tradingview.less'
: '/src/style/tradingview.less',
...options,
};
this.initWidget();
}
public initWidget() {
try {
this.widget = window.tvWidget = new TradingView.widget(this.options);
} catch (e) {
console.log(e);
console.log('TradingView--bug');
}
}
}
......@@ -14,7 +14,7 @@ export default defineConfig(({ command, mode }) => {
}-${date.getDate()}--${date.getHours()}.${date.getMinutes()}`;
// tiktok.upload.com
// http://videopublish.test
let api = 0 ? 'http://42.194.143.229:90' : 'http://tiktok.test';
let api = 0 ? 'http://42.194.143.229:90' : 'http://192.168.1.5:9002';
return {
base: '/',
resolve: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment