Merge pull request #578 from liyasthomas/refactor/lint

Refactor/lint
This commit is contained in:
Liyas Thomas
2020-02-20 10:12:53 +05:30
committed by GitHub
9 changed files with 90 additions and 74 deletions

View File

@@ -22,13 +22,11 @@ $responsiveWidth: 768px;
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 4px; width: 4px;
height: 4px; height: 4px;
border-radius: 4px; background-color: var(--bg-dark-color);
background-color: var(--bg-light-color);
} }
::-webkit-scrollbar-thumb { ::-webkit-scrollbar-thumb {
background-color: var(--fg-light-color); background-color: var(--fg-light-color);
border-radius: 8px;
&:hover { &:hover {
background-color: var(--fg-color); background-color: var(--fg-color);
@@ -62,7 +60,6 @@ body {
scroll-behavior: smooth; scroll-behavior: smooth;
} }
// Make theme transition smoother.
body.afterLoad { body.afterLoad {
transition: background-color 0.2s ease-in-out; transition: background-color 0.2s ease-in-out;
} }
@@ -76,6 +73,10 @@ a {
color: inherit; color: inherit;
text-decoration: none; text-decoration: none;
transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out;
&.link {
color: var(--ac-color);
}
} }
header, header,
@@ -146,7 +147,8 @@ footer {
z-index: 1; z-index: 1;
height: 100vh; height: 100vh;
padding: 0 8px; padding: 0 8px;
background-color: var(--bg-light-color); background-color: var(--bg-dark-color);
transition: all 0.2s ease-in-out;
} }
.main { .main {
@@ -186,7 +188,6 @@ nav.primary-nav {
color: var(--fg-light-color); color: var(--fg-light-color);
fill: var(--fg-light-color); fill: var(--fg-light-color);
margin: 8px 0; margin: 8px 0;
transition: all 0.2s ease-in-out;
&:hover { &:hover {
color: var(--fg-color); color: var(--fg-color);
@@ -422,7 +423,6 @@ button {
color: var(--act-color); color: var(--act-color);
fill: var(--act-color); fill: var(--act-color);
box-shadow: inset 0 0 0 2px var(--fg-color); box-shadow: inset 0 0 0 2px var(--fg-color);
transition: all 0.2s ease-in-out;
} }
&.icon { &.icon {
@@ -437,7 +437,6 @@ button {
color: var(--fg-color); color: var(--fg-color);
fill: var(--fg-color); fill: var(--fg-color);
box-shadow: none; box-shadow: none;
transition: all 0.2s ease-in-out;
} }
} }
@@ -472,7 +471,6 @@ button {
fieldset { fieldset {
margin: 16px 0; margin: 16px 0;
border-radius: 16px; border-radius: 16px;
transition: all 0.2s ease-in-out;
background-color: var(--bg-dark-color); background-color: var(--bg-dark-color);
} }
@@ -565,7 +563,6 @@ code {
&:not([readonly]):not(.ace_editor):active, &:not([readonly]):not(.ace_editor):active,
&:not([readonly]):not(.ace_editor):focus { &:not([readonly]):not(.ace_editor):focus {
box-shadow: inset 0 0 0 2px var(--fg-light-color); box-shadow: inset 0 0 0 2px var(--fg-light-color);
transition: all 0.2s ease-in-out;
} }
} }
@@ -576,7 +573,6 @@ code {
&:active, &:active,
&:focus { &:focus {
box-shadow: inset 0 0 0 2px var(--fg-light-color); box-shadow: inset 0 0 0 2px var(--fg-light-color);
transition: all 0.2s ease-in-out;
} }
} }
@@ -884,18 +880,19 @@ input[type="radio"]:checked + label + .tab {
padding: 0; padding: 0;
width: 100%; width: 100%;
background-color: var(--bg-color); background-color: var(--bg-color);
transition: all 0.2s ease-in-out;
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.45); box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.45);
} }
nav.primary-nav { nav.primary-nav {
flex-flow: row nowrap; flex-flow: row nowrap;
overflow: auto; overflow: auto;
justify-content: space-around; justify-content: space-between;
background-color: var(--bg-dark-color);
a { a {
background-color: transparent; background-color: transparent;
margin: 8px; margin: 8px;
flex: 1;
&.nuxt-link-exact-active { &.nuxt-link-exact-active {
background-color: transparent; background-color: transparent;

View File

@@ -20,6 +20,7 @@
border-radius: 100%; border-radius: 100%;
border: 3px solid var(--bg-dark-color); border: 3px solid var(--bg-dark-color);
cursor: pointer; cursor: pointer;
transition: all 0.2s ease-in-out;
&.fg { &.fg {
color: var(--act-color); color: var(--act-color);

View File

@@ -121,4 +121,4 @@ export const commonHeaders = [
"X-Requested-With", "X-Requested-With",
"X-Robots-Tag", "X-Robots-Tag",
"X-UA-Compatible" "X-UA-Compatible"
] ];

View File

@@ -1,16 +1,17 @@
import AxiosStrategy from "./strategies/AxiosStrategy"; import AxiosStrategy from "./strategies/AxiosStrategy";
import ExtensionStrategy from "./strategies/ExtensionStrategy"; import ExtensionStrategy from "./strategies/ExtensionStrategy";
import FirefoxStrategy from "./strategies/FirefoxStrategy"; import FirefoxStrategy from "./strategies/FirefoxStrategy";
import ChromeStrategy, { hasChromeExtensionInstalled } from "./strategies/ChromeStrategy"; import ChromeStrategy, {
hasChromeExtensionInstalled
} from "./strategies/ChromeStrategy";
const isExtensionsAllowed = ({ state }) => { const isExtensionsAllowed = ({ state }) =>
return typeof state.postwoman.settings.EXTENSIONS_ENABLED === 'undefined' typeof state.postwoman.settings.EXTENSIONS_ENABLED === "undefined" ||
|| state.postwoman.settings.EXTENSIONS_ENABLED; state.postwoman.settings.EXTENSIONS_ENABLED;
}
const runAppropriateStrategy = (req, store) => { const runAppropriateStrategy = (req, store) => {
if (isExtensionsAllowed(store)) { if (isExtensionsAllowed(store)) {
if (typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== 'undefined') { if (typeof window.__POSTWOMAN_EXTENSION_HOOK__ !== "undefined") {
return ExtensionStrategy(req, store); return ExtensionStrategy(req, store);
} }
@@ -19,7 +20,7 @@ const runAppropriateStrategy = (req, store) => {
// Chrome Provides a chrome object for scripts to access // Chrome Provides a chrome object for scripts to access
// Check its availability to say whether you are in Google Chrome // Check its availability to say whether you are in Google Chrome
if (window.chrome && hasChromeExtensionInstalled()) { if (window.chrome && hasChromeExtensionInstalled()) {
return ChromeStrategy(req, store); return ChromeStrategy(req, store);
} }
// The firefox plugin injects a function to send requests through it // The firefox plugin injects a function to send requests through it
// If that is available, then we can use the FirefoxStrategy // If that is available, then we can use the FirefoxStrategy
@@ -29,10 +30,11 @@ const runAppropriateStrategy = (req, store) => {
} }
return AxiosStrategy(req, store); return AxiosStrategy(req, store);
} };
const sendNetworkRequest = (req, store) => const sendNetworkRequest = (req, store) =>
runAppropriateStrategy(req, store) runAppropriateStrategy(req, store).finally(() =>
.finally(() => window.$nuxt.$loading.finish()); window.$nuxt.$loading.finish()
);
export { sendNetworkRequest }; export { sendNetworkRequest };

View File

@@ -3,47 +3,54 @@ const EXTENSION_ID = "amknoiejhlmhancpahfcfcfhllgkpbld";
// Check if the Chrome Extension is present // Check if the Chrome Extension is present
// The Chrome extension injects an empty span to help detection. // The Chrome extension injects an empty span to help detection.
// Also check for the presence of window.chrome object to confirm smooth operations // Also check for the presence of window.chrome object to confirm smooth operations
export const hasChromeExtensionInstalled = () => { export const hasChromeExtensionInstalled = () =>
return document.getElementById("chromePWExtensionDetect") !== null; document.getElementById("chromePWExtensionDetect") !== null;
}
const chromeWithoutProxy = (req, _store) => new Promise((resolve, reject) => { const chromeWithoutProxy = (req, _store) =>
chrome.runtime.sendMessage( new Promise((resolve, reject) => {
EXTENSION_ID, { chrome.runtime.sendMessage(
messageType: "send-req", EXTENSION_ID,
data: { {
config: req messageType: "send-req",
} data: {
}, (message) => { config: req
if (message.data.error) { }
reject(message.data.error); },
} else { ({ data }) => {
resolve(message.data.response); if (data.error) {
} reject(data.error);
} } else {
); resolve(data.response);
});
const chromeWithProxy = (req, { state }) => new Promise((resolve, reject) => {
chrome.runtime.sendMessage(
EXTENSION_ID, {
messageType: "send-req",
data: {
config: {
method: "post",
url: state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
data: req
} }
} }
}, (message) => { );
if (message.data.error) { });
reject(error);
} else { const chromeWithProxy = (req, { state }) =>
resolve(message.data.response.data); new Promise((resolve, reject) => {
chrome.runtime.sendMessage(
EXTENSION_ID,
{
messageType: "send-req",
data: {
config: {
method: "post",
url:
state.postwoman.settings.PROXY_URL ||
"https://postwoman.apollotv.xyz/",
data: req
}
}
},
({ data }) => {
if (data.error) {
reject(error);
} else {
resolve(data.response.data);
}
} }
} );
) });
});
const chromeStrategy = (req, store) => { const chromeStrategy = (req, store) => {
if (store.state.postwoman.settings.PROXY_ENABLED) { if (store.state.postwoman.settings.PROXY_ENABLED) {
@@ -51,6 +58,6 @@ const chromeStrategy = (req, store) => {
} else { } else {
return chromeWithoutProxy(req, store); return chromeWithoutProxy(req, store);
} }
} };
export default chromeStrategy; export default chromeStrategy;

View File

@@ -1,7 +1,8 @@
const extensionWithProxy = async (req, { state }) => { const extensionWithProxy = async (req, { state }) => {
const { data } = await window.__POSTWOMAN_EXTENSION_HOOK__.sendRequest({ const { data } = await window.__POSTWOMAN_EXTENSION_HOOK__.sendRequest({
method: "post", method: "post",
url: state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/", url:
state.postwoman.settings.PROXY_URL || "https://postwoman.apollotv.xyz/",
data: req data: req
}); });
return data; return data;

View File

@@ -408,7 +408,7 @@
<div class="flex-wrap"> <div class="flex-wrap">
<span v-if="version.name" class="mono"> <span v-if="version.name" class="mono">
<a <a
class="link" class="footer-link"
:href=" :href="
'https://github.com/liyasthomas/postwoman/releases/tag/' + 'https://github.com/liyasthomas/postwoman/releases/tag/' +
version.name version.name
@@ -420,7 +420,7 @@
{{ version.name }} {{ version.name }}
</a> </a>
<a <a
class="link hide-on-small-screen" class="footer-link hide-on-small-screen"
href="https://www.netlify.com" href="https://www.netlify.com"
target="_blank" target="_blank"
rel="noopener" rel="noopener"
@@ -660,7 +660,7 @@
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">
.link { .footer-link {
margin: 8px 16px; margin: 8px 16px;
} }
</style> </style>
@@ -715,7 +715,7 @@ export default {
.then(() => {}) .then(() => {})
.catch(console.error); .catch(console.error);
} else { } else {
// fallback // fallback
} }
} }
}, },

View File

@@ -206,7 +206,12 @@
{{ $t("postwoman_official_proxy_hosting") }} {{ $t("postwoman_official_proxy_hosting") }}
<br /> <br />
{{ $t("read_the") }} {{ $t("read_the") }}
<a href="https://apollotv.xyz/legal" target="_blank" rel="noopener"> <a
class="link"
href="https://apollotv.xyz/legal"
target="_blank"
rel="noopener"
>
{{ $t("apollotv_privacy_policy") }} </a {{ $t("apollotv_privacy_policy") }} </a
>. >.
</p> </p>

View File

@@ -57,11 +57,11 @@ export const SETTINGS_KEYS = [
* e.g. 'auth' * e.g. 'auth'
*/ */
"URL_EXCLUDES", "URL_EXCLUDES",
/** /**
* A boolean value indicating whether to use the browser extensions * A boolean value indicating whether to use the browser extensions
* to run the requests * to run the requests
*/ */
"EXTENSIONS_ENABLED" "EXTENSIONS_ENABLED"
]; ];
@@ -118,7 +118,9 @@ export const mutations = {
addNewCollection({ collections }, collection) { addNewCollection({ collections }, collection) {
const { name } = collection; const { name } = collection;
const duplicateCollection = collections.some(item => item.name.toLowerCase() === name.toLowerCase()); const duplicateCollection = collections.some(
item => item.name.toLowerCase() === name.toLowerCase()
);
if (duplicateCollection) { if (duplicateCollection) {
this.$toast.info("Duplicate collection"); this.$toast.info("Duplicate collection");
return; return;
@@ -137,9 +139,10 @@ export const mutations = {
}, },
editCollection({ collections }, payload) { editCollection({ collections }, payload) {
const { collection, collectionIndex } = payload; const { collection: { name }, collectionIndex } = payload;
const { name } = collection; const duplicateCollection = collections.some(
const duplicateCollection = collections.some(item => item.name.toLowerCase() === name.toLowerCase()); item => item.name.toLowerCase() === name.toLowerCase()
);
if (duplicateCollection) { if (duplicateCollection) {
this.$toast.info("Duplicate collection"); this.$toast.info("Duplicate collection");
return; return;