tav-ui
Version:
87 lines (82 loc) • 3.11 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var useMessage = require('../../../hooks/web/useMessage2.js');
var useGlobalConfig = require('../../../hooks/global/useGlobalConfig2.js');
require('../../../locales/index2.js');
var index = require('../../button/index2.js');
var types = require('./types2.js');
var pluginVue_exportHelper = require('../../../../_virtual/plugin-vue_export-helper.js');
var transfer = require('../../../locales/transfer2.js');
const _sfc_main = vue.defineComponent({
name: "TaFollow",
components: {
TaButton: index.TaButton
},
props: types.followProps,
emits: ["update:show"],
setup(props) {
const { createMessage } = useMessage.useMessage();
const globalConfig = useGlobalConfig.useGlobalConfig("components");
const state = vue.reactive({
loading: false,
isFollow: false
});
const getFollwStatus = () => {
if (globalConfig.value && globalConfig.value.TaFollow) {
globalConfig.value.TaFollow.getFollwStatus(props.id).then((res) => {
state.isFollow = res.data ? !!res.data.status : false;
});
}
};
const changFollwStatus = () => {
state.loading = true;
if (globalConfig.value && globalConfig.value.TaFollow) {
globalConfig.value.TaFollow.updateFollowStatus({ followId: props.id, type: props.type }).then(() => {
const msg = state.isFollow ? transfer.tavI18n("Tav.follow.3") : transfer.tavI18n("Tav.follow.4");
state.isFollow = !state.isFollow;
createMessage.success(msg);
}).finally(() => {
state.loading = false;
});
}
};
getFollwStatus();
vue.watch(() => props.id, (newValue) => {
if (newValue) {
getFollwStatus();
}
});
return {
...vue.toRefs(state),
tavI18n: transfer.tavI18n,
getFollwStatus,
changFollwStatus
};
}
});
const _hoisted_1 = {
key: 0,
class: "active"
};
const _hoisted_2 = { key: 1 };
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_TaButton = vue.resolveComponent("TaButton");
return vue.openBlock(), vue.createBlock(_component_TaButton, {
class: "basic-follow",
type: "link",
loading: _ctx.loading,
onClick: _ctx.changFollwStatus
}, {
default: vue.withCtx(() => [
vue.createElementVNode("i", {
class: vue.normalizeClass(`basic-follow-icon basic-follow-icon${_ctx.isFollow ? "-active" : ""}`)
}, null, 2),
_ctx.isFollow ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_1, vue.toDisplayString(_ctx.tavI18n("Tav.follow.1")), 1)) : (vue.openBlock(), vue.createElementBlock("span", _hoisted_2, vue.toDisplayString(_ctx.tavI18n("Tav.follow.2")), 1))
]),
_: 1
}, 8, ["loading", "onClick"]);
}
var Follow = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/tav-ui/tav-ui/packages/components/follow/src/follow.vue"]]);
exports["default"] = Follow;
//# sourceMappingURL=follow2.js.map