SettingsPage.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  1. <template>
  2. <Window ref="window" width="600px" @close="close">
  3. <template #header>
  4. Настройки
  5. </template>
  6. <div class="col row">
  7. <a ref="download" style="display: none;" target="_blank"></a>
  8. <div class="full-height">
  9. <q-tabs
  10. ref="tabs"
  11. v-model="selectedTab"
  12. class="bg-grey-3 text-black"
  13. left-icon="la la-caret-up"
  14. right-icon="la la-caret-down"
  15. active-color="white"
  16. active-bg-color="primary"
  17. indicator-color="black"
  18. vertical
  19. no-caps
  20. stretch
  21. inline-label
  22. >
  23. <div v-show="tabsScrollable" class="q-pt-lg" />
  24. <q-tab class="tab" name="profiles" icon="la la-users" label="Профили" />
  25. <q-tab class="tab" name="view" icon="la la-eye" label="Вид" />
  26. <q-tab class="tab" name="toolbar" icon="la la-grip-horizontal" label="Панель" />
  27. <q-tab class="tab" name="keys" icon="la la-gamepad" label="Управление" />
  28. <q-tab class="tab" name="pagemove" icon="la la-school" label="Листание" />
  29. <q-tab class="tab" name="convert" icon="la la-magic" label="Конвертир." />
  30. <q-tab class="tab" name="update" icon="la la-sync" label="Обновление" />
  31. <q-tab class="tab" name="others" icon="la la-list-ul" label="Прочее" />
  32. <q-tab class="tab" name="reset" icon="la la-broom" label="Сброс" />
  33. <div v-show="tabsScrollable" class="q-pt-lg" />
  34. </q-tabs>
  35. </div>
  36. <div class="col fit">
  37. <!-- Профили --------------------------------------------------------------------->
  38. <!--div v-if="selectedTab == 'profiles'" class="fit tab-panel">
  39. @@include('./ProfilesTab.inc');
  40. </div-->
  41. <!-- Вид ------------------------------------------------------------------------->
  42. <!--div v-if="selectedTab == 'view'" class="fit column">
  43. <q-tabs
  44. v-model="selectedViewTab"
  45. active-color="black"
  46. active-bg-color="white"
  47. indicator-color="white"
  48. dense
  49. no-caps
  50. class="no-mp bg-grey-4 text-grey-7"
  51. >
  52. <q-tab name="mode" label="Режим" />
  53. <q-tab name="color" label="Цвет" />
  54. <q-tab name="font" label="Шрифт" />
  55. <q-tab name="text" label="Текст" />
  56. <q-tab name="status" label="Строка статуса" />
  57. </q-tabs>
  58. <div class="q-mb-sm" />
  59. <div class="col tab-panel">
  60. <div v-if="selectedViewTab == 'mode'">
  61. @@include('./ViewTab/Mode.inc');
  62. </div>
  63. <div v-if="selectedViewTab == 'color'">
  64. @@include('./ViewTab/Color.inc');
  65. </div>
  66. <div v-if="selectedViewTab == 'font'">
  67. @@include('./ViewTab/Font.inc');
  68. </div>
  69. <div v-if="selectedViewTab == 'text'">
  70. @@include('./ViewTab/Text.inc');
  71. </div>
  72. <div v-if="selectedViewTab == 'status'">
  73. @@include('./ViewTab/Status.inc');
  74. </div>
  75. </div>
  76. </div-->
  77. <!-- Кнопки ---------------------------------------------------------------------->
  78. <div v-if="selectedTab == 'toolbar'" class="fit tab-panel">
  79. <ToolBarTab :form="form" />
  80. </div>
  81. <!-- Управление ------------------------------------------------------------------>
  82. <!--div v-if="selectedTab == 'keys'" class="fit column">
  83. @@include('./KeysTab.inc');
  84. </div-->
  85. <!-- Листание -------------------------------------------------------------------->
  86. <!--div v-if="selectedTab == 'pagemove'" class="fit tab-panel">
  87. @@include('./PageMoveTab.inc');
  88. </div-->
  89. <!-- Конвертирование ------------------------------------------------------------->
  90. <!--div v-if="selectedTab == 'convert'" class="fit tab-panel">
  91. @@include('./ConvertTab.inc');
  92. </div-->
  93. <!-- Обновление ------------------------------------------------------------------>
  94. <!--div v-if="selectedTab == 'update'" class="fit tab-panel">
  95. @@include('./UpdateTab.inc');
  96. </div-->
  97. <!-- Прочее ---------------------------------------------------------------------->
  98. <!--div v-if="selectedTab == 'others'" class="fit tab-panel">
  99. @@include('./OthersTab.inc');
  100. </div-->
  101. <!-- Сброс ----------------------------------------------------------------------->
  102. <!--div v-if="selectedTab == 'reset'" class="fit tab-panel">
  103. @@include('./ResetTab.inc');
  104. </div-->
  105. </div>
  106. </div>
  107. </Window>
  108. </template>
  109. <script>
  110. //-----------------------------------------------------------------------------
  111. import vueComponent from '../../vueComponent.js';
  112. import _ from 'lodash';
  113. //stuff
  114. import * as utils from '../../../share/utils';
  115. import * as cryptoUtils from '../../../share/cryptoUtils';
  116. import Window from '../../share/Window.vue';
  117. import NumInput from '../../share/NumInput.vue';
  118. import UserHotKeys from './UserHotKeys/UserHotKeys.vue';
  119. import wallpaperStorage from '../share/wallpaperStorage';
  120. import readerApi from '../../../api/reader';
  121. import rstore from '../../../store/modules/reader';
  122. import defPalette from './defPalette';
  123. //pages
  124. import ToolBarTab from './ToolBarTab/ToolBarTab.vue';
  125. const hex = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;
  126. const componentOptions = {
  127. components: {
  128. Window,
  129. NumInput,
  130. UserHotKeys,
  131. //pages
  132. ToolBarTab,
  133. },
  134. watch: {
  135. settings: function() {
  136. this.settingsChanged();
  137. },
  138. form: {
  139. handler(newValue) {
  140. if (this.inited) {
  141. console.log('save settings');
  142. this.commit('reader/setSettings', _.cloneDeep(newValue));
  143. }
  144. },
  145. deep: true,
  146. },
  147. fontBold: function(newValue) {
  148. this.fontWeight = (newValue ? 'bold' : '');
  149. },
  150. fontItalic: function(newValue) {
  151. this.fontStyle = (newValue ? 'italic' : '');
  152. },
  153. vertShift: function(newValue) {
  154. const font = (this.webFontName ? this.webFontName : this.fontName);
  155. if (this.fontShifts[font] != newValue || this.fontVertShift != newValue) {
  156. this.fontShifts = Object.assign({}, this.fontShifts, {[font]: newValue});
  157. this.fontVertShift = newValue;
  158. }
  159. },
  160. fontName: function(newValue) {
  161. const font = (this.webFontName ? this.webFontName : newValue);
  162. this.vertShift = this.fontShifts[font] || 0;
  163. },
  164. webFontName: function(newValue) {
  165. const font = (newValue ? newValue : this.fontName);
  166. this.vertShift = this.fontShifts[font] || 0;
  167. },
  168. wallpaper: function(newValue) {
  169. if (newValue != '' && this.pageChangeAnimation == 'flip')
  170. this.pageChangeAnimation = '';
  171. },
  172. dualPageMode(newValue) {
  173. if (newValue && this.pageChangeAnimation == 'flip' || this.pageChangeAnimation == 'rightShift')
  174. this.pageChangeAnimation = '';
  175. },
  176. textColor: function(newValue) {
  177. this.textColorFiltered = newValue;
  178. },
  179. textColorFiltered: function(newValue) {
  180. if (hex.test(newValue))
  181. this.textColor = newValue;
  182. },
  183. backgroundColor: function(newValue) {
  184. this.bgColorFiltered = newValue;
  185. },
  186. bgColorFiltered: function(newValue) {
  187. if (hex.test(newValue))
  188. this.backgroundColor = newValue;
  189. },
  190. dualDivColor(newValue) {
  191. this.dualDivColorFiltered = newValue;
  192. },
  193. dualDivColorFiltered(newValue) {
  194. if (hex.test(newValue))
  195. this.dualDivColor = newValue;
  196. },
  197. statusBarColor(newValue) {
  198. this.statusBarColorFiltered = newValue;
  199. },
  200. statusBarColorFiltered(newValue) {
  201. if (hex.test(newValue))
  202. this.statusBarColor = newValue;
  203. },
  204. },
  205. };
  206. class SettingsPage {
  207. _options = componentOptions;
  208. form = {};
  209. selectedTab = 'profiles';
  210. selectedViewTab = 'mode';
  211. selectedKeysTab = 'mouse';
  212. fontBold = false;
  213. fontItalic = false;
  214. vertShift = 0;
  215. tabsScrollable = false;
  216. textColorFiltered = '';
  217. bgColorFiltered = '';
  218. dualDivColorFiltered = '';
  219. statusBarColorFiltered = '';
  220. webFonts = [];
  221. fonts = [];
  222. serverStorageKeyVisible = false;
  223. created() {
  224. this.commit = this.$store.commit;
  225. this.reader = this.$store.state.reader;
  226. this.settingsChanged();
  227. }
  228. mounted() {
  229. this.$watch(
  230. '$refs.tabs.scrollable',
  231. (newValue) => {
  232. this.tabsScrollable = newValue && !this.$root.isMobileDevice;
  233. }
  234. );
  235. }
  236. init() {
  237. this.$refs.window.init();
  238. this.inited = true;
  239. }
  240. settingsChanged() {
  241. if (_.isEqual(this.form, this.settings))
  242. return;
  243. this.form = _.cloneDeep(this.settings);
  244. const form = this.form;
  245. this.fontBold = (form.fontWeight == 'bold');
  246. this.fontItalic = (form.fontStyle == 'italic');
  247. this.fonts = rstore.fonts;
  248. this.webFonts = rstore.webFonts;
  249. const font = (form.webFontName ? form.webFontName : form.fontName);
  250. this.vertShift = form.fontShifts[font] || 0;
  251. this.textColorFiltered = form.textColor;
  252. this.bgColorFiltered = form.backgroundColor;
  253. this.dualDivColorFiltered = form.dualDivColor;
  254. this.statusBarColorFiltered = form.statusBarColor;
  255. }
  256. get mode() {
  257. return this.$store.state.config.mode;
  258. }
  259. get isExternalConverter() {
  260. return this.$store.state.config.useExternalBookConverter;
  261. }
  262. get settings() {
  263. return this.$store.state.reader.settings;
  264. }
  265. get serverSyncEnabled() {
  266. return this.$store.state.reader.serverSyncEnabled;
  267. }
  268. set serverSyncEnabled(newValue) {
  269. this.commit('reader/setServerSyncEnabled', newValue);
  270. }
  271. get profiles() {
  272. return this.$store.state.reader.profiles;
  273. }
  274. get configBucEnabled() {
  275. return this.$store.state.config.bucEnabled;
  276. }
  277. get currentProfileOptions() {
  278. const profNames = Object.keys(this.profiles)
  279. profNames.sort();
  280. let result = [{label: 'Нет', value: ''}];
  281. profNames.forEach(name => {
  282. result.push({label: name, value: name});
  283. });
  284. return result;
  285. }
  286. get wallpaperOptions() {
  287. let result = [{label: 'Нет', value: ''}];
  288. const userWallpapers = _.cloneDeep(this.userWallpapers);
  289. userWallpapers.sort((a, b) => a.label.localeCompare(b.label));
  290. for (const wp of userWallpapers) {
  291. if (wallpaperStorage.keyExists(wp.cssClass))
  292. result.push({label: wp.label, value: wp.cssClass});
  293. }
  294. for (let i = 1; i <= 17; i++) {
  295. result.push({label: i, value: `paper${i}`});
  296. }
  297. return result;
  298. }
  299. get fontsOptions() {
  300. let result = [];
  301. this.fonts.forEach(font => {
  302. result.push({label: (font.label ? font.label : font.name), value: font.name});
  303. });
  304. return result;
  305. }
  306. get webFontsOptions() {
  307. let result = [{label: 'Нет', value: ''}];
  308. this.webFonts.forEach(font => {
  309. result.push({label: font.name, value: font.name});
  310. });
  311. return result;
  312. }
  313. get pageChangeAnimationOptions() {
  314. let result = [
  315. {label: 'Нет', value: ''},
  316. {label: 'Вверх-вниз', value: 'downShift'},
  317. (!this.dualPageMode ? {label: 'Вправо-влево', value: 'rightShift'} : null),
  318. {label: 'Протаивание', value: 'thaw'},
  319. {label: 'Мерцание', value: 'blink'},
  320. {label: 'Вращение', value: 'rotate'},
  321. (this.wallpaper == '' && !this.dualPageMode ? {label: 'Листание', value: 'flip'} : null),
  322. ];
  323. result = result.filter(v => v);
  324. return result;
  325. }
  326. get currentProfile() {
  327. return this.$store.state.reader.currentProfile;
  328. }
  329. set currentProfile(newValue) {
  330. this.commit('reader/setCurrentProfile', newValue);
  331. }
  332. get partialStorageKey() {
  333. return this.serverStorageKey.substr(0, 7) + '***';
  334. }
  335. get serverStorageKey() {
  336. return this.$store.state.reader.serverStorageKey;
  337. }
  338. get setStorageKeyLink() {
  339. return `https://${window.location.host}/#/reader?setStorageAccessKey=${utils.toBase58(this.serverStorageKey)}`;
  340. }
  341. get predefineTextColors() {
  342. return defPalette.concat([
  343. '#ffffff',
  344. '#000000',
  345. '#202020',
  346. '#323232',
  347. '#aaaaaa',
  348. '#00c0c0',
  349. '#ebe2c9',
  350. '#cfdc99',
  351. '#478355',
  352. '#909080',
  353. ]);
  354. }
  355. get predefineBackgroundColors() {
  356. return defPalette.concat([
  357. '#ffffff',
  358. '#000000',
  359. '#202020',
  360. '#ebe2c9',
  361. '#cfdc99',
  362. '#478355',
  363. '#a6caf0',
  364. '#909080',
  365. '#808080',
  366. '#c8c8c8',
  367. ]);
  368. }
  369. colorPanStyle(type) {
  370. let result = 'width: 30px; height: 30px; border: 1px solid black; border-radius: 4px;';
  371. switch (type) {
  372. case 'text':
  373. result += `background-color: ${this.textColor};`
  374. break;
  375. case 'bg':
  376. result += `background-color: ${this.backgroundColor};`
  377. break;
  378. case 'div':
  379. result += `background-color: ${this.dualDivColor};`
  380. break;
  381. case 'statusbar':
  382. result += `background-color: ${this.statusBarColor};`
  383. break;
  384. }
  385. return result;
  386. }
  387. needReload() {
  388. this.$root.notify.warning('Необходимо обновить страницу (F5), чтобы изменения возымели эффект');
  389. }
  390. needTextReload() {
  391. this.$root.notify.warning('Необходимо обновить книгу в обход кэша, чтобы изменения возымели эффект');
  392. }
  393. close() {
  394. this.$emit('do-action', {action: 'settings'});
  395. }
  396. async setDefaults() {
  397. try {
  398. if (await this.$root.stdDialog.confirm('Подтвердите установку настроек по умолчанию:', ' ')) {
  399. this.form = Object.assign({}, rstore.settingDefaults);
  400. for (let prop in rstore.settingDefaults) {
  401. this[prop] = this.form[prop];
  402. }
  403. }
  404. } catch (e) {
  405. //
  406. }
  407. }
  408. async addProfile() {
  409. try {
  410. if (Object.keys(this.profiles).length >= 100) {
  411. this.$root.stdDialog.alert('Достигнут предел количества профилей', 'Ошибка');
  412. return;
  413. }
  414. const result = await this.$root.stdDialog.prompt('Введите произвольное название для профиля устройства:', ' ', {
  415. inputValidator: (str) => { if (!str) return 'Название не должно быть пустым'; else if (str.length > 50) return 'Слишком длинное название'; else return true; },
  416. });
  417. if (result && result.value) {
  418. if (this.profiles[result.value]) {
  419. this.$root.stdDialog.alert('Такой профиль уже существует', 'Ошибка');
  420. } else {
  421. const newProfiles = Object.assign({}, this.profiles, {[result.value]: 1});
  422. this.commit('reader/setAllowProfilesSave', true);
  423. await this.$nextTick();//ждем обработчики watch
  424. this.commit('reader/setProfiles', newProfiles);
  425. await this.$nextTick();//ждем обработчики watch
  426. this.commit('reader/setAllowProfilesSave', false);
  427. this.currentProfile = result.value;
  428. }
  429. }
  430. } catch (e) {
  431. //
  432. }
  433. }
  434. async delProfile() {
  435. if (!this.currentProfile)
  436. return;
  437. try {
  438. const result = await this.$root.stdDialog.prompt(`<b>Предупреждение!</b> Удаление профиля '${this.$root.sanitize(this.currentProfile)}' необратимо.` +
  439. `<br>Все настройки профиля будут потеряны, однако список читаемых книг сохранится.` +
  440. `<br><br>Введите 'да' для подтверждения удаления:`, ' ', {
  441. inputValidator: (str) => { if (str && str.toLowerCase() === 'да') return true; else return 'Удаление не подтверждено'; },
  442. });
  443. if (result && result.value && result.value.toLowerCase() == 'да') {
  444. if (this.profiles[this.currentProfile]) {
  445. const newProfiles = Object.assign({}, this.profiles);
  446. delete newProfiles[this.currentProfile];
  447. this.commit('reader/setAllowProfilesSave', true);
  448. await this.$nextTick();//ждем обработчики watch
  449. this.commit('reader/setProfiles', newProfiles);
  450. await this.$nextTick();//ждем обработчики watch
  451. this.commit('reader/setAllowProfilesSave', false);
  452. this.currentProfile = '';
  453. }
  454. }
  455. } catch (e) {
  456. //
  457. }
  458. }
  459. async delAllProfiles() {
  460. if (!Object.keys(this.profiles).length)
  461. return;
  462. try {
  463. const result = await this.$root.stdDialog.prompt(`<b>Предупреждение!</b> Удаление ВСЕХ профилей с настройками необратимо.` +
  464. `<br><br>Введите 'да' для подтверждения удаления:`, ' ', {
  465. inputValidator: (str) => { if (str && str.toLowerCase() === 'да') return true; else return 'Удаление не подтверждено'; },
  466. });
  467. if (result && result.value && result.value.toLowerCase() == 'да') {
  468. this.commit('reader/setAllowProfilesSave', true);
  469. await this.$nextTick();//ждем обработчики watch
  470. this.commit('reader/setProfiles', {});
  471. await this.$nextTick();//ждем обработчики watch
  472. this.commit('reader/setAllowProfilesSave', false);
  473. this.currentProfile = '';
  474. }
  475. } catch (e) {
  476. //
  477. }
  478. }
  479. async copyToClip(text, prefix) {
  480. const result = await utils.copyTextToClipboard(text);
  481. const suf = (prefix.substr(-1) == 'а' ? 'а' : '');
  482. const msg = (result ? `${prefix} успешно скопирован${suf} в буфер обмена` : 'Копирование не удалось');
  483. if (result)
  484. this.$root.notify.success(msg);
  485. else
  486. this.$root.notify.error(msg);
  487. }
  488. async showServerStorageKey() {
  489. this.serverStorageKeyVisible = !this.serverStorageKeyVisible;
  490. }
  491. async enterServerStorageKey(key) {
  492. try {
  493. const result = await this.$root.stdDialog.prompt(`<b>Предупреждение!</b> Изменение ключа доступа приведет к замене всех профилей и читаемых книг в читалке.` +
  494. `<br><br>Введите новый ключ доступа:`, ' ', {
  495. inputValidator: (str) => {
  496. try {
  497. if (str && utils.fromBase58(str).length == 32) {
  498. return true;
  499. }
  500. } catch (e) {
  501. //
  502. }
  503. return 'Неверный формат ключа';
  504. },
  505. inputValue: (key && _.isString(key) ? key : null),
  506. });
  507. if (result && result.value && utils.fromBase58(result.value).length == 32) {
  508. this.commit('reader/setServerStorageKey', result.value);
  509. }
  510. } catch (e) {
  511. //
  512. }
  513. }
  514. async generateServerStorageKey() {
  515. try {
  516. const result = await this.$root.stdDialog.prompt(`<b>Предупреждение!</b> Генерация нового ключа доступа приведет к удалению всех профилей и читаемых книг в читалке.` +
  517. `<br><br>Введите 'да' для подтверждения генерации нового ключа:`, ' ', {
  518. inputValidator: (str) => { if (str && str.toLowerCase() === 'да') return true; else return 'Генерация не подтверждена'; },
  519. });
  520. if (result && result.value && result.value.toLowerCase() == 'да') {
  521. if (this.$root.generateNewServerStorageKey)
  522. this.$root.generateNewServerStorageKey();
  523. }
  524. } catch (e) {
  525. //
  526. }
  527. }
  528. loadWallpaperFileClick() {
  529. this.$refs.file.click();
  530. }
  531. loadWallpaperFile() {
  532. const file = this.$refs.file.files[0];
  533. if (file.size > 10*1024*1024) {
  534. this.$root.stdDialog.alert('Файл обоев не должен превышать в размере 10Mb', 'Ошибка');
  535. return;
  536. }
  537. if (file.type != 'image/png' && file.type != 'image/jpeg') {
  538. this.$root.stdDialog.alert('Файл обоев должен иметь тип PNG или JPEG', 'Ошибка');
  539. return;
  540. }
  541. if (this.userWallpapers.length >= 100) {
  542. this.$root.stdDialog.alert('Превышено максимальное количество пользовательских обоев.', 'Ошибка');
  543. return;
  544. }
  545. this.$refs.file.value = '';
  546. if (file) {
  547. const reader = new FileReader();
  548. reader.onload = (e) => {
  549. (async() => {
  550. const data = e.target.result;
  551. const key = utils.toHex(cryptoUtils.sha256(data));
  552. const label = `#${key.substring(0, 4)}`;
  553. const cssClass = `user-paper${key}`;
  554. const newUserWallpapers = _.cloneDeep(this.userWallpapers);
  555. const index = _.findIndex(newUserWallpapers, (item) => (item.cssClass == cssClass));
  556. if (index < 0)
  557. newUserWallpapers.push({label, cssClass});
  558. if (!wallpaperStorage.keyExists(cssClass)) {
  559. await wallpaperStorage.setData(cssClass, data);
  560. //отправим data на сервер в файл `/upload/${key}`
  561. try {
  562. //const res =
  563. await readerApi.uploadFileBuf(data);
  564. //console.log(res);
  565. } catch (e) {
  566. console.error(e);
  567. }
  568. }
  569. this.userWallpapers = newUserWallpapers;
  570. this.wallpaper = cssClass;
  571. })();
  572. }
  573. reader.readAsDataURL(file);
  574. }
  575. }
  576. async delWallpaper() {
  577. if (this.wallpaper.indexOf('user-paper') == 0) {
  578. const newUserWallpapers = [];
  579. for (const wp of this.userWallpapers) {
  580. if (wp.cssClass != this.wallpaper) {
  581. newUserWallpapers.push(wp);
  582. }
  583. }
  584. await wallpaperStorage.removeData(this.wallpaper);
  585. this.userWallpapers = newUserWallpapers;
  586. this.wallpaper = '';
  587. }
  588. }
  589. async downloadWallpaper() {
  590. if (this.wallpaper.indexOf('user-paper') != 0)
  591. return;
  592. try {
  593. const d = this.$refs.download;
  594. const dataUrl = await wallpaperStorage.getData(this.wallpaper);
  595. if (!dataUrl)
  596. throw new Error('Файл обоев не найден');
  597. d.href = dataUrl;
  598. d.download = `wallpaper-#${this.wallpaper.replace('user-paper', '').substring(0, 4)}`;
  599. d.click();
  600. } catch (e) {
  601. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  602. }
  603. }
  604. keyHook(event) {
  605. if (!this.$root.stdDialog.active && event.type == 'keydown' && event.key == 'Escape') {
  606. this.close();
  607. }
  608. return true;
  609. }
  610. }
  611. export default vueComponent(SettingsPage);
  612. //-----------------------------------------------------------------------------
  613. </script>
  614. <style scoped>
  615. .tab {
  616. justify-content: initial;
  617. }
  618. .tab-panel {
  619. overflow-x: hidden;
  620. overflow-y: auto;
  621. font-size: 90%;
  622. padding: 0 10px 15px 10px;
  623. }
  624. .label-1, .label-3, .label-7 {
  625. width: 75px;
  626. }
  627. .label-2, .label-4, .label-5 {
  628. width: 110px;
  629. }
  630. .label-6 {
  631. width: 100px;
  632. }
  633. .text {
  634. font-size: 90%;
  635. line-height: 130%;
  636. }
  637. .button {
  638. margin: 3px 15px 3px 0;
  639. padding: 0 5px 0 5px;
  640. }
  641. .copy-icon {
  642. margin-left: 5px;
  643. cursor: pointer;
  644. font-size: 120%;
  645. color: blue;
  646. }
  647. .input {
  648. max-width: 150px;
  649. }
  650. .no-mp {
  651. margin: 0;
  652. padding: 0;
  653. }
  654. .col-left {
  655. width: 150px;
  656. }
  657. </style>
  658. <style>
  659. .sets-part-header {
  660. border-top: 2px solid #bbbbbb;
  661. font-weight: bold;
  662. font-size: 110%;
  663. margin-top: 15px;
  664. margin-bottom: 5px;
  665. }
  666. .sets-label {
  667. display: flex;
  668. flex-direction: column;
  669. justify-content: center;
  670. text-align: right;
  671. margin-right: 10px;
  672. overflow: hidden;
  673. }
  674. .sets-item {
  675. width: 100%;
  676. margin-top: 5px;
  677. margin-bottom: 5px;
  678. }
  679. </style>