Skip to content

Commit

Permalink
Change default data source to Document source.
Browse files Browse the repository at this point in the history
  • Loading branch information
boybook committed Apr 25, 2022
1 parent b79fe75 commit 184766b
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 60,998 deletions.
490 changes: 1 addition & 489 deletions dist/code.js

Large diffs are not rendered by default.

60,464 changes: 16 additions & 60,448 deletions dist/ui.html

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@
},
"dependencies": {
"@notionhq/client": "^1.0.4",
"@vue/compiler-sfc": "^3.0.2",
"@vueuse/core": "^8.2.5",
"figma-plugin-ds": "^0.1.8",
"tiny-emitter": "^2.1.0",
"vue-gtag": "^2.0.1",
"vue-i18n": "^9.2.0-beta.34",
"vuedraggable": "^4.1.0"
},
"devDependencies": {
"@figma/plugin-typings": "^1.18.2",
"@types/node": "^12.0.5",
"@vue/compiler-sfc": "^3.0.2",
"css-loader": "^2.1.1",
"html-webpack-inline-source-plugin": "0.0.10",
"html-webpack-plugin": "^3.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ let uiShowed = false;
// figma.clientStorage.setAsync("nodes", undefined).then();
// figma.clientStorage.setAsync("language", "ch").then();
// figma.clientStorage.setAsync("provider", undefined).then();
// figma.clientStorage.setAsync("access-token", undefined).then();
figma.clientStorage.setAsync("access-token", undefined).then();
// figma.root.setPluginData("file-id", "");
// figma.root.setPluginData("tags", "");
// figma.root.setPluginData("nodes", "");
figma.root.setPluginData("nodes", "");

let file = figma.fileKey;
if (!file) {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/I18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ export const messages = {
empty_intro: "You will easily manage everything across files",
empty_button: "Start Now",
alert: {
token: "Preview images require the Figma Token license to generate.",
token_file: "Preview images require the Figma Token license and File URL to generate.",
token: "Previews require the Figma Token license to generate.",
token_file: "Previews require the Figma Token license and File URL to generate.",
button: "License"
}
},
Expand Down
29 changes: 15 additions & 14 deletions src/ui/pagenode/PageNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Link
</a>
-->
<FigInput v-if="node" v-model:val="node.title" />
<FigInput v-if="node" v-model:val="node.title" @submit="toSave(false)" />
</div>
<div class="selected" :class="{ 'selected-empty': !collectTags || collectTags.length === 0 }">
<FigTag
Expand Down Expand Up @@ -59,7 +59,7 @@
import DataProvider from "../provider/DataProvider";
import { exportCover } from "../provider/CoverProvider";
import {computed, onMounted, PropType, ref, watch, watchEffect} from "vue";
import {computed, onMounted, PropType, ref, watch, watchEffect, watchPostEffect} from "vue";
import { dispatch, handleEvent} from "../uiMessageHandler";
import * as Utils from "../utils";
Expand All @@ -73,7 +73,6 @@ import PageNodeFooter from "./PageNodeFooter.vue";
import LoadingWithContent from "../component/LoadingWithContent.vue";
import AccessTokenModal from "../access/AccessTokenModal.vue";
import {useI18n} from "vue-i18n";
import {event, exception, pageview} from "vue-gtag";
import {removeCoverCache} from "../hooks/reloadCover";
export default {
Expand Down Expand Up @@ -121,10 +120,6 @@ export default {
console.log("PageNode.selectionchange", "拦截")
}
});
pageview({
page_title: "PageNode",
page_path: "/pagenode"
});
if (provider.type === 'document' || fileId.value) {
reloadNode(false, true);
}
Expand All @@ -136,6 +131,19 @@ export default {
}
});
/*const tryLazySave = (title: string) => {
return setTimeout(() => toSave(false), 1000);
};
watchPostEffect(onInvalidate => {
const timer = tryLazySave(node.value?.title);
onInvalidate(() => {
if (timer) {
clearTimeout(timer)
}
})
});*/
const reloadNode = async (keepCheck: boolean, reloadTags: boolean) => {
if (!currentSelection.value) return;
try {
Expand Down Expand Up @@ -260,7 +268,6 @@ export default {
loading.value = t('loading.error');
console.error(e);
dispatch('notify-err', e);
exception(e);
}
}
Expand All @@ -286,7 +293,6 @@ export default {
loading.value = t('loading.error');
console.error(e);
dispatch('notify-err', e);
exception(e);
}
}
Expand All @@ -306,7 +312,6 @@ export default {
loading.value = t('loading.error') + e;
console.error(e);
dispatch('notify-err', e);
exception(e);
}
}
Expand All @@ -324,7 +329,6 @@ export default {
loading.value = t('loading.error');
console.error(e);
dispatch('notify-err', e);
exception(e);
}
}
Expand All @@ -344,7 +348,6 @@ export default {
loading.value = t('loading.error');
console.error(e);
dispatch('notify-err', e);
exception(e);
}
}
Expand Down Expand Up @@ -408,7 +411,6 @@ export default {
loading.value = t('loading.error');
console.error(e);
dispatch('notify-err', e);
exception(e);
}
}
Expand All @@ -427,7 +429,6 @@ export default {
loading.value = t('loading.error') + e;
console.error(e);
dispatch('notify-err', e);
exception(e);
}
}
Expand Down
10 changes: 1 addition & 9 deletions src/ui/pageselect/PageSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
import TagTree from "../component/tagtree/TagTree.vue";
import {computed, onMounted, PropType, ref, watchEffect} from "vue";
import * as Utils from "../utils";
import { event, pageview } from 'vue-gtag';
import DataProvider from "../provider/DataProvider";
import PageSelectType from "./PageSelectType.vue";
import PageSelectBar from "./PageSelectBar.vue";
Expand Down Expand Up @@ -93,13 +92,6 @@ export default {
return props.provider.type === 'document' && !props.initData.fileId;
});
onMounted(() => {
pageview({
page_title: "PageSelect",
page_path: "/pageselect"
});
});
const tagTree = ref<Context.TagTree>();
const currentType = ref<string>(props.defaultTagType);
Expand Down Expand Up @@ -153,7 +145,7 @@ export default {
callback?.();
alertAccess.value = false;
// 文档数据源模式,还需要填写文件ID
if (needAccessBoth) {
if (needAccessBoth.value) {
fileIdModal.value = true;
}
}
Expand Down
18 changes: 10 additions & 8 deletions src/ui/pageselect/PageSelectTypeTag.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<template>
<div class="node-tag" ref="target">
<div class="node-tag-title">
<FigTag :tag="tag" :removable="false"></FigTag>
<div class="node-tag-title" :style="{ paddingBottom: result.length === 0 ? '4px' : '12px' }">
<FigTag :tag="tag" :removable="false" />
<LoadingIcon width="12" v-if="loading" style="margin-left: 8px; opacity: 0.45;" />
<span class="counter" v-if="!loading" v-bind:class="{ 'counter-zero': count === 0 }"> {{ count }} </span>
</div>
<ul>
<li class="node-tag-loading" v-if="loading">
<ul :style="{ maxHeight: result.length > 0 ? '196px' : 0, opacity: result.length > 0 ? 1 : 0, paddingBottom: result.length > 0 ? '8px' : 0 }">
<!--<li class="node-tag-loading" v-if="loading">
<LoadingIcon style="flex: none; order: 0; flex-grow: 0;" />
</li>
</li>-->
<li class="node-tag-loading" v-if="!loading && (!result || result.length === 0)">
<img :src="require('../resource/empty.svg')" alt="empty">
<p>Empty</p>
Expand Down Expand Up @@ -110,7 +111,7 @@ export default {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: flex-start;
align-items: center;
}
.node-tag ul {
Expand All @@ -122,6 +123,7 @@ export default {
padding: 0 0 8px 16px;
width: calc(100% - 16px);
overflow-y: hidden;
transition: all 500ms ease;
}
.node-tag li {
Expand All @@ -146,7 +148,7 @@ export default {
font-size: 12px;
line-height: 18px;
color: rgba(0, 0, 0, 0.85);
background: rgba(255, 255, 255, 0.5);
background: rgba(255, 255, 255, 0.4);
border-radius: 16px;
min-width: 8px;
font-family: Avenir, -apple-system, serif;
Expand All @@ -157,7 +159,7 @@ export default {
.counter-zero {
font-weight: 400 !important;
color: rgba(0, 0, 0, 0.25) !important;
background: rgba(255, 255, 255, 0.25) !important;
background: rgba(255, 255, 255, 0.2) !important;
}
</style>
2 changes: 1 addition & 1 deletion src/ui/pageselect/PageSelectTypeTagNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default {
// 加载时,如果发现cover不是有效url
onMounted(() => {
if (!props.node.cover?.startsWith("http")) { // 图片不是有效URL
if ((props.provider.type === 'document' && props.documentFileId || (props.provider.type !== 'document' && props.node.file_id))) {
if (props.accessToken && (props.provider.type === 'document' && props.documentFileId || (props.provider.type !== 'document' && props.node.file_id))) {
// 具备重新生成的条件
tryReloadCover();
} else {
Expand Down
8 changes: 0 additions & 8 deletions src/ui/pagesettings/PageSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ import DataProvider from "../provider/DataProvider";
import { DataProviderBlobSave } from "../provider/DataProviderBlobSave";
import { downloadJson } from "../hooks/downloadJson";
import * as Utils from "../utils";
import {event, pageview} from 'vue-gtag';
import AccessTokenModal from "../access/AccessTokenModal.vue";
import initProvider from "../provider/initProvider";
import {NotionProvider} from "../provider/NotionProvider";
Expand All @@ -149,13 +148,6 @@ export default {
setup(props, context) {
const { t, locale } = useI18n();
onMounted(() => {
pageview({
page_title: "PageSettings",
page_path: "/pageselect"
});
});
const saving = ref(false);
const accessModal = ref(false);
const fileIdModal = ref(false);
Expand Down
7 changes: 0 additions & 7 deletions src/ui/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { createI18n } from 'vue-i18n';
//@ts-ignore
import App from './ui.vue';
import { messages } from "./I18n";
import VueGtag from "vue-gtag";

const i18n = createI18n({
legacy: false,
Expand All @@ -24,11 +23,5 @@ app.directive('focus', {
})

app.use(i18n);
app.use(VueGtag, {
globalObjectName: "FigmaTags",
config: {
id: "G-VLF0LP4C5W"
}
});

app.mount('#app');
4 changes: 1 addition & 3 deletions src/ui/ui.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { useI18n } from 'vue-i18n';
import PageSettings from "./pagesettings/PageSettings.vue";
import initProvider from "./provider/initProvider";
import LoadingWithContent from "./component/LoadingWithContent.vue";
import { event } from 'vue-gtag'
export default {
components: {LoadingWithContent, PageSettings, PageSelect, PageNode },
Expand Down Expand Up @@ -72,7 +71,7 @@ export default {
locale.value = data.language;
initData.value = data;
page.value = data.page;
if (!initData.value.provider) initData.value.provider = JSON.stringify({ type: 'local' });
if (!initData.value.provider) initData.value.provider = JSON.stringify({ type: 'document' });
const prv: DataProvider = initProvider(JSON.parse(initData.value.provider));
const prvError = await prv.testError();
if (!prvError) {
Expand All @@ -84,7 +83,6 @@ export default {
//setProvider(initProvider({ type: 'local' }));
}
});
event('setup');
});
watchEffect(() => {
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4563,11 +4563,6 @@ vue-demi@*:
resolved "https://registry.yarnpkg.com/vue-demi/-/vue-demi-0.12.5.tgz#8eeed566a7d86eb090209a11723f887d28aeb2d1"
integrity sha512-BREuTgTYlUr0zw0EZn3hnhC3I6gPWv+Kwh4MCih6QcAeaTlaIX0DwOVN0wHej7hSvDPecz4jygy/idsgKfW58Q==

vue-gtag@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vue-gtag/-/vue-gtag-2.0.1.tgz#d4dc1b9cf79809c37ce844824c0f7fa97af520dd"
integrity sha512-aM4A58FVL0wV2ptYi+xzAjeg+pQVRyUcfBc5UkXAwQrR4t3WBhor50Izp2I+3Oo7+l+vWJ7u78DGcNzReb8S/A==

vue-i18n@^9.2.0-beta.34:
version "9.2.0-beta.34"
resolved "https://registry.yarnpkg.com/vue-i18n/-/vue-i18n-9.2.0-beta.34.tgz#ab092a4c3635782c49054995265e3e44e3533e8d"
Expand Down

0 comments on commit 184766b

Please sign in to comment.